babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4352. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @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.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** 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 */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** 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 */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** 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 */
  4523. static readonly GEQUAL: number;
  4524. /** 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 */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * 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.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * 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.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5302. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5303. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5304. lineProcessor?: (line: string, isFragment: boolean) => string;
  5305. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5306. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. }
  5308. }
  5309. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5310. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5329. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5330. /** @hidden */
  5331. export class ShaderCodeNode {
  5332. line: string;
  5333. children: ShaderCodeNode[];
  5334. additionalDefineKey?: string;
  5335. additionalDefineValue?: string;
  5336. isValid(preprocessors: {
  5337. [key: string]: string;
  5338. }): boolean;
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5345. /** @hidden */
  5346. export class ShaderCodeCursor {
  5347. private _lines;
  5348. lineIndex: number;
  5349. readonly currentLine: string;
  5350. readonly canRead: boolean;
  5351. lines: string[];
  5352. }
  5353. }
  5354. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5355. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5356. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5357. /** @hidden */
  5358. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5359. process(preprocessors: {
  5360. [key: string]: string;
  5361. }, options: ProcessingOptions): string;
  5362. }
  5363. }
  5364. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5365. /** @hidden */
  5366. export class ShaderDefineExpression {
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5373. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5374. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5375. /** @hidden */
  5376. export class ShaderCodeTestNode extends ShaderCodeNode {
  5377. testExpression: ShaderDefineExpression;
  5378. isValid(preprocessors: {
  5379. [key: string]: string;
  5380. }): boolean;
  5381. }
  5382. }
  5383. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5384. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5385. /** @hidden */
  5386. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5387. define: string;
  5388. not: boolean;
  5389. constructor(define: string, not?: boolean);
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5396. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5397. /** @hidden */
  5398. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5399. leftOperand: ShaderDefineExpression;
  5400. rightOperand: ShaderDefineExpression;
  5401. isTrue(preprocessors: {
  5402. [key: string]: string;
  5403. }): boolean;
  5404. }
  5405. }
  5406. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5407. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5408. /** @hidden */
  5409. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5410. leftOperand: ShaderDefineExpression;
  5411. rightOperand: ShaderDefineExpression;
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5418. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5419. /** @hidden */
  5420. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5421. define: string;
  5422. operand: string;
  5423. testValue: string;
  5424. constructor(define: string, operand: string, testValue: string);
  5425. isTrue(preprocessors: {
  5426. [key: string]: string;
  5427. }): boolean;
  5428. }
  5429. }
  5430. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5431. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5432. /** @hidden */
  5433. export class ShaderProcessor {
  5434. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5435. private static _ProcessPrecision;
  5436. private static _ExtractOperation;
  5437. private static _BuildSubExpression;
  5438. private static _BuildExpression;
  5439. private static _MoveCursorWithinIf;
  5440. private static _MoveCursor;
  5441. private static _EvaluatePreProcessors;
  5442. private static _PreparePreProcessors;
  5443. private static _ProcessShaderConversion;
  5444. private static _ProcessIncludes;
  5445. }
  5446. }
  5447. declare module "babylonjs/Misc/performanceMonitor" {
  5448. /**
  5449. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5450. */
  5451. export class PerformanceMonitor {
  5452. private _enabled;
  5453. private _rollingFrameTime;
  5454. private _lastFrameTimeMs;
  5455. /**
  5456. * constructor
  5457. * @param frameSampleSize The number of samples required to saturate the sliding window
  5458. */
  5459. constructor(frameSampleSize?: number);
  5460. /**
  5461. * Samples current frame
  5462. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5463. */
  5464. sampleFrame(timeMs?: number): void;
  5465. /**
  5466. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5467. */
  5468. readonly averageFrameTime: number;
  5469. /**
  5470. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTimeVariance: number;
  5473. /**
  5474. * Returns the frame time of the most recent frame
  5475. */
  5476. readonly instantaneousFrameTime: number;
  5477. /**
  5478. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5479. */
  5480. readonly averageFPS: number;
  5481. /**
  5482. * Returns the average framerate in frames per second using the most recent frame time
  5483. */
  5484. readonly instantaneousFPS: number;
  5485. /**
  5486. * Returns true if enough samples have been taken to completely fill the sliding window
  5487. */
  5488. readonly isSaturated: boolean;
  5489. /**
  5490. * Enables contributions to the sliding window sample set
  5491. */
  5492. enable(): void;
  5493. /**
  5494. * Disables contributions to the sliding window sample set
  5495. * Samples will not be interpolated over the disabled period
  5496. */
  5497. disable(): void;
  5498. /**
  5499. * Returns true if sampling is enabled
  5500. */
  5501. readonly isEnabled: boolean;
  5502. /**
  5503. * Resets performance monitor
  5504. */
  5505. reset(): void;
  5506. }
  5507. /**
  5508. * RollingAverage
  5509. *
  5510. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5511. */
  5512. export class RollingAverage {
  5513. /**
  5514. * Current average
  5515. */
  5516. average: number;
  5517. /**
  5518. * Current variance
  5519. */
  5520. variance: number;
  5521. protected _samples: Array<number>;
  5522. protected _sampleCount: number;
  5523. protected _pos: number;
  5524. protected _m2: number;
  5525. /**
  5526. * constructor
  5527. * @param length The number of samples required to saturate the sliding window
  5528. */
  5529. constructor(length: number);
  5530. /**
  5531. * Adds a sample to the sample set
  5532. * @param v The sample value
  5533. */
  5534. add(v: number): void;
  5535. /**
  5536. * Returns previously added values or null if outside of history or outside the sliding window domain
  5537. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5538. * @return Value previously recorded with add() or null if outside of range
  5539. */
  5540. history(i: number): number;
  5541. /**
  5542. * Returns true if enough samples have been taken to completely fill the sliding window
  5543. * @return true if sample-set saturated
  5544. */
  5545. isSaturated(): boolean;
  5546. /**
  5547. * Resets the rolling average (equivalent to 0 samples taken so far)
  5548. */
  5549. reset(): void;
  5550. /**
  5551. * Wraps a value around the sample range boundaries
  5552. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5553. * @return Wrapped position in sample range
  5554. */
  5555. protected _wrapPosition(i: number): number;
  5556. }
  5557. }
  5558. declare module "babylonjs/Misc/stringDictionary" {
  5559. import { Nullable } from "babylonjs/types";
  5560. /**
  5561. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5562. * The underlying implementation relies on an associative array to ensure the best performances.
  5563. * The value can be anything including 'null' but except 'undefined'
  5564. */
  5565. export class StringDictionary<T> {
  5566. /**
  5567. * This will clear this dictionary and copy the content from the 'source' one.
  5568. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5569. * @param source the dictionary to take the content from and copy to this dictionary
  5570. */
  5571. copyFrom(source: StringDictionary<T>): void;
  5572. /**
  5573. * Get a value based from its key
  5574. * @param key the given key to get the matching value from
  5575. * @return the value if found, otherwise undefined is returned
  5576. */
  5577. get(key: string): T | undefined;
  5578. /**
  5579. * Get a value from its key or add it if it doesn't exist.
  5580. * This method will ensure you that a given key/data will be present in the dictionary.
  5581. * @param key the given key to get the matching value from
  5582. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5583. * The factory will only be invoked if there's no data for the given key.
  5584. * @return the value corresponding to the key.
  5585. */
  5586. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5587. /**
  5588. * Get a value from its key if present in the dictionary otherwise add it
  5589. * @param key the key to get the value from
  5590. * @param val if there's no such key/value pair in the dictionary add it with this value
  5591. * @return the value corresponding to the key
  5592. */
  5593. getOrAdd(key: string, val: T): T;
  5594. /**
  5595. * Check if there's a given key in the dictionary
  5596. * @param key the key to check for
  5597. * @return true if the key is present, false otherwise
  5598. */
  5599. contains(key: string): boolean;
  5600. /**
  5601. * Add a new key and its corresponding value
  5602. * @param key the key to add
  5603. * @param value the value corresponding to the key
  5604. * @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
  5605. */
  5606. add(key: string, value: T): boolean;
  5607. /**
  5608. * Update a specific value associated to a key
  5609. * @param key defines the key to use
  5610. * @param value defines the value to store
  5611. * @returns true if the value was updated (or false if the key was not found)
  5612. */
  5613. set(key: string, value: T): boolean;
  5614. /**
  5615. * Get the element of the given key and remove it from the dictionary
  5616. * @param key defines the key to search
  5617. * @returns the value associated with the key or null if not found
  5618. */
  5619. getAndRemove(key: string): Nullable<T>;
  5620. /**
  5621. * Remove a key/value from the dictionary.
  5622. * @param key the key to remove
  5623. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5624. */
  5625. remove(key: string): boolean;
  5626. /**
  5627. * Clear the whole content of the dictionary
  5628. */
  5629. clear(): void;
  5630. /**
  5631. * Gets the current count
  5632. */
  5633. readonly count: number;
  5634. /**
  5635. * Execute a callback on each key/val of the dictionary.
  5636. * Note that you can remove any element in this dictionary in the callback implementation
  5637. * @param callback the callback to execute on a given key/value pair
  5638. */
  5639. forEach(callback: (key: string, val: T) => void): void;
  5640. /**
  5641. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5642. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5643. * Note that you can remove any element in this dictionary in the callback implementation
  5644. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5645. * @returns the first item
  5646. */
  5647. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5648. private _count;
  5649. private _data;
  5650. }
  5651. }
  5652. declare module "babylonjs/Misc/promise" {
  5653. /**
  5654. * Helper class that provides a small promise polyfill
  5655. */
  5656. export class PromisePolyfill {
  5657. /**
  5658. * Static function used to check if the polyfill is required
  5659. * If this is the case then the function will inject the polyfill to window.Promise
  5660. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5661. */
  5662. static Apply(force?: boolean): void;
  5663. }
  5664. }
  5665. declare module "babylonjs/Meshes/buffer" {
  5666. import { Nullable, DataArray } from "babylonjs/types";
  5667. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5668. /**
  5669. * Class used to store data that will be store in GPU memory
  5670. */
  5671. export class Buffer {
  5672. private _engine;
  5673. private _buffer;
  5674. /** @hidden */
  5675. _data: Nullable<DataArray>;
  5676. private _updatable;
  5677. private _instanced;
  5678. /**
  5679. * Gets the byte stride.
  5680. */
  5681. readonly byteStride: number;
  5682. /**
  5683. * Constructor
  5684. * @param engine the engine
  5685. * @param data the data to use for this buffer
  5686. * @param updatable whether the data is updatable
  5687. * @param stride the stride (optional)
  5688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5689. * @param instanced whether the buffer is instanced (optional)
  5690. * @param useBytes set to true if the stride in in bytes (optional)
  5691. */
  5692. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5693. /**
  5694. * Create a new VertexBuffer based on the current buffer
  5695. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5696. * @param offset defines offset in the buffer (0 by default)
  5697. * @param size defines the size in floats of attributes (position is 3 for instance)
  5698. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5699. * @param instanced defines if the vertex buffer contains indexed data
  5700. * @param useBytes defines if the offset and stride are in bytes
  5701. * @returns the new vertex buffer
  5702. */
  5703. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5704. /**
  5705. * Gets a boolean indicating if the Buffer is updatable?
  5706. * @returns true if the buffer is updatable
  5707. */
  5708. isUpdatable(): boolean;
  5709. /**
  5710. * Gets current buffer's data
  5711. * @returns a DataArray or null
  5712. */
  5713. getData(): Nullable<DataArray>;
  5714. /**
  5715. * Gets underlying native buffer
  5716. * @returns underlying native buffer
  5717. */
  5718. getBuffer(): Nullable<DataBuffer>;
  5719. /**
  5720. * Gets the stride in float32 units (i.e. byte stride / 4).
  5721. * May not be an integer if the byte stride is not divisible by 4.
  5722. * DEPRECATED. Use byteStride instead.
  5723. * @returns the stride in float32 units
  5724. */
  5725. getStrideSize(): number;
  5726. /**
  5727. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5728. * @param data defines the data to store
  5729. */
  5730. create(data?: Nullable<DataArray>): void;
  5731. /** @hidden */
  5732. _rebuild(): void;
  5733. /**
  5734. * Update current buffer data
  5735. * @param data defines the data to store
  5736. */
  5737. update(data: DataArray): void;
  5738. /**
  5739. * Updates the data directly.
  5740. * @param data the new data
  5741. * @param offset the new offset
  5742. * @param vertexCount the vertex count (optional)
  5743. * @param useBytes set to true if the offset is in bytes
  5744. */
  5745. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5746. /**
  5747. * Release all resources
  5748. */
  5749. dispose(): void;
  5750. }
  5751. /**
  5752. * Specialized buffer used to store vertex data
  5753. */
  5754. export class VertexBuffer {
  5755. /** @hidden */
  5756. _buffer: Buffer;
  5757. private _kind;
  5758. private _size;
  5759. private _ownsBuffer;
  5760. private _instanced;
  5761. private _instanceDivisor;
  5762. /**
  5763. * The byte type.
  5764. */
  5765. static readonly BYTE: number;
  5766. /**
  5767. * The unsigned byte type.
  5768. */
  5769. static readonly UNSIGNED_BYTE: number;
  5770. /**
  5771. * The short type.
  5772. */
  5773. static readonly SHORT: number;
  5774. /**
  5775. * The unsigned short type.
  5776. */
  5777. static readonly UNSIGNED_SHORT: number;
  5778. /**
  5779. * The integer type.
  5780. */
  5781. static readonly INT: number;
  5782. /**
  5783. * The unsigned integer type.
  5784. */
  5785. static readonly UNSIGNED_INT: number;
  5786. /**
  5787. * The float type.
  5788. */
  5789. static readonly FLOAT: number;
  5790. /**
  5791. * Gets or sets the instance divisor when in instanced mode
  5792. */
  5793. instanceDivisor: number;
  5794. /**
  5795. * Gets the byte stride.
  5796. */
  5797. readonly byteStride: number;
  5798. /**
  5799. * Gets the byte offset.
  5800. */
  5801. readonly byteOffset: number;
  5802. /**
  5803. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5804. */
  5805. readonly normalized: boolean;
  5806. /**
  5807. * Gets the data type of each component in the array.
  5808. */
  5809. readonly type: number;
  5810. /**
  5811. * Constructor
  5812. * @param engine the engine
  5813. * @param data the data to use for this vertex buffer
  5814. * @param kind the vertex buffer kind
  5815. * @param updatable whether the data is updatable
  5816. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5817. * @param stride the stride (optional)
  5818. * @param instanced whether the buffer is instanced (optional)
  5819. * @param offset the offset of the data (optional)
  5820. * @param size the number of components (optional)
  5821. * @param type the type of the component (optional)
  5822. * @param normalized whether the data contains normalized data (optional)
  5823. * @param useBytes set to true if stride and offset are in bytes (optional)
  5824. */
  5825. 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);
  5826. /** @hidden */
  5827. _rebuild(): void;
  5828. /**
  5829. * Returns the kind of the VertexBuffer (string)
  5830. * @returns a string
  5831. */
  5832. getKind(): string;
  5833. /**
  5834. * Gets a boolean indicating if the VertexBuffer is updatable?
  5835. * @returns true if the buffer is updatable
  5836. */
  5837. isUpdatable(): boolean;
  5838. /**
  5839. * Gets current buffer's data
  5840. * @returns a DataArray or null
  5841. */
  5842. getData(): Nullable<DataArray>;
  5843. /**
  5844. * Gets underlying native buffer
  5845. * @returns underlying native buffer
  5846. */
  5847. getBuffer(): Nullable<DataBuffer>;
  5848. /**
  5849. * Gets the stride in float32 units (i.e. byte stride / 4).
  5850. * May not be an integer if the byte stride is not divisible by 4.
  5851. * DEPRECATED. Use byteStride instead.
  5852. * @returns the stride in float32 units
  5853. */
  5854. getStrideSize(): number;
  5855. /**
  5856. * Returns the offset as a multiple of the type byte length.
  5857. * DEPRECATED. Use byteOffset instead.
  5858. * @returns the offset in bytes
  5859. */
  5860. getOffset(): number;
  5861. /**
  5862. * Returns the number of components per vertex attribute (integer)
  5863. * @returns the size in float
  5864. */
  5865. getSize(): number;
  5866. /**
  5867. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5868. * @returns true if this buffer is instanced
  5869. */
  5870. getIsInstanced(): boolean;
  5871. /**
  5872. * Returns the instancing divisor, zero for non-instanced (integer).
  5873. * @returns a number
  5874. */
  5875. getInstanceDivisor(): number;
  5876. /**
  5877. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5878. * @param data defines the data to store
  5879. */
  5880. create(data?: DataArray): void;
  5881. /**
  5882. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5883. * This function will create a new buffer if the current one is not updatable
  5884. * @param data defines the data to store
  5885. */
  5886. update(data: DataArray): void;
  5887. /**
  5888. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5889. * Returns the directly updated WebGLBuffer.
  5890. * @param data the new data
  5891. * @param offset the new offset
  5892. * @param useBytes set to true if the offset is in bytes
  5893. */
  5894. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5895. /**
  5896. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5897. */
  5898. dispose(): void;
  5899. /**
  5900. * Enumerates each value of this vertex buffer as numbers.
  5901. * @param count the number of values to enumerate
  5902. * @param callback the callback function called for each value
  5903. */
  5904. forEach(count: number, callback: (value: number, index: number) => void): void;
  5905. /**
  5906. * Positions
  5907. */
  5908. static readonly PositionKind: string;
  5909. /**
  5910. * Normals
  5911. */
  5912. static readonly NormalKind: string;
  5913. /**
  5914. * Tangents
  5915. */
  5916. static readonly TangentKind: string;
  5917. /**
  5918. * Texture coordinates
  5919. */
  5920. static readonly UVKind: string;
  5921. /**
  5922. * Texture coordinates 2
  5923. */
  5924. static readonly UV2Kind: string;
  5925. /**
  5926. * Texture coordinates 3
  5927. */
  5928. static readonly UV3Kind: string;
  5929. /**
  5930. * Texture coordinates 4
  5931. */
  5932. static readonly UV4Kind: string;
  5933. /**
  5934. * Texture coordinates 5
  5935. */
  5936. static readonly UV5Kind: string;
  5937. /**
  5938. * Texture coordinates 6
  5939. */
  5940. static readonly UV6Kind: string;
  5941. /**
  5942. * Colors
  5943. */
  5944. static readonly ColorKind: string;
  5945. /**
  5946. * Matrix indices (for bones)
  5947. */
  5948. static readonly MatricesIndicesKind: string;
  5949. /**
  5950. * Matrix weights (for bones)
  5951. */
  5952. static readonly MatricesWeightsKind: string;
  5953. /**
  5954. * Additional matrix indices (for bones)
  5955. */
  5956. static readonly MatricesIndicesExtraKind: string;
  5957. /**
  5958. * Additional matrix weights (for bones)
  5959. */
  5960. static readonly MatricesWeightsExtraKind: string;
  5961. /**
  5962. * Deduces the stride given a kind.
  5963. * @param kind The kind string to deduce
  5964. * @returns The deduced stride
  5965. */
  5966. static DeduceStride(kind: string): number;
  5967. /**
  5968. * Gets the byte length of the given type.
  5969. * @param type the type
  5970. * @returns the number of bytes
  5971. */
  5972. static GetTypeByteLength(type: number): number;
  5973. /**
  5974. * Enumerates each value of the given parameters as numbers.
  5975. * @param data the data to enumerate
  5976. * @param byteOffset the byte offset of the data
  5977. * @param byteStride the byte stride of the data
  5978. * @param componentCount the number of components per element
  5979. * @param componentType the type of the component
  5980. * @param count the number of values to enumerate
  5981. * @param normalized whether the data is normalized
  5982. * @param callback the callback function called for each value
  5983. */
  5984. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5985. private static _GetFloatValue;
  5986. }
  5987. }
  5988. declare module "babylonjs/Maths/sphericalPolynomial" {
  5989. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5990. /**
  5991. * Class representing spherical harmonics coefficients to the 3rd degree
  5992. */
  5993. export class SphericalHarmonics {
  5994. /**
  5995. * Defines whether or not the harmonics have been prescaled for rendering.
  5996. */
  5997. preScaled: boolean;
  5998. /**
  5999. * The l0,0 coefficients of the spherical harmonics
  6000. */
  6001. l00: Vector3;
  6002. /**
  6003. * The l1,-1 coefficients of the spherical harmonics
  6004. */
  6005. l1_1: Vector3;
  6006. /**
  6007. * The l1,0 coefficients of the spherical harmonics
  6008. */
  6009. l10: Vector3;
  6010. /**
  6011. * The l1,1 coefficients of the spherical harmonics
  6012. */
  6013. l11: Vector3;
  6014. /**
  6015. * The l2,-2 coefficients of the spherical harmonics
  6016. */
  6017. l2_2: Vector3;
  6018. /**
  6019. * The l2,-1 coefficients of the spherical harmonics
  6020. */
  6021. l2_1: Vector3;
  6022. /**
  6023. * The l2,0 coefficients of the spherical harmonics
  6024. */
  6025. l20: Vector3;
  6026. /**
  6027. * The l2,1 coefficients of the spherical harmonics
  6028. */
  6029. l21: Vector3;
  6030. /**
  6031. * The l2,2 coefficients of the spherical harmonics
  6032. */
  6033. l22: Vector3;
  6034. /**
  6035. * Adds a light to the spherical harmonics
  6036. * @param direction the direction of the light
  6037. * @param color the color of the light
  6038. * @param deltaSolidAngle the delta solid angle of the light
  6039. */
  6040. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6041. /**
  6042. * Scales the spherical harmonics by the given amount
  6043. * @param scale the amount to scale
  6044. */
  6045. scaleInPlace(scale: number): void;
  6046. /**
  6047. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6048. *
  6049. * ```
  6050. * E_lm = A_l * L_lm
  6051. * ```
  6052. *
  6053. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6054. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6055. * the scaling factors are given in equation 9.
  6056. */
  6057. convertIncidentRadianceToIrradiance(): void;
  6058. /**
  6059. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6060. *
  6061. * ```
  6062. * L = (1/pi) * E * rho
  6063. * ```
  6064. *
  6065. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6066. */
  6067. convertIrradianceToLambertianRadiance(): void;
  6068. /**
  6069. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6070. * required operations at run time.
  6071. *
  6072. * This is simply done by scaling back the SH with Ylm constants parameter.
  6073. * The trigonometric part being applied by the shader at run time.
  6074. */
  6075. preScaleForRendering(): void;
  6076. /**
  6077. * Constructs a spherical harmonics from an array.
  6078. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6079. * @returns the spherical harmonics
  6080. */
  6081. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6082. /**
  6083. * Gets the spherical harmonics from polynomial
  6084. * @param polynomial the spherical polynomial
  6085. * @returns the spherical harmonics
  6086. */
  6087. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6088. }
  6089. /**
  6090. * Class representing spherical polynomial coefficients to the 3rd degree
  6091. */
  6092. export class SphericalPolynomial {
  6093. private _harmonics;
  6094. /**
  6095. * The spherical harmonics used to create the polynomials.
  6096. */
  6097. readonly preScaledHarmonics: SphericalHarmonics;
  6098. /**
  6099. * The x coefficients of the spherical polynomial
  6100. */
  6101. x: Vector3;
  6102. /**
  6103. * The y coefficients of the spherical polynomial
  6104. */
  6105. y: Vector3;
  6106. /**
  6107. * The z coefficients of the spherical polynomial
  6108. */
  6109. z: Vector3;
  6110. /**
  6111. * The xx coefficients of the spherical polynomial
  6112. */
  6113. xx: Vector3;
  6114. /**
  6115. * The yy coefficients of the spherical polynomial
  6116. */
  6117. yy: Vector3;
  6118. /**
  6119. * The zz coefficients of the spherical polynomial
  6120. */
  6121. zz: Vector3;
  6122. /**
  6123. * The xy coefficients of the spherical polynomial
  6124. */
  6125. xy: Vector3;
  6126. /**
  6127. * The yz coefficients of the spherical polynomial
  6128. */
  6129. yz: Vector3;
  6130. /**
  6131. * The zx coefficients of the spherical polynomial
  6132. */
  6133. zx: Vector3;
  6134. /**
  6135. * Adds an ambient color to the spherical polynomial
  6136. * @param color the color to add
  6137. */
  6138. addAmbient(color: Color3): void;
  6139. /**
  6140. * Scales the spherical polynomial by the given amount
  6141. * @param scale the amount to scale
  6142. */
  6143. scaleInPlace(scale: number): void;
  6144. /**
  6145. * Gets the spherical polynomial from harmonics
  6146. * @param harmonics the spherical harmonics
  6147. * @returns the spherical polynomial
  6148. */
  6149. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6150. /**
  6151. * Constructs a spherical polynomial from an array.
  6152. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6153. * @returns the spherical polynomial
  6154. */
  6155. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6156. }
  6157. }
  6158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6159. import { Nullable } from "babylonjs/types";
  6160. /**
  6161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6162. */
  6163. export interface CubeMapInfo {
  6164. /**
  6165. * The pixel array for the front face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. front: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the back face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. back: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the left face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. left: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the right face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. right: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the up face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. up: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The pixel array for the down face.
  6191. * This is stored in format, left to right, up to down format.
  6192. */
  6193. down: Nullable<ArrayBufferView>;
  6194. /**
  6195. * The size of the cubemap stored.
  6196. *
  6197. * Each faces will be size * size pixels.
  6198. */
  6199. size: number;
  6200. /**
  6201. * The format of the texture.
  6202. *
  6203. * RGBA, RGB.
  6204. */
  6205. format: number;
  6206. /**
  6207. * The type of the texture data.
  6208. *
  6209. * UNSIGNED_INT, FLOAT.
  6210. */
  6211. type: number;
  6212. /**
  6213. * Specifies whether the texture is in gamma space.
  6214. */
  6215. gammaSpace: boolean;
  6216. }
  6217. /**
  6218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6219. */
  6220. export class PanoramaToCubeMapTools {
  6221. private static FACE_FRONT;
  6222. private static FACE_BACK;
  6223. private static FACE_RIGHT;
  6224. private static FACE_LEFT;
  6225. private static FACE_DOWN;
  6226. private static FACE_UP;
  6227. /**
  6228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6229. *
  6230. * @param float32Array The source data.
  6231. * @param inputWidth The width of the input panorama.
  6232. * @param inputHeight The height of the input panorama.
  6233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6234. * @return The cubemap data
  6235. */
  6236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6237. private static CreateCubemapTexture;
  6238. private static CalcProjectionSpherical;
  6239. }
  6240. }
  6241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6245. /**
  6246. * Helper class dealing with the extraction of spherical polynomial dataArray
  6247. * from a cube map.
  6248. */
  6249. export class CubeMapToSphericalPolynomialTools {
  6250. private static FileFaces;
  6251. /**
  6252. * Converts a texture to the according Spherical Polynomial data.
  6253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6254. *
  6255. * @param texture The texture to extract the information from.
  6256. * @return The Spherical Polynomial data.
  6257. */
  6258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6259. /**
  6260. * Converts a cubemap to the according Spherical Polynomial data.
  6261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6262. *
  6263. * @param cubeInfo The Cube map to extract the information from.
  6264. * @return The Spherical Polynomial data.
  6265. */
  6266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6267. }
  6268. }
  6269. declare module "babylonjs/Engines/engineStore" {
  6270. import { Nullable } from "babylonjs/types";
  6271. import { Engine } from "babylonjs/Engines/engine";
  6272. import { Scene } from "babylonjs/scene";
  6273. /**
  6274. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6275. * during the life time of the application.
  6276. */
  6277. export class EngineStore {
  6278. /** Gets the list of created engines */
  6279. static Instances: import("babylonjs/Engines/engine").Engine[];
  6280. /** @hidden */
  6281. static _LastCreatedScene: Nullable<Scene>;
  6282. /**
  6283. * Gets the latest created engine
  6284. */
  6285. static readonly LastCreatedEngine: Nullable<Engine>;
  6286. /**
  6287. * Gets the latest created scene
  6288. */
  6289. static readonly LastCreatedScene: Nullable<Scene>;
  6290. }
  6291. }
  6292. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6293. /**
  6294. * Define options used to create a render target texture
  6295. */
  6296. export class RenderTargetCreationOptions {
  6297. /**
  6298. * Specifies is mipmaps must be generated
  6299. */
  6300. generateMipMaps?: boolean;
  6301. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6302. generateDepthBuffer?: boolean;
  6303. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6304. generateStencilBuffer?: boolean;
  6305. /** Defines texture type (int by default) */
  6306. type?: number;
  6307. /** Defines sampling mode (trilinear by default) */
  6308. samplingMode?: number;
  6309. /** Defines format (RGBA by default) */
  6310. format?: number;
  6311. }
  6312. }
  6313. declare module "babylonjs/States/alphaCullingState" {
  6314. /**
  6315. * @hidden
  6316. **/
  6317. export class _AlphaState {
  6318. private _isAlphaBlendDirty;
  6319. private _isBlendFunctionParametersDirty;
  6320. private _isBlendEquationParametersDirty;
  6321. private _isBlendConstantsDirty;
  6322. private _alphaBlend;
  6323. private _blendFunctionParameters;
  6324. private _blendEquationParameters;
  6325. private _blendConstants;
  6326. /**
  6327. * Initializes the state.
  6328. */
  6329. constructor();
  6330. readonly isDirty: boolean;
  6331. alphaBlend: boolean;
  6332. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6333. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6334. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6335. reset(): void;
  6336. apply(gl: WebGLRenderingContext): void;
  6337. }
  6338. }
  6339. declare module "babylonjs/States/depthCullingState" {
  6340. import { Nullable } from "babylonjs/types";
  6341. /**
  6342. * @hidden
  6343. **/
  6344. export class _DepthCullingState {
  6345. private _isDepthTestDirty;
  6346. private _isDepthMaskDirty;
  6347. private _isDepthFuncDirty;
  6348. private _isCullFaceDirty;
  6349. private _isCullDirty;
  6350. private _isZOffsetDirty;
  6351. private _isFrontFaceDirty;
  6352. private _depthTest;
  6353. private _depthMask;
  6354. private _depthFunc;
  6355. private _cull;
  6356. private _cullFace;
  6357. private _zOffset;
  6358. private _frontFace;
  6359. /**
  6360. * Initializes the state.
  6361. */
  6362. constructor();
  6363. readonly isDirty: boolean;
  6364. zOffset: number;
  6365. cullFace: Nullable<number>;
  6366. cull: Nullable<boolean>;
  6367. depthFunc: Nullable<number>;
  6368. depthMask: boolean;
  6369. depthTest: boolean;
  6370. frontFace: Nullable<number>;
  6371. reset(): void;
  6372. apply(gl: WebGLRenderingContext): void;
  6373. }
  6374. }
  6375. declare module "babylonjs/States/stencilState" {
  6376. /**
  6377. * @hidden
  6378. **/
  6379. export class _StencilState {
  6380. /** 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 */
  6381. static readonly ALWAYS: number;
  6382. /** Passed to stencilOperation to specify that stencil value must be kept */
  6383. static readonly KEEP: number;
  6384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6385. static readonly REPLACE: number;
  6386. private _isStencilTestDirty;
  6387. private _isStencilMaskDirty;
  6388. private _isStencilFuncDirty;
  6389. private _isStencilOpDirty;
  6390. private _stencilTest;
  6391. private _stencilMask;
  6392. private _stencilFunc;
  6393. private _stencilFuncRef;
  6394. private _stencilFuncMask;
  6395. private _stencilOpStencilFail;
  6396. private _stencilOpDepthFail;
  6397. private _stencilOpStencilDepthPass;
  6398. readonly isDirty: boolean;
  6399. stencilFunc: number;
  6400. stencilFuncRef: number;
  6401. stencilFuncMask: number;
  6402. stencilOpStencilFail: number;
  6403. stencilOpDepthFail: number;
  6404. stencilOpStencilDepthPass: number;
  6405. stencilMask: number;
  6406. stencilTest: boolean;
  6407. constructor();
  6408. reset(): void;
  6409. apply(gl: WebGLRenderingContext): void;
  6410. }
  6411. }
  6412. declare module "babylonjs/States/index" {
  6413. export * from "babylonjs/States/alphaCullingState";
  6414. export * from "babylonjs/States/depthCullingState";
  6415. export * from "babylonjs/States/stencilState";
  6416. }
  6417. declare module "babylonjs/Instrumentation/timeToken" {
  6418. import { Nullable } from "babylonjs/types";
  6419. /**
  6420. * @hidden
  6421. **/
  6422. export class _TimeToken {
  6423. _startTimeQuery: Nullable<WebGLQuery>;
  6424. _endTimeQuery: Nullable<WebGLQuery>;
  6425. _timeElapsedQuery: Nullable<WebGLQuery>;
  6426. _timeElapsedQueryEnded: boolean;
  6427. }
  6428. }
  6429. declare module "babylonjs/Materials/Textures/internalTexture" {
  6430. import { Observable } from "babylonjs/Misc/observable";
  6431. import { Nullable, int } from "babylonjs/types";
  6432. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6433. import { Engine } from "babylonjs/Engines/engine";
  6434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6435. /**
  6436. * Class used to store data associated with WebGL texture data for the engine
  6437. * This class should not be used directly
  6438. */
  6439. export class InternalTexture {
  6440. /** @hidden */
  6441. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6442. /**
  6443. * The source of the texture data is unknown
  6444. */
  6445. static DATASOURCE_UNKNOWN: number;
  6446. /**
  6447. * Texture data comes from an URL
  6448. */
  6449. static DATASOURCE_URL: number;
  6450. /**
  6451. * Texture data is only used for temporary storage
  6452. */
  6453. static DATASOURCE_TEMP: number;
  6454. /**
  6455. * Texture data comes from raw data (ArrayBuffer)
  6456. */
  6457. static DATASOURCE_RAW: number;
  6458. /**
  6459. * Texture content is dynamic (video or dynamic texture)
  6460. */
  6461. static DATASOURCE_DYNAMIC: number;
  6462. /**
  6463. * Texture content is generated by rendering to it
  6464. */
  6465. static DATASOURCE_RENDERTARGET: number;
  6466. /**
  6467. * Texture content is part of a multi render target process
  6468. */
  6469. static DATASOURCE_MULTIRENDERTARGET: number;
  6470. /**
  6471. * Texture data comes from a cube data file
  6472. */
  6473. static DATASOURCE_CUBE: number;
  6474. /**
  6475. * Texture data comes from a raw cube data
  6476. */
  6477. static DATASOURCE_CUBERAW: number;
  6478. /**
  6479. * Texture data come from a prefiltered cube data file
  6480. */
  6481. static DATASOURCE_CUBEPREFILTERED: number;
  6482. /**
  6483. * Texture content is raw 3D data
  6484. */
  6485. static DATASOURCE_RAW3D: number;
  6486. /**
  6487. * Texture content is a depth texture
  6488. */
  6489. static DATASOURCE_DEPTHTEXTURE: number;
  6490. /**
  6491. * Texture data comes from a raw cube data encoded with RGBD
  6492. */
  6493. static DATASOURCE_CUBERAW_RGBD: number;
  6494. /**
  6495. * Defines if the texture is ready
  6496. */
  6497. isReady: boolean;
  6498. /**
  6499. * Defines if the texture is a cube texture
  6500. */
  6501. isCube: boolean;
  6502. /**
  6503. * Defines if the texture contains 3D data
  6504. */
  6505. is3D: boolean;
  6506. /**
  6507. * Defines if the texture contains multiview data
  6508. */
  6509. isMultiview: boolean;
  6510. /**
  6511. * Gets the URL used to load this texture
  6512. */
  6513. url: string;
  6514. /**
  6515. * Gets the sampling mode of the texture
  6516. */
  6517. samplingMode: number;
  6518. /**
  6519. * Gets a boolean indicating if the texture needs mipmaps generation
  6520. */
  6521. generateMipMaps: boolean;
  6522. /**
  6523. * Gets the number of samples used by the texture (WebGL2+ only)
  6524. */
  6525. samples: number;
  6526. /**
  6527. * Gets the type of the texture (int, float...)
  6528. */
  6529. type: number;
  6530. /**
  6531. * Gets the format of the texture (RGB, RGBA...)
  6532. */
  6533. format: number;
  6534. /**
  6535. * Observable called when the texture is loaded
  6536. */
  6537. onLoadedObservable: Observable<InternalTexture>;
  6538. /**
  6539. * Gets the width of the texture
  6540. */
  6541. width: number;
  6542. /**
  6543. * Gets the height of the texture
  6544. */
  6545. height: number;
  6546. /**
  6547. * Gets the depth of the texture
  6548. */
  6549. depth: number;
  6550. /**
  6551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6552. */
  6553. baseWidth: number;
  6554. /**
  6555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseHeight: number;
  6558. /**
  6559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseDepth: number;
  6562. /**
  6563. * Gets a boolean indicating if the texture is inverted on Y axis
  6564. */
  6565. invertY: boolean;
  6566. /** @hidden */
  6567. _invertVScale: boolean;
  6568. /** @hidden */
  6569. _associatedChannel: number;
  6570. /** @hidden */
  6571. _dataSource: number;
  6572. /** @hidden */
  6573. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6574. /** @hidden */
  6575. _bufferView: Nullable<ArrayBufferView>;
  6576. /** @hidden */
  6577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6578. /** @hidden */
  6579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6580. /** @hidden */
  6581. _size: number;
  6582. /** @hidden */
  6583. _extension: string;
  6584. /** @hidden */
  6585. _files: Nullable<string[]>;
  6586. /** @hidden */
  6587. _workingCanvas: Nullable<HTMLCanvasElement>;
  6588. /** @hidden */
  6589. _workingContext: Nullable<CanvasRenderingContext2D>;
  6590. /** @hidden */
  6591. _framebuffer: Nullable<WebGLFramebuffer>;
  6592. /** @hidden */
  6593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6594. /** @hidden */
  6595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _attachments: Nullable<number[]>;
  6600. /** @hidden */
  6601. _cachedCoordinatesMode: Nullable<number>;
  6602. /** @hidden */
  6603. _cachedWrapU: Nullable<number>;
  6604. /** @hidden */
  6605. _cachedWrapV: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapR: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6610. /** @hidden */
  6611. _isDisabled: boolean;
  6612. /** @hidden */
  6613. _compression: Nullable<string>;
  6614. /** @hidden */
  6615. _generateStencilBuffer: boolean;
  6616. /** @hidden */
  6617. _generateDepthBuffer: boolean;
  6618. /** @hidden */
  6619. _comparisonFunction: number;
  6620. /** @hidden */
  6621. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6622. /** @hidden */
  6623. _lodGenerationScale: number;
  6624. /** @hidden */
  6625. _lodGenerationOffset: number;
  6626. /** @hidden */
  6627. _colorTextureArray: Nullable<WebGLTexture>;
  6628. /** @hidden */
  6629. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6630. /** @hidden */
  6631. _lodTextureHigh: Nullable<BaseTexture>;
  6632. /** @hidden */
  6633. _lodTextureMid: Nullable<BaseTexture>;
  6634. /** @hidden */
  6635. _lodTextureLow: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _isRGBD: boolean;
  6638. /** @hidden */
  6639. _linearSpecularLOD: boolean;
  6640. /** @hidden */
  6641. _irradianceTexture: Nullable<BaseTexture>;
  6642. /** @hidden */
  6643. _webGLTexture: Nullable<WebGLTexture>;
  6644. /** @hidden */
  6645. _references: number;
  6646. private _engine;
  6647. /**
  6648. * Gets the Engine the texture belongs to.
  6649. * @returns The babylon engine
  6650. */
  6651. getEngine(): Engine;
  6652. /**
  6653. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6654. */
  6655. readonly dataSource: number;
  6656. /**
  6657. * Creates a new InternalTexture
  6658. * @param engine defines the engine to use
  6659. * @param dataSource defines the type of data that will be used
  6660. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6661. */
  6662. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6663. /**
  6664. * Increments the number of references (ie. the number of Texture that point to it)
  6665. */
  6666. incrementReferences(): void;
  6667. /**
  6668. * Change the size of the texture (not the size of the content)
  6669. * @param width defines the new width
  6670. * @param height defines the new height
  6671. * @param depth defines the new depth (1 by default)
  6672. */
  6673. updateSize(width: int, height: int, depth?: int): void;
  6674. /** @hidden */
  6675. _rebuild(): void;
  6676. /** @hidden */
  6677. _swapAndDie(target: InternalTexture): void;
  6678. /**
  6679. * Dispose the current allocated resources
  6680. */
  6681. dispose(): void;
  6682. }
  6683. }
  6684. declare module "babylonjs/Animations/easing" {
  6685. /**
  6686. * This represents the main contract an easing function should follow.
  6687. * Easing functions are used throughout the animation system.
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export interface IEasingFunction {
  6691. /**
  6692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6693. * of the easing function.
  6694. * The link below provides some of the most common examples of easing functions.
  6695. * @see https://easings.net/
  6696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6697. * @returns the corresponding value on the curve defined by the easing function
  6698. */
  6699. ease(gradient: number): number;
  6700. }
  6701. /**
  6702. * Base class used for every default easing function.
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class EasingFunction implements IEasingFunction {
  6706. /**
  6707. * Interpolation follows the mathematical formula associated with the easing function.
  6708. */
  6709. static readonly EASINGMODE_EASEIN: number;
  6710. /**
  6711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEOUT: number;
  6714. /**
  6715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6716. */
  6717. static readonly EASINGMODE_EASEINOUT: number;
  6718. private _easingMode;
  6719. /**
  6720. * Sets the easing mode of the current function.
  6721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6722. */
  6723. setEasingMode(easingMode: number): void;
  6724. /**
  6725. * Gets the current easing mode.
  6726. * @returns the easing mode
  6727. */
  6728. getEasingMode(): number;
  6729. /**
  6730. * @hidden
  6731. */
  6732. easeInCore(gradient: number): number;
  6733. /**
  6734. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6735. * of the easing function.
  6736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6737. * @returns the corresponding value on the curve defined by the easing function
  6738. */
  6739. ease(gradient: number): number;
  6740. }
  6741. /**
  6742. * Easing function with a circle shape (see link below).
  6743. * @see https://easings.net/#easeInCirc
  6744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6745. */
  6746. export class CircleEase extends EasingFunction implements IEasingFunction {
  6747. /** @hidden */
  6748. easeInCore(gradient: number): number;
  6749. }
  6750. /**
  6751. * Easing function with a ease back shape (see link below).
  6752. * @see https://easings.net/#easeInBack
  6753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6754. */
  6755. export class BackEase extends EasingFunction implements IEasingFunction {
  6756. /** Defines the amplitude of the function */
  6757. amplitude: number;
  6758. /**
  6759. * Instantiates a back ease easing
  6760. * @see https://easings.net/#easeInBack
  6761. * @param amplitude Defines the amplitude of the function
  6762. */
  6763. constructor(
  6764. /** Defines the amplitude of the function */
  6765. amplitude?: number);
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with a bouncing shape (see link below).
  6771. * @see https://easings.net/#easeInBounce
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class BounceEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of bounces */
  6776. bounces: number;
  6777. /** Defines the amplitude of the bounce */
  6778. bounciness: number;
  6779. /**
  6780. * Instantiates a bounce easing
  6781. * @see https://easings.net/#easeInBounce
  6782. * @param bounces Defines the number of bounces
  6783. * @param bounciness Defines the amplitude of the bounce
  6784. */
  6785. constructor(
  6786. /** Defines the number of bounces */
  6787. bounces?: number,
  6788. /** Defines the amplitude of the bounce */
  6789. bounciness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with a power of 3 shape (see link below).
  6795. * @see https://easings.net/#easeInCubic
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class CubicEase extends EasingFunction implements IEasingFunction {
  6799. /** @hidden */
  6800. easeInCore(gradient: number): number;
  6801. }
  6802. /**
  6803. * Easing function with an elastic shape (see link below).
  6804. * @see https://easings.net/#easeInElastic
  6805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6806. */
  6807. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6808. /** Defines the number of oscillations*/
  6809. oscillations: number;
  6810. /** Defines the amplitude of the oscillations*/
  6811. springiness: number;
  6812. /**
  6813. * Instantiates an elastic easing function
  6814. * @see https://easings.net/#easeInElastic
  6815. * @param oscillations Defines the number of oscillations
  6816. * @param springiness Defines the amplitude of the oscillations
  6817. */
  6818. constructor(
  6819. /** Defines the number of oscillations*/
  6820. oscillations?: number,
  6821. /** Defines the amplitude of the oscillations*/
  6822. springiness?: number);
  6823. /** @hidden */
  6824. easeInCore(gradient: number): number;
  6825. }
  6826. /**
  6827. * Easing function with an exponential shape (see link below).
  6828. * @see https://easings.net/#easeInExpo
  6829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6830. */
  6831. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6832. /** Defines the exponent of the function */
  6833. exponent: number;
  6834. /**
  6835. * Instantiates an exponential easing function
  6836. * @see https://easings.net/#easeInExpo
  6837. * @param exponent Defines the exponent of the function
  6838. */
  6839. constructor(
  6840. /** Defines the exponent of the function */
  6841. exponent?: number);
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power shape (see link below).
  6847. * @see https://easings.net/#easeInQuad
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class PowerEase extends EasingFunction implements IEasingFunction {
  6851. /** Defines the power of the function */
  6852. power: number;
  6853. /**
  6854. * Instantiates an power base easing function
  6855. * @see https://easings.net/#easeInQuad
  6856. * @param power Defines the power of the function
  6857. */
  6858. constructor(
  6859. /** Defines the power of the function */
  6860. power?: number);
  6861. /** @hidden */
  6862. easeInCore(gradient: number): number;
  6863. }
  6864. /**
  6865. * Easing function with a power of 2 shape (see link below).
  6866. * @see https://easings.net/#easeInQuad
  6867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6868. */
  6869. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6870. /** @hidden */
  6871. easeInCore(gradient: number): number;
  6872. }
  6873. /**
  6874. * Easing function with a power of 4 shape (see link below).
  6875. * @see https://easings.net/#easeInQuart
  6876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6877. */
  6878. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6879. /** @hidden */
  6880. easeInCore(gradient: number): number;
  6881. }
  6882. /**
  6883. * Easing function with a power of 5 shape (see link below).
  6884. * @see https://easings.net/#easeInQuint
  6885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6886. */
  6887. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6888. /** @hidden */
  6889. easeInCore(gradient: number): number;
  6890. }
  6891. /**
  6892. * Easing function with a sin shape (see link below).
  6893. * @see https://easings.net/#easeInSine
  6894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6895. */
  6896. export class SineEase extends EasingFunction implements IEasingFunction {
  6897. /** @hidden */
  6898. easeInCore(gradient: number): number;
  6899. }
  6900. /**
  6901. * Easing function with a bezier shape (see link below).
  6902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6904. */
  6905. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6906. /** Defines the x component of the start tangent in the bezier curve */
  6907. x1: number;
  6908. /** Defines the y component of the start tangent in the bezier curve */
  6909. y1: number;
  6910. /** Defines the x component of the end tangent in the bezier curve */
  6911. x2: number;
  6912. /** Defines the y component of the end tangent in the bezier curve */
  6913. y2: number;
  6914. /**
  6915. * Instantiates a bezier function
  6916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6917. * @param x1 Defines the x component of the start tangent in the bezier curve
  6918. * @param y1 Defines the y component of the start tangent in the bezier curve
  6919. * @param x2 Defines the x component of the end tangent in the bezier curve
  6920. * @param y2 Defines the y component of the end tangent in the bezier curve
  6921. */
  6922. constructor(
  6923. /** Defines the x component of the start tangent in the bezier curve */
  6924. x1?: number,
  6925. /** Defines the y component of the start tangent in the bezier curve */
  6926. y1?: number,
  6927. /** Defines the x component of the end tangent in the bezier curve */
  6928. x2?: number,
  6929. /** Defines the y component of the end tangent in the bezier curve */
  6930. y2?: number);
  6931. /** @hidden */
  6932. easeInCore(gradient: number): number;
  6933. }
  6934. }
  6935. declare module "babylonjs/Animations/animationKey" {
  6936. /**
  6937. * Defines an interface which represents an animation key frame
  6938. */
  6939. export interface IAnimationKey {
  6940. /**
  6941. * Frame of the key frame
  6942. */
  6943. frame: number;
  6944. /**
  6945. * Value at the specifies key frame
  6946. */
  6947. value: any;
  6948. /**
  6949. * The input tangent for the cubic hermite spline
  6950. */
  6951. inTangent?: any;
  6952. /**
  6953. * The output tangent for the cubic hermite spline
  6954. */
  6955. outTangent?: any;
  6956. /**
  6957. * The animation interpolation type
  6958. */
  6959. interpolation?: AnimationKeyInterpolation;
  6960. }
  6961. /**
  6962. * Enum for the animation key frame interpolation type
  6963. */
  6964. export enum AnimationKeyInterpolation {
  6965. /**
  6966. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6967. */
  6968. STEP = 1
  6969. }
  6970. }
  6971. declare module "babylonjs/Animations/animationRange" {
  6972. /**
  6973. * Represents the range of an animation
  6974. */
  6975. export class AnimationRange {
  6976. /**The name of the animation range**/
  6977. name: string;
  6978. /**The starting frame of the animation */
  6979. from: number;
  6980. /**The ending frame of the animation*/
  6981. to: number;
  6982. /**
  6983. * Initializes the range of an animation
  6984. * @param name The name of the animation range
  6985. * @param from The starting frame of the animation
  6986. * @param to The ending frame of the animation
  6987. */
  6988. constructor(
  6989. /**The name of the animation range**/
  6990. name: string,
  6991. /**The starting frame of the animation */
  6992. from: number,
  6993. /**The ending frame of the animation*/
  6994. to: number);
  6995. /**
  6996. * Makes a copy of the animation range
  6997. * @returns A copy of the animation range
  6998. */
  6999. clone(): AnimationRange;
  7000. }
  7001. }
  7002. declare module "babylonjs/Animations/animationEvent" {
  7003. /**
  7004. * Composed of a frame, and an action function
  7005. */
  7006. export class AnimationEvent {
  7007. /** The frame for which the event is triggered **/
  7008. frame: number;
  7009. /** The event to perform when triggered **/
  7010. action: (currentFrame: number) => void;
  7011. /** Specifies if the event should be triggered only once**/
  7012. onlyOnce?: boolean | undefined;
  7013. /**
  7014. * Specifies if the animation event is done
  7015. */
  7016. isDone: boolean;
  7017. /**
  7018. * Initializes the animation event
  7019. * @param frame The frame for which the event is triggered
  7020. * @param action The event to perform when triggered
  7021. * @param onlyOnce Specifies if the event should be triggered only once
  7022. */
  7023. constructor(
  7024. /** The frame for which the event is triggered **/
  7025. frame: number,
  7026. /** The event to perform when triggered **/
  7027. action: (currentFrame: number) => void,
  7028. /** Specifies if the event should be triggered only once**/
  7029. onlyOnce?: boolean | undefined);
  7030. /** @hidden */
  7031. _clone(): AnimationEvent;
  7032. }
  7033. }
  7034. declare module "babylonjs/Behaviors/behavior" {
  7035. import { Nullable } from "babylonjs/types";
  7036. /**
  7037. * Interface used to define a behavior
  7038. */
  7039. export interface Behavior<T> {
  7040. /** gets or sets behavior's name */
  7041. name: string;
  7042. /**
  7043. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7044. */
  7045. init(): void;
  7046. /**
  7047. * Called when the behavior is attached to a target
  7048. * @param target defines the target where the behavior is attached to
  7049. */
  7050. attach(target: T): void;
  7051. /**
  7052. * Called when the behavior is detached from its target
  7053. */
  7054. detach(): void;
  7055. }
  7056. /**
  7057. * Interface implemented by classes supporting behaviors
  7058. */
  7059. export interface IBehaviorAware<T> {
  7060. /**
  7061. * Attach a behavior
  7062. * @param behavior defines the behavior to attach
  7063. * @returns the current host
  7064. */
  7065. addBehavior(behavior: Behavior<T>): T;
  7066. /**
  7067. * Remove a behavior from the current object
  7068. * @param behavior defines the behavior to detach
  7069. * @returns the current host
  7070. */
  7071. removeBehavior(behavior: Behavior<T>): T;
  7072. /**
  7073. * Gets a behavior using its name to search
  7074. * @param name defines the name to search
  7075. * @returns the behavior or null if not found
  7076. */
  7077. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7078. }
  7079. }
  7080. declare module "babylonjs/Collisions/intersectionInfo" {
  7081. import { Nullable } from "babylonjs/types";
  7082. /**
  7083. * @hidden
  7084. */
  7085. export class IntersectionInfo {
  7086. bu: Nullable<number>;
  7087. bv: Nullable<number>;
  7088. distance: number;
  7089. faceId: number;
  7090. subMeshId: number;
  7091. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7092. }
  7093. }
  7094. declare module "babylonjs/Culling/boundingSphere" {
  7095. import { DeepImmutable } from "babylonjs/types";
  7096. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7097. /**
  7098. * Class used to store bounding sphere information
  7099. */
  7100. export class BoundingSphere {
  7101. /**
  7102. * Gets the center of the bounding sphere in local space
  7103. */
  7104. readonly center: Vector3;
  7105. /**
  7106. * Radius of the bounding sphere in local space
  7107. */
  7108. radius: number;
  7109. /**
  7110. * Gets the center of the bounding sphere in world space
  7111. */
  7112. readonly centerWorld: Vector3;
  7113. /**
  7114. * Radius of the bounding sphere in world space
  7115. */
  7116. radiusWorld: number;
  7117. /**
  7118. * Gets the minimum vector in local space
  7119. */
  7120. readonly minimum: Vector3;
  7121. /**
  7122. * Gets the maximum vector in local space
  7123. */
  7124. readonly maximum: Vector3;
  7125. private _worldMatrix;
  7126. private static readonly TmpVector3;
  7127. /**
  7128. * Creates a new bounding sphere
  7129. * @param min defines the minimum vector (in local space)
  7130. * @param max defines the maximum vector (in local space)
  7131. * @param worldMatrix defines the new world matrix
  7132. */
  7133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7134. /**
  7135. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7136. * @param min defines the new minimum vector (in local space)
  7137. * @param max defines the new maximum vector (in local space)
  7138. * @param worldMatrix defines the new world matrix
  7139. */
  7140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Scale the current bounding sphere by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding box
  7145. */
  7146. scale(factor: number): BoundingSphere;
  7147. /**
  7148. * Gets the world matrix of the bounding box
  7149. * @returns a matrix
  7150. */
  7151. getWorldMatrix(): DeepImmutable<Matrix>;
  7152. /** @hidden */
  7153. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding sphere is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding sphere center is in between the frustum planes.
  7162. * Used for optimistic fast inclusion.
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @returns true if the sphere center is in between the frustum planes
  7165. */
  7166. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a point is inside the bounding sphere
  7169. * @param point defines the point to test
  7170. * @returns true if the point is inside the bounding sphere
  7171. */
  7172. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7173. /**
  7174. * Checks if two sphere intersct
  7175. * @param sphere0 sphere 0
  7176. * @param sphere1 sphere 1
  7177. * @returns true if the speres intersect
  7178. */
  7179. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7180. }
  7181. }
  7182. declare module "babylonjs/Culling/boundingBox" {
  7183. import { DeepImmutable } from "babylonjs/types";
  7184. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7187. /**
  7188. * Class used to store bounding box information
  7189. */
  7190. export class BoundingBox implements ICullable {
  7191. /**
  7192. * Gets the 8 vectors representing the bounding box in local space
  7193. */
  7194. readonly vectors: Vector3[];
  7195. /**
  7196. * Gets the center of the bounding box in local space
  7197. */
  7198. readonly center: Vector3;
  7199. /**
  7200. * Gets the center of the bounding box in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Gets the extend size in local space
  7205. */
  7206. readonly extendSize: Vector3;
  7207. /**
  7208. * Gets the extend size in world space
  7209. */
  7210. readonly extendSizeWorld: Vector3;
  7211. /**
  7212. * Gets the OBB (object bounding box) directions
  7213. */
  7214. readonly directions: Vector3[];
  7215. /**
  7216. * Gets the 8 vectors representing the bounding box in world space
  7217. */
  7218. readonly vectorsWorld: Vector3[];
  7219. /**
  7220. * Gets the minimum vector in world space
  7221. */
  7222. readonly minimumWorld: Vector3;
  7223. /**
  7224. * Gets the maximum vector in world space
  7225. */
  7226. readonly maximumWorld: Vector3;
  7227. /**
  7228. * Gets the minimum vector in local space
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * Gets the maximum vector in local space
  7233. */
  7234. readonly maximum: Vector3;
  7235. private _worldMatrix;
  7236. private static readonly TmpVector3;
  7237. /**
  7238. * @hidden
  7239. */
  7240. _tag: number;
  7241. /**
  7242. * Creates a new bounding box
  7243. * @param min defines the minimum vector (in local space)
  7244. * @param max defines the maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7248. /**
  7249. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7250. * @param min defines the new minimum vector (in local space)
  7251. * @param max defines the new maximum vector (in local space)
  7252. * @param worldMatrix defines the new world matrix
  7253. */
  7254. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Scale the current bounding box by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding box
  7259. */
  7260. scale(factor: number): BoundingBox;
  7261. /**
  7262. * Gets the world matrix of the bounding box
  7263. * @returns a matrix
  7264. */
  7265. getWorldMatrix(): DeepImmutable<Matrix>;
  7266. /** @hidden */
  7267. _update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Tests if the bounding box is intersecting the frustum planes
  7270. * @param frustumPlanes defines the frustum planes to test
  7271. * @returns true if there is an intersection
  7272. */
  7273. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /**
  7275. * Tests if the bounding box is entirely inside the frustum planes
  7276. * @param frustumPlanes defines the frustum planes to test
  7277. * @returns true if there is an inclusion
  7278. */
  7279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7280. /**
  7281. * Tests if a point is inside the bounding box
  7282. * @param point defines the point to test
  7283. * @returns true if the point is inside the bounding box
  7284. */
  7285. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7286. /**
  7287. * Tests if the bounding box intersects with a bounding sphere
  7288. * @param sphere defines the sphere to test
  7289. * @returns true if there is an intersection
  7290. */
  7291. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7292. /**
  7293. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7294. * @param min defines the min vector to use
  7295. * @param max defines the max vector to use
  7296. * @returns true if there is an intersection
  7297. */
  7298. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7299. /**
  7300. * Tests if two bounding boxes are intersections
  7301. * @param box0 defines the first box to test
  7302. * @param box1 defines the second box to test
  7303. * @returns true if there is an intersection
  7304. */
  7305. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7306. /**
  7307. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7308. * @param minPoint defines the minimum vector of the bounding box
  7309. * @param maxPoint defines the maximum vector of the bounding box
  7310. * @param sphereCenter defines the sphere center
  7311. * @param sphereRadius defines the sphere radius
  7312. * @returns true if there is an intersection
  7313. */
  7314. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7315. /**
  7316. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7317. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7318. * @param frustumPlanes defines the frustum planes to test
  7319. * @return true if there is an inclusion
  7320. */
  7321. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /**
  7323. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7324. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7325. * @param frustumPlanes defines the frustum planes to test
  7326. * @return true if there is an intersection
  7327. */
  7328. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7329. }
  7330. }
  7331. declare module "babylonjs/Collisions/collider" {
  7332. import { Nullable, IndicesArray } from "babylonjs/types";
  7333. import { Vector3, Plane } from "babylonjs/Maths/math";
  7334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7335. /** @hidden */
  7336. export class Collider {
  7337. /** Define if a collision was found */
  7338. collisionFound: boolean;
  7339. /**
  7340. * Define last intersection point in local space
  7341. */
  7342. intersectionPoint: Vector3;
  7343. /**
  7344. * Define last collided mesh
  7345. */
  7346. collidedMesh: Nullable<AbstractMesh>;
  7347. private _collisionPoint;
  7348. private _planeIntersectionPoint;
  7349. private _tempVector;
  7350. private _tempVector2;
  7351. private _tempVector3;
  7352. private _tempVector4;
  7353. private _edge;
  7354. private _baseToVertex;
  7355. private _destinationPoint;
  7356. private _slidePlaneNormal;
  7357. private _displacementVector;
  7358. /** @hidden */
  7359. _radius: Vector3;
  7360. /** @hidden */
  7361. _retry: number;
  7362. private _velocity;
  7363. private _basePoint;
  7364. private _epsilon;
  7365. /** @hidden */
  7366. _velocityWorldLength: number;
  7367. /** @hidden */
  7368. _basePointWorld: Vector3;
  7369. private _velocityWorld;
  7370. private _normalizedVelocity;
  7371. /** @hidden */
  7372. _initialVelocity: Vector3;
  7373. /** @hidden */
  7374. _initialPosition: Vector3;
  7375. private _nearestDistance;
  7376. private _collisionMask;
  7377. collisionMask: number;
  7378. /**
  7379. * Gets the plane normal used to compute the sliding response (in local space)
  7380. */
  7381. readonly slidePlaneNormal: Vector3;
  7382. /** @hidden */
  7383. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7384. /** @hidden */
  7385. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7386. /** @hidden */
  7387. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7388. /** @hidden */
  7389. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7390. /** @hidden */
  7391. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7392. /** @hidden */
  7393. _getResponse(pos: Vector3, vel: Vector3): void;
  7394. }
  7395. }
  7396. declare module "babylonjs/Culling/boundingInfo" {
  7397. import { DeepImmutable } from "babylonjs/types";
  7398. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7399. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7400. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7401. import { Collider } from "babylonjs/Collisions/collider";
  7402. /**
  7403. * Interface for cullable objects
  7404. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7405. */
  7406. export interface ICullable {
  7407. /**
  7408. * Checks if the object or part of the object is in the frustum
  7409. * @param frustumPlanes Camera near/planes
  7410. * @returns true if the object is in frustum otherwise false
  7411. */
  7412. isInFrustum(frustumPlanes: Plane[]): boolean;
  7413. /**
  7414. * Checks if a cullable object (mesh...) is in the camera frustum
  7415. * Unlike isInFrustum this cheks the full bounding box
  7416. * @param frustumPlanes Camera near/planes
  7417. * @returns true if the object is in frustum otherwise false
  7418. */
  7419. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7420. }
  7421. /**
  7422. * Info for a bounding data of a mesh
  7423. */
  7424. export class BoundingInfo implements ICullable {
  7425. /**
  7426. * Bounding box for the mesh
  7427. */
  7428. readonly boundingBox: BoundingBox;
  7429. /**
  7430. * Bounding sphere for the mesh
  7431. */
  7432. readonly boundingSphere: BoundingSphere;
  7433. private _isLocked;
  7434. private static readonly TmpVector3;
  7435. /**
  7436. * Constructs bounding info
  7437. * @param minimum min vector of the bounding box/sphere
  7438. * @param maximum max vector of the bounding box/sphere
  7439. * @param worldMatrix defines the new world matrix
  7440. */
  7441. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7442. /**
  7443. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7444. * @param min defines the new minimum vector (in local space)
  7445. * @param max defines the new maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7449. /**
  7450. * min vector of the bounding box/sphere
  7451. */
  7452. readonly minimum: Vector3;
  7453. /**
  7454. * max vector of the bounding box/sphere
  7455. */
  7456. readonly maximum: Vector3;
  7457. /**
  7458. * If the info is locked and won't be updated to avoid perf overhead
  7459. */
  7460. isLocked: boolean;
  7461. /**
  7462. * Updates the bounding sphere and box
  7463. * @param world world matrix to be used to update
  7464. */
  7465. update(world: DeepImmutable<Matrix>): void;
  7466. /**
  7467. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7468. * @param center New center of the bounding info
  7469. * @param extend New extend of the bounding info
  7470. * @returns the current bounding info
  7471. */
  7472. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7473. /**
  7474. * Scale the current bounding info by applying a scale factor
  7475. * @param factor defines the scale factor to apply
  7476. * @returns the current bounding info
  7477. */
  7478. scale(factor: number): BoundingInfo;
  7479. /**
  7480. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7481. * @param frustumPlanes defines the frustum to test
  7482. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7483. * @returns true if the bounding info is in the frustum planes
  7484. */
  7485. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7486. /**
  7487. * Gets the world distance between the min and max points of the bounding box
  7488. */
  7489. readonly diagonalLength: number;
  7490. /**
  7491. * Checks if a cullable object (mesh...) is in the camera frustum
  7492. * Unlike isInFrustum this cheks the full bounding box
  7493. * @param frustumPlanes Camera near/planes
  7494. * @returns true if the object is in frustum otherwise false
  7495. */
  7496. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7497. /** @hidden */
  7498. _checkCollision(collider: Collider): boolean;
  7499. /**
  7500. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7501. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7502. * @param point the point to check intersection with
  7503. * @returns if the point intersects
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7508. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7509. * @param boundingInfo the bounding info to check intersection with
  7510. * @param precise if the intersection should be done using OBB
  7511. * @returns if the bounding info intersects
  7512. */
  7513. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/smartArray" {
  7517. /**
  7518. * Defines an array and its length.
  7519. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7520. */
  7521. export interface ISmartArrayLike<T> {
  7522. /**
  7523. * The data of the array.
  7524. */
  7525. data: Array<T>;
  7526. /**
  7527. * The active length of the array.
  7528. */
  7529. length: number;
  7530. }
  7531. /**
  7532. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7533. */
  7534. export class SmartArray<T> implements ISmartArrayLike<T> {
  7535. /**
  7536. * The full set of data from the array.
  7537. */
  7538. data: Array<T>;
  7539. /**
  7540. * The active length of the array.
  7541. */
  7542. length: number;
  7543. protected _id: number;
  7544. /**
  7545. * Instantiates a Smart Array.
  7546. * @param capacity defines the default capacity of the array.
  7547. */
  7548. constructor(capacity: number);
  7549. /**
  7550. * Pushes a value at the end of the active data.
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Iterates over the active data and apply the lambda to them.
  7556. * @param func defines the action to apply on each value.
  7557. */
  7558. forEach(func: (content: T) => void): void;
  7559. /**
  7560. * Sorts the full sets of data.
  7561. * @param compareFn defines the comparison function to apply.
  7562. */
  7563. sort(compareFn: (a: T, b: T) => number): void;
  7564. /**
  7565. * Resets the active data to an empty array.
  7566. */
  7567. reset(): void;
  7568. /**
  7569. * Releases all the data from the array as well as the array.
  7570. */
  7571. dispose(): void;
  7572. /**
  7573. * Concats the active data with a given array.
  7574. * @param array defines the data to concatenate with.
  7575. */
  7576. concat(array: any): void;
  7577. /**
  7578. * Returns the position of a value in the active data.
  7579. * @param value defines the value to find the index for
  7580. * @returns the index if found in the active data otherwise -1
  7581. */
  7582. indexOf(value: T): number;
  7583. /**
  7584. * Returns whether an element is part of the active data.
  7585. * @param value defines the value to look for
  7586. * @returns true if found in the active data otherwise false
  7587. */
  7588. contains(value: T): boolean;
  7589. private static _GlobalId;
  7590. }
  7591. /**
  7592. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7593. * The data in this array can only be present once
  7594. */
  7595. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7596. private _duplicateId;
  7597. /**
  7598. * Pushes a value at the end of the active data.
  7599. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7600. * @param value defines the object to push in the array.
  7601. */
  7602. push(value: T): void;
  7603. /**
  7604. * Pushes a value at the end of the active data.
  7605. * If the data is already present, it won t be added again
  7606. * @param value defines the object to push in the array.
  7607. * @returns true if added false if it was already present
  7608. */
  7609. pushNoDuplicate(value: T): boolean;
  7610. /**
  7611. * Resets the active data to an empty array.
  7612. */
  7613. reset(): void;
  7614. /**
  7615. * Concats the active data with a given array.
  7616. * This ensures no dupplicate will be present in the result.
  7617. * @param array defines the data to concatenate with.
  7618. */
  7619. concatWithNoDuplicate(array: any): void;
  7620. }
  7621. }
  7622. declare module "babylonjs/Misc/iInspectable" {
  7623. /**
  7624. * Enum that determines the text-wrapping mode to use.
  7625. */
  7626. export enum InspectableType {
  7627. /**
  7628. * Checkbox for booleans
  7629. */
  7630. Checkbox = 0,
  7631. /**
  7632. * Sliders for numbers
  7633. */
  7634. Slider = 1,
  7635. /**
  7636. * Vector3
  7637. */
  7638. Vector3 = 2,
  7639. /**
  7640. * Quaternions
  7641. */
  7642. Quaternion = 3,
  7643. /**
  7644. * Color3
  7645. */
  7646. Color3 = 4
  7647. }
  7648. /**
  7649. * Interface used to define custom inspectable properties.
  7650. * This interface is used by the inspector to display custom property grids
  7651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7652. */
  7653. export interface IInspectable {
  7654. /**
  7655. * Gets the label to display
  7656. */
  7657. label: string;
  7658. /**
  7659. * Gets the name of the property to edit
  7660. */
  7661. propertyName: string;
  7662. /**
  7663. * Gets the type of the editor to use
  7664. */
  7665. type: InspectableType;
  7666. /**
  7667. * Gets the minimum value of the property when using in "slider" mode
  7668. */
  7669. min?: number;
  7670. /**
  7671. * Gets the maximum value of the property when using in "slider" mode
  7672. */
  7673. max?: number;
  7674. /**
  7675. * Gets the setp to use when using in "slider" mode
  7676. */
  7677. step?: number;
  7678. }
  7679. }
  7680. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7681. import { Nullable } from "babylonjs/types";
  7682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7683. /**
  7684. * This represents the required contract to create a new type of texture loader.
  7685. */
  7686. export interface IInternalTextureLoader {
  7687. /**
  7688. * Defines wether the loader supports cascade loading the different faces.
  7689. */
  7690. supportCascades: boolean;
  7691. /**
  7692. * This returns if the loader support the current file information.
  7693. * @param extension defines the file extension of the file being loaded
  7694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7695. * @param fallback defines the fallback internal texture if any
  7696. * @param isBase64 defines whether the texture is encoded as a base64
  7697. * @param isBuffer defines whether the texture data are stored as a buffer
  7698. * @returns true if the loader can load the specified file
  7699. */
  7700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7701. /**
  7702. * Transform the url before loading if required.
  7703. * @param rootUrl the url of the texture
  7704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7705. * @returns the transformed texture
  7706. */
  7707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7708. /**
  7709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7710. * @param rootUrl the url of the texture
  7711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7712. * @returns the fallback texture
  7713. */
  7714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7715. /**
  7716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7717. * @param data contains the texture data
  7718. * @param texture defines the BabylonJS internal texture
  7719. * @param createPolynomials will be true if polynomials have been requested
  7720. * @param onLoad defines the callback to trigger once the texture is ready
  7721. * @param onError defines the callback to trigger in case of error
  7722. */
  7723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7724. /**
  7725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7726. * @param data contains the texture data
  7727. * @param texture defines the BabylonJS internal texture
  7728. * @param callback defines the method to call once ready to upload
  7729. */
  7730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7731. }
  7732. }
  7733. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7735. import { Nullable } from "babylonjs/types";
  7736. import { Scene } from "babylonjs/scene";
  7737. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7738. module "babylonjs/Engines/engine" {
  7739. interface Engine {
  7740. /**
  7741. * Creates a depth stencil cube texture.
  7742. * This is only available in WebGL 2.
  7743. * @param size The size of face edge in the cube texture.
  7744. * @param options The options defining the cube texture.
  7745. * @returns The cube texture
  7746. */
  7747. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7748. /**
  7749. * Creates a cube texture
  7750. * @param rootUrl defines the url where the files to load is located
  7751. * @param scene defines the current scene
  7752. * @param files defines the list of files to load (1 per face)
  7753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7754. * @param onLoad defines an optional callback raised when the texture is loaded
  7755. * @param onError defines an optional callback raised if there is an issue to load the texture
  7756. * @param format defines the format of the data
  7757. * @param forcedExtension defines the extension to use to pick the right loader
  7758. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7762. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7763. * @returns the cube texture as an InternalTexture
  7764. */
  7765. 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;
  7766. /**
  7767. * Creates a cube texture
  7768. * @param rootUrl defines the url where the files to load is located
  7769. * @param scene defines the current scene
  7770. * @param files defines the list of files to load (1 per face)
  7771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7772. * @param onLoad defines an optional callback raised when the texture is loaded
  7773. * @param onError defines an optional callback raised if there is an issue to load the texture
  7774. * @param format defines the format of the data
  7775. * @param forcedExtension defines the extension to use to pick the right loader
  7776. * @returns the cube texture as an InternalTexture
  7777. */
  7778. 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;
  7779. /**
  7780. * Creates a cube texture
  7781. * @param rootUrl defines the url where the files to load is located
  7782. * @param scene defines the current scene
  7783. * @param files defines the list of files to load (1 per face)
  7784. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7785. * @param onLoad defines an optional callback raised when the texture is loaded
  7786. * @param onError defines an optional callback raised if there is an issue to load the texture
  7787. * @param format defines the format of the data
  7788. * @param forcedExtension defines the extension to use to pick the right loader
  7789. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7790. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7791. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7792. * @returns the cube texture as an InternalTexture
  7793. */
  7794. 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;
  7795. /** @hidden */
  7796. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7797. /** @hidden */
  7798. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7799. /** @hidden */
  7800. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7803. }
  7804. }
  7805. }
  7806. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7807. import { Nullable } from "babylonjs/types";
  7808. import { Scene } from "babylonjs/scene";
  7809. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7811. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7812. /**
  7813. * Class for creating a cube texture
  7814. */
  7815. export class CubeTexture extends BaseTexture {
  7816. private _delayedOnLoad;
  7817. /**
  7818. * The url of the texture
  7819. */
  7820. url: string;
  7821. /**
  7822. * Gets or sets the center of the bounding box associated with the cube texture.
  7823. * It must define where the camera used to render the texture was set
  7824. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7825. */
  7826. boundingBoxPosition: Vector3;
  7827. private _boundingBoxSize;
  7828. /**
  7829. * Gets or sets the size of the bounding box associated with the cube texture
  7830. * When defined, the cubemap will switch to local mode
  7831. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7832. * @example https://www.babylonjs-playground.com/#RNASML
  7833. */
  7834. /**
  7835. * Returns the bounding box size
  7836. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7837. */
  7838. boundingBoxSize: Vector3;
  7839. protected _rotationY: number;
  7840. /**
  7841. * Sets texture matrix rotation angle around Y axis in radians.
  7842. */
  7843. /**
  7844. * Gets texture matrix rotation angle around Y axis radians.
  7845. */
  7846. rotationY: number;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. readonly noMipmap: boolean;
  7851. private _noMipmap;
  7852. private _files;
  7853. private _extensions;
  7854. private _textureMatrix;
  7855. private _format;
  7856. private _createPolynomials;
  7857. /** @hidden */
  7858. _prefiltered: boolean;
  7859. /**
  7860. * Creates a cube texture from an array of image urls
  7861. * @param files defines an array of image urls
  7862. * @param scene defines the hosting scene
  7863. * @param noMipmap specifies if mip maps are not used
  7864. * @returns a cube texture
  7865. */
  7866. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7867. /**
  7868. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7869. * @param url defines the url of the prefiltered texture
  7870. * @param scene defines the scene the texture is attached to
  7871. * @param forcedExtension defines the extension of the file if different from the url
  7872. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7873. * @return the prefiltered texture
  7874. */
  7875. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7876. /**
  7877. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7878. * as prefiltered data.
  7879. * @param rootUrl defines the url of the texture or the root name of the six images
  7880. * @param scene defines the scene the texture is attached to
  7881. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7882. * @param noMipmap defines if mipmaps should be created or not
  7883. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7884. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7885. * @param onError defines a callback triggered in case of error during load
  7886. * @param format defines the internal format to use for the texture once loaded
  7887. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7888. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7889. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7890. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7891. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7892. * @return the cube texture
  7893. */
  7894. 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);
  7895. /**
  7896. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7897. */
  7898. readonly isPrefiltered: boolean;
  7899. /**
  7900. * Get the current class name of the texture useful for serialization or dynamic coding.
  7901. * @returns "CubeTexture"
  7902. */
  7903. getClassName(): string;
  7904. /**
  7905. * Update the url (and optional buffer) of this texture if url was null during construction.
  7906. * @param url the url of the texture
  7907. * @param forcedExtension defines the extension to use
  7908. * @param onLoad callback called when the texture is loaded (defaults to null)
  7909. */
  7910. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7911. /**
  7912. * Delays loading of the cube texture
  7913. * @param forcedExtension defines the extension to use
  7914. */
  7915. delayLoad(forcedExtension?: string): void;
  7916. /**
  7917. * Returns the reflection texture matrix
  7918. * @returns the reflection texture matrix
  7919. */
  7920. getReflectionTextureMatrix(): Matrix;
  7921. /**
  7922. * Sets the reflection texture matrix
  7923. * @param value Reflection texture matrix
  7924. */
  7925. setReflectionTextureMatrix(value: Matrix): void;
  7926. /**
  7927. * Parses text to create a cube texture
  7928. * @param parsedTexture define the serialized text to read from
  7929. * @param scene defines the hosting scene
  7930. * @param rootUrl defines the root url of the cube texture
  7931. * @returns a cube texture
  7932. */
  7933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7934. /**
  7935. * Makes a clone, or deep copy, of the cube texture
  7936. * @returns a new cube texture
  7937. */
  7938. clone(): CubeTexture;
  7939. }
  7940. }
  7941. declare module "babylonjs/Shaders/postprocess.vertex" {
  7942. /** @hidden */
  7943. export var postprocessVertexShader: {
  7944. name: string;
  7945. shader: string;
  7946. };
  7947. }
  7948. declare module "babylonjs/Cameras/targetCamera" {
  7949. import { Nullable } from "babylonjs/types";
  7950. import { Camera } from "babylonjs/Cameras/camera";
  7951. import { Scene } from "babylonjs/scene";
  7952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7953. /**
  7954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7955. * This is the base of the follow, arc rotate cameras and Free camera
  7956. * @see http://doc.babylonjs.com/features/cameras
  7957. */
  7958. export class TargetCamera extends Camera {
  7959. private static _RigCamTransformMatrix;
  7960. private static _TargetTransformMatrix;
  7961. private static _TargetFocalPoint;
  7962. /**
  7963. * Define the current direction the camera is moving to
  7964. */
  7965. cameraDirection: Vector3;
  7966. /**
  7967. * Define the current rotation the camera is rotating to
  7968. */
  7969. cameraRotation: Vector2;
  7970. /**
  7971. * When set, the up vector of the camera will be updated by the rotation of the camera
  7972. */
  7973. updateUpVectorFromRotation: boolean;
  7974. private _tmpQuaternion;
  7975. /**
  7976. * Define the current rotation of the camera
  7977. */
  7978. rotation: Vector3;
  7979. /**
  7980. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7981. */
  7982. rotationQuaternion: Quaternion;
  7983. /**
  7984. * Define the current speed of the camera
  7985. */
  7986. speed: number;
  7987. /**
  7988. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7989. * around all axis.
  7990. */
  7991. noRotationConstraint: boolean;
  7992. /**
  7993. * Define the current target of the camera as an object or a position.
  7994. */
  7995. lockedTarget: any;
  7996. /** @hidden */
  7997. _currentTarget: Vector3;
  7998. /** @hidden */
  7999. _initialFocalDistance: number;
  8000. /** @hidden */
  8001. _viewMatrix: Matrix;
  8002. /** @hidden */
  8003. _camMatrix: Matrix;
  8004. /** @hidden */
  8005. _cameraTransformMatrix: Matrix;
  8006. /** @hidden */
  8007. _cameraRotationMatrix: Matrix;
  8008. /** @hidden */
  8009. _referencePoint: Vector3;
  8010. /** @hidden */
  8011. _transformedReferencePoint: Vector3;
  8012. protected _globalCurrentTarget: Vector3;
  8013. protected _globalCurrentUpVector: Vector3;
  8014. /** @hidden */
  8015. _reset: () => void;
  8016. private _defaultUp;
  8017. /**
  8018. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8019. * This is the base of the follow, arc rotate cameras and Free camera
  8020. * @see http://doc.babylonjs.com/features/cameras
  8021. * @param name Defines the name of the camera in the scene
  8022. * @param position Defines the start position of the camera in the scene
  8023. * @param scene Defines the scene the camera belongs to
  8024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8025. */
  8026. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8027. /**
  8028. * Gets the position in front of the camera at a given distance.
  8029. * @param distance The distance from the camera we want the position to be
  8030. * @returns the position
  8031. */
  8032. getFrontPosition(distance: number): Vector3;
  8033. /** @hidden */
  8034. _getLockedTargetPosition(): Nullable<Vector3>;
  8035. private _storedPosition;
  8036. private _storedRotation;
  8037. private _storedRotationQuaternion;
  8038. /**
  8039. * Store current camera state of the camera (fov, position, rotation, etc..)
  8040. * @returns the camera
  8041. */
  8042. storeState(): Camera;
  8043. /**
  8044. * Restored camera state. You must call storeState() first
  8045. * @returns whether it was successful or not
  8046. * @hidden
  8047. */
  8048. _restoreStateValues(): boolean;
  8049. /** @hidden */
  8050. _initCache(): void;
  8051. /** @hidden */
  8052. _updateCache(ignoreParentClass?: boolean): void;
  8053. /** @hidden */
  8054. _isSynchronizedViewMatrix(): boolean;
  8055. /** @hidden */
  8056. _computeLocalCameraSpeed(): number;
  8057. /**
  8058. * Defines the target the camera should look at.
  8059. * This will automatically adapt alpha beta and radius to fit within the new target.
  8060. * @param target Defines the new target as a Vector or a mesh
  8061. */
  8062. setTarget(target: Vector3): void;
  8063. /**
  8064. * Return the current target position of the camera. This value is expressed in local space.
  8065. * @returns the target position
  8066. */
  8067. getTarget(): Vector3;
  8068. /** @hidden */
  8069. _decideIfNeedsToMove(): boolean;
  8070. /** @hidden */
  8071. _updatePosition(): void;
  8072. /** @hidden */
  8073. _checkInputs(): void;
  8074. protected _updateCameraRotationMatrix(): void;
  8075. /**
  8076. * 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)
  8077. * @returns the current camera
  8078. */
  8079. private _rotateUpVectorWithCameraRotationMatrix;
  8080. private _cachedRotationZ;
  8081. private _cachedQuaternionRotationZ;
  8082. /** @hidden */
  8083. _getViewMatrix(): Matrix;
  8084. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8085. /**
  8086. * @hidden
  8087. */
  8088. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8089. /**
  8090. * @hidden
  8091. */
  8092. _updateRigCameras(): void;
  8093. private _getRigCamPositionAndTarget;
  8094. /**
  8095. * Gets the current object class name.
  8096. * @return the class name
  8097. */
  8098. getClassName(): string;
  8099. }
  8100. }
  8101. declare module "babylonjs/Cameras/cameraInputsManager" {
  8102. import { Nullable } from "babylonjs/types";
  8103. import { Camera } from "babylonjs/Cameras/camera";
  8104. /**
  8105. * @ignore
  8106. * This is a list of all the different input types that are available in the application.
  8107. * Fo instance: ArcRotateCameraGamepadInput...
  8108. */
  8109. export var CameraInputTypes: {};
  8110. /**
  8111. * This is the contract to implement in order to create a new input class.
  8112. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8113. */
  8114. export interface ICameraInput<TCamera extends Camera> {
  8115. /**
  8116. * Defines the camera the input is attached to.
  8117. */
  8118. camera: Nullable<TCamera>;
  8119. /**
  8120. * Gets the class name of the current intput.
  8121. * @returns the class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Get the friendly name associated with the input class.
  8126. * @returns the input friendly name
  8127. */
  8128. getSimpleName(): string;
  8129. /**
  8130. * Attach the input controls to a specific dom element to get the input from.
  8131. * @param element Defines the element the controls should be listened from
  8132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8133. */
  8134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8135. /**
  8136. * Detach the current controls from the specified dom element.
  8137. * @param element Defines the element to stop listening the inputs from
  8138. */
  8139. detachControl(element: Nullable<HTMLElement>): void;
  8140. /**
  8141. * Update the current camera state depending on the inputs that have been used this frame.
  8142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8143. */
  8144. checkInputs?: () => void;
  8145. }
  8146. /**
  8147. * Represents a map of input types to input instance or input index to input instance.
  8148. */
  8149. export interface CameraInputsMap<TCamera extends Camera> {
  8150. /**
  8151. * Accessor to the input by input type.
  8152. */
  8153. [name: string]: ICameraInput<TCamera>;
  8154. /**
  8155. * Accessor to the input by input index.
  8156. */
  8157. [idx: number]: ICameraInput<TCamera>;
  8158. }
  8159. /**
  8160. * This represents the input manager used within a camera.
  8161. * It helps dealing with all the different kind of input attached to a camera.
  8162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8163. */
  8164. export class CameraInputsManager<TCamera extends Camera> {
  8165. /**
  8166. * Defines the list of inputs attahed to the camera.
  8167. */
  8168. attached: CameraInputsMap<TCamera>;
  8169. /**
  8170. * Defines the dom element the camera is collecting inputs from.
  8171. * This is null if the controls have not been attached.
  8172. */
  8173. attachedElement: Nullable<HTMLElement>;
  8174. /**
  8175. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8176. */
  8177. noPreventDefault: boolean;
  8178. /**
  8179. * Defined the camera the input manager belongs to.
  8180. */
  8181. camera: TCamera;
  8182. /**
  8183. * Update the current camera state depending on the inputs that have been used this frame.
  8184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8185. */
  8186. checkInputs: () => void;
  8187. /**
  8188. * Instantiate a new Camera Input Manager.
  8189. * @param camera Defines the camera the input manager blongs to
  8190. */
  8191. constructor(camera: TCamera);
  8192. /**
  8193. * Add an input method to a camera
  8194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8195. * @param input camera input method
  8196. */
  8197. add(input: ICameraInput<TCamera>): void;
  8198. /**
  8199. * Remove a specific input method from a camera
  8200. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8201. * @param inputToRemove camera input method
  8202. */
  8203. remove(inputToRemove: ICameraInput<TCamera>): void;
  8204. /**
  8205. * Remove a specific input type from a camera
  8206. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8207. * @param inputType the type of the input to remove
  8208. */
  8209. removeByType(inputType: string): void;
  8210. private _addCheckInputs;
  8211. /**
  8212. * Attach the input controls to the currently attached dom element to listen the events from.
  8213. * @param input Defines the input to attach
  8214. */
  8215. attachInput(input: ICameraInput<TCamera>): void;
  8216. /**
  8217. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8218. * @param element Defines the dom element to collect the events from
  8219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8220. */
  8221. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8222. /**
  8223. * Detach the current manager inputs controls from a specific dom element.
  8224. * @param element Defines the dom element to collect the events from
  8225. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8226. */
  8227. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8228. /**
  8229. * Rebuild the dynamic inputCheck function from the current list of
  8230. * defined inputs in the manager.
  8231. */
  8232. rebuildInputCheck(): void;
  8233. /**
  8234. * Remove all attached input methods from a camera
  8235. */
  8236. clear(): void;
  8237. /**
  8238. * Serialize the current input manager attached to a camera.
  8239. * This ensures than once parsed,
  8240. * the input associated to the camera will be identical to the current ones
  8241. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8242. */
  8243. serialize(serializedCamera: any): void;
  8244. /**
  8245. * Parses an input manager serialized JSON to restore the previous list of inputs
  8246. * and states associated to a camera.
  8247. * @param parsedCamera Defines the JSON to parse
  8248. */
  8249. parse(parsedCamera: any): void;
  8250. }
  8251. }
  8252. declare module "babylonjs/Events/keyboardEvents" {
  8253. /**
  8254. * Gather the list of keyboard event types as constants.
  8255. */
  8256. export class KeyboardEventTypes {
  8257. /**
  8258. * The keydown event is fired when a key becomes active (pressed).
  8259. */
  8260. static readonly KEYDOWN: number;
  8261. /**
  8262. * The keyup event is fired when a key has been released.
  8263. */
  8264. static readonly KEYUP: number;
  8265. }
  8266. /**
  8267. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8268. */
  8269. export class KeyboardInfo {
  8270. /**
  8271. * Defines the type of event (KeyboardEventTypes)
  8272. */
  8273. type: number;
  8274. /**
  8275. * Defines the related dom event
  8276. */
  8277. event: KeyboardEvent;
  8278. /**
  8279. * Instantiates a new keyboard info.
  8280. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8281. * @param type Defines the type of event (KeyboardEventTypes)
  8282. * @param event Defines the related dom event
  8283. */
  8284. constructor(
  8285. /**
  8286. * Defines the type of event (KeyboardEventTypes)
  8287. */
  8288. type: number,
  8289. /**
  8290. * Defines the related dom event
  8291. */
  8292. event: KeyboardEvent);
  8293. }
  8294. /**
  8295. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8296. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8297. */
  8298. export class KeyboardInfoPre extends KeyboardInfo {
  8299. /**
  8300. * Defines the type of event (KeyboardEventTypes)
  8301. */
  8302. type: number;
  8303. /**
  8304. * Defines the related dom event
  8305. */
  8306. event: KeyboardEvent;
  8307. /**
  8308. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8309. */
  8310. skipOnPointerObservable: boolean;
  8311. /**
  8312. * Instantiates a new keyboard pre info.
  8313. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8314. * @param type Defines the type of event (KeyboardEventTypes)
  8315. * @param event Defines the related dom event
  8316. */
  8317. constructor(
  8318. /**
  8319. * Defines the type of event (KeyboardEventTypes)
  8320. */
  8321. type: number,
  8322. /**
  8323. * Defines the related dom event
  8324. */
  8325. event: KeyboardEvent);
  8326. }
  8327. }
  8328. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8329. import { Nullable } from "babylonjs/types";
  8330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8331. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8332. /**
  8333. * Manage the keyboard inputs to control the movement of a free camera.
  8334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8335. */
  8336. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8337. /**
  8338. * Defines the camera the input is attached to.
  8339. */
  8340. camera: FreeCamera;
  8341. /**
  8342. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8343. */
  8344. keysUp: number[];
  8345. /**
  8346. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8347. */
  8348. keysDown: number[];
  8349. /**
  8350. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8351. */
  8352. keysLeft: number[];
  8353. /**
  8354. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8355. */
  8356. keysRight: number[];
  8357. private _keys;
  8358. private _onCanvasBlurObserver;
  8359. private _onKeyboardObserver;
  8360. private _engine;
  8361. private _scene;
  8362. /**
  8363. * Attach the input controls to a specific dom element to get the input from.
  8364. * @param element Defines the element the controls should be listened from
  8365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8366. */
  8367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8368. /**
  8369. * Detach the current controls from the specified dom element.
  8370. * @param element Defines the element to stop listening the inputs from
  8371. */
  8372. detachControl(element: Nullable<HTMLElement>): void;
  8373. /**
  8374. * Update the current camera state depending on the inputs that have been used this frame.
  8375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8376. */
  8377. checkInputs(): void;
  8378. /**
  8379. * Gets the class name of the current intput.
  8380. * @returns the class name
  8381. */
  8382. getClassName(): string;
  8383. /** @hidden */
  8384. _onLostFocus(): void;
  8385. /**
  8386. * Get the friendly name associated with the input class.
  8387. * @returns the input friendly name
  8388. */
  8389. getSimpleName(): string;
  8390. }
  8391. }
  8392. declare module "babylonjs/Materials/multiMaterial" {
  8393. import { Nullable } from "babylonjs/types";
  8394. import { Scene } from "babylonjs/scene";
  8395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8396. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. import { Material } from "babylonjs/Materials/material";
  8399. /**
  8400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8401. * separate meshes. This can be use to improve performances.
  8402. * @see http://doc.babylonjs.com/how_to/multi_materials
  8403. */
  8404. export class MultiMaterial extends Material {
  8405. private _subMaterials;
  8406. /**
  8407. * Gets or Sets the list of Materials used within the multi material.
  8408. * They need to be ordered according to the submeshes order in the associated mesh
  8409. */
  8410. subMaterials: Nullable<Material>[];
  8411. /**
  8412. * Function used to align with Node.getChildren()
  8413. * @returns the list of Materials used within the multi material
  8414. */
  8415. getChildren(): Nullable<Material>[];
  8416. /**
  8417. * Instantiates a new Multi Material
  8418. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8419. * separate meshes. This can be use to improve performances.
  8420. * @see http://doc.babylonjs.com/how_to/multi_materials
  8421. * @param name Define the name in the scene
  8422. * @param scene Define the scene the material belongs to
  8423. */
  8424. constructor(name: string, scene: Scene);
  8425. private _hookArray;
  8426. /**
  8427. * Get one of the submaterial by its index in the submaterials array
  8428. * @param index The index to look the sub material at
  8429. * @returns The Material if the index has been defined
  8430. */
  8431. getSubMaterial(index: number): Nullable<Material>;
  8432. /**
  8433. * Get the list of active textures for the whole sub materials list.
  8434. * @returns All the textures that will be used during the rendering
  8435. */
  8436. getActiveTextures(): BaseTexture[];
  8437. /**
  8438. * Gets the current class name of the material e.g. "MultiMaterial"
  8439. * Mainly use in serialization.
  8440. * @returns the class name
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Checks if the material is ready to render the requested sub mesh
  8445. * @param mesh Define the mesh the submesh belongs to
  8446. * @param subMesh Define the sub mesh to look readyness for
  8447. * @param useInstances Define whether or not the material is used with instances
  8448. * @returns true if ready, otherwise false
  8449. */
  8450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8451. /**
  8452. * Clones the current material and its related sub materials
  8453. * @param name Define the name of the newly cloned material
  8454. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8455. * @returns the cloned material
  8456. */
  8457. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8458. /**
  8459. * Serializes the materials into a JSON representation.
  8460. * @returns the JSON representation
  8461. */
  8462. serialize(): any;
  8463. /**
  8464. * Dispose the material and release its associated resources
  8465. * @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)
  8466. * @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)
  8467. * @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)
  8468. */
  8469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8470. /**
  8471. * Creates a MultiMaterial from parsed MultiMaterial data.
  8472. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8473. * @param scene defines the hosting scene
  8474. * @returns a new MultiMaterial
  8475. */
  8476. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8477. }
  8478. }
  8479. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8480. /**
  8481. * Class used to represent data loading progression
  8482. */
  8483. export class SceneLoaderFlags {
  8484. private static _ForceFullSceneLoadingForIncremental;
  8485. private static _ShowLoadingScreen;
  8486. private static _CleanBoneMatrixWeights;
  8487. private static _loggingLevel;
  8488. /**
  8489. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8490. */
  8491. static ForceFullSceneLoadingForIncremental: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8494. */
  8495. static ShowLoadingScreen: boolean;
  8496. /**
  8497. * Defines the current logging level (while loading the scene)
  8498. * @ignorenaming
  8499. */
  8500. static loggingLevel: number;
  8501. /**
  8502. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8503. */
  8504. static CleanBoneMatrixWeights: boolean;
  8505. }
  8506. }
  8507. declare module "babylonjs/Meshes/transformNode" {
  8508. import { DeepImmutable } from "babylonjs/types";
  8509. import { Observable } from "babylonjs/Misc/observable";
  8510. import { Nullable } from "babylonjs/types";
  8511. import { Camera } from "babylonjs/Cameras/camera";
  8512. import { Scene } from "babylonjs/scene";
  8513. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8514. import { Node } from "babylonjs/node";
  8515. import { Bone } from "babylonjs/Bones/bone";
  8516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8517. /**
  8518. * 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.
  8519. * @see https://doc.babylonjs.com/how_to/transformnode
  8520. */
  8521. export class TransformNode extends Node {
  8522. /**
  8523. * Object will not rotate to face the camera
  8524. */
  8525. static BILLBOARDMODE_NONE: number;
  8526. /**
  8527. * Object will rotate to face the camera but only on the x axis
  8528. */
  8529. static BILLBOARDMODE_X: number;
  8530. /**
  8531. * Object will rotate to face the camera but only on the y axis
  8532. */
  8533. static BILLBOARDMODE_Y: number;
  8534. /**
  8535. * Object will rotate to face the camera but only on the z axis
  8536. */
  8537. static BILLBOARDMODE_Z: number;
  8538. /**
  8539. * Object will rotate to face the camera
  8540. */
  8541. static BILLBOARDMODE_ALL: number;
  8542. private _forward;
  8543. private _forwardInverted;
  8544. private _up;
  8545. private _right;
  8546. private _rightInverted;
  8547. private _position;
  8548. private _rotation;
  8549. private _rotationQuaternion;
  8550. protected _scaling: Vector3;
  8551. protected _isDirty: boolean;
  8552. private _transformToBoneReferal;
  8553. private _billboardMode;
  8554. /**
  8555. * Gets or sets the billboard mode. Default is 0.
  8556. *
  8557. * | Value | Type | Description |
  8558. * | --- | --- | --- |
  8559. * | 0 | BILLBOARDMODE_NONE | |
  8560. * | 1 | BILLBOARDMODE_X | |
  8561. * | 2 | BILLBOARDMODE_Y | |
  8562. * | 4 | BILLBOARDMODE_Z | |
  8563. * | 7 | BILLBOARDMODE_ALL | |
  8564. *
  8565. */
  8566. billboardMode: number;
  8567. private _preserveParentRotationForBillboard;
  8568. /**
  8569. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8570. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8571. */
  8572. preserveParentRotationForBillboard: boolean;
  8573. /**
  8574. * 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
  8575. */
  8576. scalingDeterminant: number;
  8577. private _infiniteDistance;
  8578. /**
  8579. * Gets or sets the distance of the object to max, often used by skybox
  8580. */
  8581. infiniteDistance: boolean;
  8582. /**
  8583. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8584. * By default the system will update normals to compensate
  8585. */
  8586. ignoreNonUniformScaling: boolean;
  8587. /**
  8588. * 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
  8589. */
  8590. reIntegrateRotationIntoRotationQuaternion: boolean;
  8591. /** @hidden */
  8592. _poseMatrix: Nullable<Matrix>;
  8593. /** @hidden */
  8594. _localMatrix: Matrix;
  8595. private _usePivotMatrix;
  8596. private _absolutePosition;
  8597. private _pivotMatrix;
  8598. private _pivotMatrixInverse;
  8599. protected _postMultiplyPivotMatrix: boolean;
  8600. protected _isWorldMatrixFrozen: boolean;
  8601. /** @hidden */
  8602. _indexInSceneTransformNodesArray: number;
  8603. /**
  8604. * An event triggered after the world matrix is updated
  8605. */
  8606. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8607. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8608. /**
  8609. * Gets a string identifying the name of the class
  8610. * @returns "TransformNode" string
  8611. */
  8612. getClassName(): string;
  8613. /**
  8614. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8615. */
  8616. position: Vector3;
  8617. /**
  8618. * 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)).
  8619. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8620. */
  8621. rotation: Vector3;
  8622. /**
  8623. * 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)).
  8624. */
  8625. scaling: Vector3;
  8626. /**
  8627. * 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).
  8628. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8629. */
  8630. rotationQuaternion: Nullable<Quaternion>;
  8631. /**
  8632. * The forward direction of that transform in world space.
  8633. */
  8634. readonly forward: Vector3;
  8635. /**
  8636. * The up direction of that transform in world space.
  8637. */
  8638. readonly up: Vector3;
  8639. /**
  8640. * The right direction of that transform in world space.
  8641. */
  8642. readonly right: Vector3;
  8643. /**
  8644. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8645. * @param matrix the matrix to copy the pose from
  8646. * @returns this TransformNode.
  8647. */
  8648. updatePoseMatrix(matrix: Matrix): TransformNode;
  8649. /**
  8650. * Returns the mesh Pose matrix.
  8651. * @returns the pose matrix
  8652. */
  8653. getPoseMatrix(): Matrix;
  8654. /** @hidden */
  8655. _isSynchronized(): boolean;
  8656. /** @hidden */
  8657. _initCache(): void;
  8658. /**
  8659. * Flag the transform node as dirty (Forcing it to update everything)
  8660. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8661. * @returns this transform node
  8662. */
  8663. markAsDirty(property: string): TransformNode;
  8664. /**
  8665. * Returns the current mesh absolute position.
  8666. * Returns a Vector3.
  8667. */
  8668. readonly absolutePosition: Vector3;
  8669. /**
  8670. * Sets a new matrix to apply before all other transformation
  8671. * @param matrix defines the transform matrix
  8672. * @returns the current TransformNode
  8673. */
  8674. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8675. /**
  8676. * Sets a new pivot matrix to the current node
  8677. * @param matrix defines the new pivot matrix to use
  8678. * @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
  8679. * @returns the current TransformNode
  8680. */
  8681. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8682. /**
  8683. * Returns the mesh pivot matrix.
  8684. * Default : Identity.
  8685. * @returns the matrix
  8686. */
  8687. getPivotMatrix(): Matrix;
  8688. /**
  8689. * Prevents the World matrix to be computed any longer.
  8690. * @returns the TransformNode.
  8691. */
  8692. freezeWorldMatrix(): TransformNode;
  8693. /**
  8694. * Allows back the World matrix computation.
  8695. * @returns the TransformNode.
  8696. */
  8697. unfreezeWorldMatrix(): this;
  8698. /**
  8699. * True if the World matrix has been frozen.
  8700. */
  8701. readonly isWorldMatrixFrozen: boolean;
  8702. /**
  8703. * Retuns the mesh absolute position in the World.
  8704. * @returns a Vector3.
  8705. */
  8706. getAbsolutePosition(): Vector3;
  8707. /**
  8708. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8709. * @param absolutePosition the absolute position to set
  8710. * @returns the TransformNode.
  8711. */
  8712. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8713. /**
  8714. * Sets the mesh position in its local space.
  8715. * @param vector3 the position to set in localspace
  8716. * @returns the TransformNode.
  8717. */
  8718. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8719. /**
  8720. * Returns the mesh position in the local space from the current World matrix values.
  8721. * @returns a new Vector3.
  8722. */
  8723. getPositionExpressedInLocalSpace(): Vector3;
  8724. /**
  8725. * Translates the mesh along the passed Vector3 in its local space.
  8726. * @param vector3 the distance to translate in localspace
  8727. * @returns the TransformNode.
  8728. */
  8729. locallyTranslate(vector3: Vector3): TransformNode;
  8730. private static _lookAtVectorCache;
  8731. /**
  8732. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8733. * @param targetPoint the position (must be in same space as current mesh) to look at
  8734. * @param yawCor optional yaw (y-axis) correction in radians
  8735. * @param pitchCor optional pitch (x-axis) correction in radians
  8736. * @param rollCor optional roll (z-axis) correction in radians
  8737. * @param space the choosen space of the target
  8738. * @returns the TransformNode.
  8739. */
  8740. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8741. /**
  8742. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8743. * This Vector3 is expressed in the World space.
  8744. * @param localAxis axis to rotate
  8745. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. */
  8747. getDirection(localAxis: Vector3): Vector3;
  8748. /**
  8749. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8750. * localAxis is expressed in the mesh local space.
  8751. * result is computed in the Wordl space from the mesh World matrix.
  8752. * @param localAxis axis to rotate
  8753. * @param result the resulting transformnode
  8754. * @returns this TransformNode.
  8755. */
  8756. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8757. /**
  8758. * Sets this transform node rotation to the given local axis.
  8759. * @param localAxis the axis in local space
  8760. * @param yawCor optional yaw (y-axis) correction in radians
  8761. * @param pitchCor optional pitch (x-axis) correction in radians
  8762. * @param rollCor optional roll (z-axis) correction in radians
  8763. * @returns this TransformNode
  8764. */
  8765. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8766. /**
  8767. * Sets a new pivot point to the current node
  8768. * @param point defines the new pivot point to use
  8769. * @param space defines if the point is in world or local space (local by default)
  8770. * @returns the current TransformNode
  8771. */
  8772. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8773. /**
  8774. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8775. * @returns the pivot point
  8776. */
  8777. getPivotPoint(): Vector3;
  8778. /**
  8779. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8780. * @param result the vector3 to store the result
  8781. * @returns this TransformNode.
  8782. */
  8783. getPivotPointToRef(result: Vector3): TransformNode;
  8784. /**
  8785. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8786. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8787. */
  8788. getAbsolutePivotPoint(): Vector3;
  8789. /**
  8790. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8791. * @param result vector3 to store the result
  8792. * @returns this TransformNode.
  8793. */
  8794. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8795. /**
  8796. * Defines the passed node as the parent of the current node.
  8797. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8798. * @see https://doc.babylonjs.com/how_to/parenting
  8799. * @param node the node ot set as the parent
  8800. * @returns this TransformNode.
  8801. */
  8802. setParent(node: Nullable<Node>): TransformNode;
  8803. private _nonUniformScaling;
  8804. /**
  8805. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8806. */
  8807. readonly nonUniformScaling: boolean;
  8808. /** @hidden */
  8809. _updateNonUniformScalingState(value: boolean): boolean;
  8810. /**
  8811. * Attach the current TransformNode to another TransformNode associated with a bone
  8812. * @param bone Bone affecting the TransformNode
  8813. * @param affectedTransformNode TransformNode associated with the bone
  8814. * @returns this object
  8815. */
  8816. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8817. /**
  8818. * Detach the transform node if its associated with a bone
  8819. * @returns this object
  8820. */
  8821. detachFromBone(): TransformNode;
  8822. private static _rotationAxisCache;
  8823. /**
  8824. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8825. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8826. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8827. * The passed axis is also normalized.
  8828. * @param axis the axis to rotate around
  8829. * @param amount the amount to rotate in radians
  8830. * @param space Space to rotate in (Default: local)
  8831. * @returns the TransformNode.
  8832. */
  8833. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8834. /**
  8835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8837. * The passed axis is also normalized. .
  8838. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8839. * @param point the point to rotate around
  8840. * @param axis the axis to rotate around
  8841. * @param amount the amount to rotate in radians
  8842. * @returns the TransformNode
  8843. */
  8844. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8845. /**
  8846. * Translates the mesh along the axis vector for the passed distance in the given space.
  8847. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8848. * @param axis the axis to translate in
  8849. * @param distance the distance to translate
  8850. * @param space Space to rotate in (Default: local)
  8851. * @returns the TransformNode.
  8852. */
  8853. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8854. /**
  8855. * Adds a rotation step to the mesh current rotation.
  8856. * x, y, z are Euler angles expressed in radians.
  8857. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8858. * This means this rotation is made in the mesh local space only.
  8859. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8860. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8861. * ```javascript
  8862. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8863. * ```
  8864. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8865. * 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.
  8866. * @param x Rotation to add
  8867. * @param y Rotation to add
  8868. * @param z Rotation to add
  8869. * @returns the TransformNode.
  8870. */
  8871. addRotation(x: number, y: number, z: number): TransformNode;
  8872. /**
  8873. * @hidden
  8874. */
  8875. protected _getEffectiveParent(): Nullable<Node>;
  8876. /**
  8877. * Computes the world matrix of the node
  8878. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8879. * @returns the world matrix
  8880. */
  8881. computeWorldMatrix(force?: boolean): Matrix;
  8882. protected _afterComputeWorldMatrix(): void;
  8883. /**
  8884. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8885. * @param func callback function to add
  8886. *
  8887. * @returns the TransformNode.
  8888. */
  8889. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8890. /**
  8891. * Removes a registered callback function.
  8892. * @param func callback function to remove
  8893. * @returns the TransformNode.
  8894. */
  8895. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8896. /**
  8897. * Gets the position of the current mesh in camera space
  8898. * @param camera defines the camera to use
  8899. * @returns a position
  8900. */
  8901. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8902. /**
  8903. * Returns the distance from the mesh to the active camera
  8904. * @param camera defines the camera to use
  8905. * @returns the distance
  8906. */
  8907. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8908. /**
  8909. * Clone the current transform node
  8910. * @param name Name of the new clone
  8911. * @param newParent New parent for the clone
  8912. * @param doNotCloneChildren Do not clone children hierarchy
  8913. * @returns the new transform node
  8914. */
  8915. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8916. /**
  8917. * Serializes the objects information.
  8918. * @param currentSerializationObject defines the object to serialize in
  8919. * @returns the serialized object
  8920. */
  8921. serialize(currentSerializationObject?: any): any;
  8922. /**
  8923. * Returns a new TransformNode object parsed from the source provided.
  8924. * @param parsedTransformNode is the source.
  8925. * @param scene the scne the object belongs to
  8926. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8927. * @returns a new TransformNode object parsed from the source provided.
  8928. */
  8929. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8930. /**
  8931. * Get all child-transformNodes of this node
  8932. * @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
  8933. * @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
  8934. * @returns an array of TransformNode
  8935. */
  8936. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8937. /**
  8938. * Releases resources associated with this transform node.
  8939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8941. */
  8942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8943. /**
  8944. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8945. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8946. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8947. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8948. * @returns the current mesh
  8949. */
  8950. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8951. }
  8952. }
  8953. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8954. /**
  8955. * Class used to override all child animations of a given target
  8956. */
  8957. export class AnimationPropertiesOverride {
  8958. /**
  8959. * Gets or sets a value indicating if animation blending must be used
  8960. */
  8961. enableBlending: boolean;
  8962. /**
  8963. * Gets or sets the blending speed to use when enableBlending is true
  8964. */
  8965. blendingSpeed: number;
  8966. /**
  8967. * Gets or sets the default loop mode to use
  8968. */
  8969. loopMode: number;
  8970. }
  8971. }
  8972. declare module "babylonjs/Bones/bone" {
  8973. import { Skeleton } from "babylonjs/Bones/skeleton";
  8974. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8975. import { Nullable } from "babylonjs/types";
  8976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8978. import { Node } from "babylonjs/node";
  8979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8980. /**
  8981. * Class used to store bone information
  8982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8983. */
  8984. export class Bone extends Node {
  8985. /**
  8986. * defines the bone name
  8987. */
  8988. name: string;
  8989. private static _tmpVecs;
  8990. private static _tmpQuat;
  8991. private static _tmpMats;
  8992. /**
  8993. * Gets the list of child bones
  8994. */
  8995. children: Bone[];
  8996. /** Gets the animations associated with this bone */
  8997. animations: import("babylonjs/Animations/animation").Animation[];
  8998. /**
  8999. * Gets or sets bone length
  9000. */
  9001. length: number;
  9002. /**
  9003. * @hidden Internal only
  9004. * Set this value to map this bone to a different index in the transform matrices
  9005. * Set this value to -1 to exclude the bone from the transform matrices
  9006. */
  9007. _index: Nullable<number>;
  9008. private _skeleton;
  9009. private _localMatrix;
  9010. private _restPose;
  9011. private _baseMatrix;
  9012. private _absoluteTransform;
  9013. private _invertedAbsoluteTransform;
  9014. private _parent;
  9015. private _scalingDeterminant;
  9016. private _worldTransform;
  9017. private _localScaling;
  9018. private _localRotation;
  9019. private _localPosition;
  9020. private _needToDecompose;
  9021. private _needToCompose;
  9022. /** @hidden */
  9023. _linkedTransformNode: Nullable<TransformNode>;
  9024. /** @hidden */
  9025. _waitingTransformNodeId: Nullable<string>;
  9026. /** @hidden */
  9027. /** @hidden */
  9028. _matrix: Matrix;
  9029. /**
  9030. * Create a new bone
  9031. * @param name defines the bone name
  9032. * @param skeleton defines the parent skeleton
  9033. * @param parentBone defines the parent (can be null if the bone is the root)
  9034. * @param localMatrix defines the local matrix
  9035. * @param restPose defines the rest pose matrix
  9036. * @param baseMatrix defines the base matrix
  9037. * @param index defines index of the bone in the hiearchy
  9038. */
  9039. constructor(
  9040. /**
  9041. * defines the bone name
  9042. */
  9043. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9044. /**
  9045. * Gets the current object class name.
  9046. * @return the class name
  9047. */
  9048. getClassName(): string;
  9049. /**
  9050. * Gets the parent skeleton
  9051. * @returns a skeleton
  9052. */
  9053. getSkeleton(): Skeleton;
  9054. /**
  9055. * Gets parent bone
  9056. * @returns a bone or null if the bone is the root of the bone hierarchy
  9057. */
  9058. getParent(): Nullable<Bone>;
  9059. /**
  9060. * Returns an array containing the root bones
  9061. * @returns an array containing the root bones
  9062. */
  9063. getChildren(): Array<Bone>;
  9064. /**
  9065. * Sets the parent bone
  9066. * @param parent defines the parent (can be null if the bone is the root)
  9067. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9068. */
  9069. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9070. /**
  9071. * Gets the local matrix
  9072. * @returns a matrix
  9073. */
  9074. getLocalMatrix(): Matrix;
  9075. /**
  9076. * Gets the base matrix (initial matrix which remains unchanged)
  9077. * @returns a matrix
  9078. */
  9079. getBaseMatrix(): Matrix;
  9080. /**
  9081. * Gets the rest pose matrix
  9082. * @returns a matrix
  9083. */
  9084. getRestPose(): Matrix;
  9085. /**
  9086. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9087. */
  9088. getWorldMatrix(): Matrix;
  9089. /**
  9090. * Sets the local matrix to rest pose matrix
  9091. */
  9092. returnToRest(): void;
  9093. /**
  9094. * Gets the inverse of the absolute transform matrix.
  9095. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9096. * @returns a matrix
  9097. */
  9098. getInvertedAbsoluteTransform(): Matrix;
  9099. /**
  9100. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9101. * @returns a matrix
  9102. */
  9103. getAbsoluteTransform(): Matrix;
  9104. /**
  9105. * Links with the given transform node.
  9106. * The local matrix of this bone is copied from the transform node every frame.
  9107. * @param transformNode defines the transform node to link to
  9108. */
  9109. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9110. /** Gets or sets current position (in local space) */
  9111. position: Vector3;
  9112. /** Gets or sets current rotation (in local space) */
  9113. rotation: Vector3;
  9114. /** Gets or sets current rotation quaternion (in local space) */
  9115. rotationQuaternion: Quaternion;
  9116. /** Gets or sets current scaling (in local space) */
  9117. scaling: Vector3;
  9118. /**
  9119. * Gets the animation properties override
  9120. */
  9121. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9122. private _decompose;
  9123. private _compose;
  9124. /**
  9125. * Update the base and local matrices
  9126. * @param matrix defines the new base or local matrix
  9127. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9128. * @param updateLocalMatrix defines if the local matrix should be updated
  9129. */
  9130. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9131. /** @hidden */
  9132. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9133. /**
  9134. * Flag the bone as dirty (Forcing it to update everything)
  9135. */
  9136. markAsDirty(): void;
  9137. /** @hidden */
  9138. _markAsDirtyAndCompose(): void;
  9139. private _markAsDirtyAndDecompose;
  9140. /**
  9141. * Translate the bone in local or world space
  9142. * @param vec The amount to translate the bone
  9143. * @param space The space that the translation is in
  9144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9145. */
  9146. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9147. /**
  9148. * Set the postion of the bone in local or world space
  9149. * @param position The position to set the bone
  9150. * @param space The space that the position is in
  9151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9152. */
  9153. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9154. /**
  9155. * Set the absolute position of the bone (world space)
  9156. * @param position The position to set the bone
  9157. * @param mesh The mesh that this bone is attached to
  9158. */
  9159. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9160. /**
  9161. * Scale the bone on the x, y and z axes (in local space)
  9162. * @param x The amount to scale the bone on the x axis
  9163. * @param y The amount to scale the bone on the y axis
  9164. * @param z The amount to scale the bone on the z axis
  9165. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9166. */
  9167. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9168. /**
  9169. * Set the bone scaling in local space
  9170. * @param scale defines the scaling vector
  9171. */
  9172. setScale(scale: Vector3): void;
  9173. /**
  9174. * Gets the current scaling in local space
  9175. * @returns the current scaling vector
  9176. */
  9177. getScale(): Vector3;
  9178. /**
  9179. * Gets the current scaling in local space and stores it in a target vector
  9180. * @param result defines the target vector
  9181. */
  9182. getScaleToRef(result: Vector3): void;
  9183. /**
  9184. * Set the yaw, pitch, and roll of the bone in local or world space
  9185. * @param yaw The rotation of the bone on the y axis
  9186. * @param pitch The rotation of the bone on the x axis
  9187. * @param roll The rotation of the bone on the z axis
  9188. * @param space The space that the axes of rotation are in
  9189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9190. */
  9191. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9192. /**
  9193. * Add a rotation to the bone on an axis in local or world space
  9194. * @param axis The axis to rotate the bone on
  9195. * @param amount The amount to rotate the bone
  9196. * @param space The space that the axis is in
  9197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9198. */
  9199. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9200. /**
  9201. * Set the rotation of the bone to a particular axis angle in local or world space
  9202. * @param axis The axis to rotate the bone on
  9203. * @param angle The angle that the bone should be rotated to
  9204. * @param space The space that the axis is in
  9205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9206. */
  9207. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9208. /**
  9209. * Set the euler rotation of the bone in local of world space
  9210. * @param rotation The euler rotation that the bone should be set to
  9211. * @param space The space that the rotation is in
  9212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9213. */
  9214. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9215. /**
  9216. * Set the quaternion rotation of the bone in local of world space
  9217. * @param quat The quaternion rotation that the bone should be set to
  9218. * @param space The space that the rotation is in
  9219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9220. */
  9221. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9222. /**
  9223. * Set the rotation matrix of the bone in local of world space
  9224. * @param rotMat The rotation matrix that the bone should be set to
  9225. * @param space The space that the rotation is in
  9226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9227. */
  9228. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9229. private _rotateWithMatrix;
  9230. private _getNegativeRotationToRef;
  9231. /**
  9232. * Get the position of the bone in local or world space
  9233. * @param space The space that the returned position is in
  9234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9235. * @returns The position of the bone
  9236. */
  9237. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9238. /**
  9239. * Copy the position of the bone to a vector3 in local or world space
  9240. * @param space The space that the returned position is in
  9241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9242. * @param result The vector3 to copy the position to
  9243. */
  9244. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9245. /**
  9246. * Get the absolute position of the bone (world space)
  9247. * @param mesh The mesh that this bone is attached to
  9248. * @returns The absolute position of the bone
  9249. */
  9250. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9251. /**
  9252. * Copy the absolute position of the bone (world space) to the result param
  9253. * @param mesh The mesh that this bone is attached to
  9254. * @param result The vector3 to copy the absolute position to
  9255. */
  9256. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9257. /**
  9258. * Compute the absolute transforms of this bone and its children
  9259. */
  9260. computeAbsoluteTransforms(): void;
  9261. /**
  9262. * Get the world direction from an axis that is in the local space of the bone
  9263. * @param localAxis The local direction that is used to compute the world direction
  9264. * @param mesh The mesh that this bone is attached to
  9265. * @returns The world direction
  9266. */
  9267. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9268. /**
  9269. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9270. * @param localAxis The local direction that is used to compute the world direction
  9271. * @param mesh The mesh that this bone is attached to
  9272. * @param result The vector3 that the world direction will be copied to
  9273. */
  9274. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9275. /**
  9276. * Get the euler rotation of the bone in local or world space
  9277. * @param space The space that the rotation should be in
  9278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9279. * @returns The euler rotation
  9280. */
  9281. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9282. /**
  9283. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9284. * @param space The space that the rotation should be in
  9285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9286. * @param result The vector3 that the rotation should be copied to
  9287. */
  9288. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9289. /**
  9290. * Get the quaternion rotation of the bone in either local or world space
  9291. * @param space The space that the rotation should be in
  9292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9293. * @returns The quaternion rotation
  9294. */
  9295. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9296. /**
  9297. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9298. * @param space The space that the rotation should be in
  9299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9300. * @param result The quaternion that the rotation should be copied to
  9301. */
  9302. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9303. /**
  9304. * Get the rotation matrix of the bone in local or world space
  9305. * @param space The space that the rotation should be in
  9306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9307. * @returns The rotation matrix
  9308. */
  9309. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9310. /**
  9311. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9312. * @param space The space that the rotation should be in
  9313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9314. * @param result The quaternion that the rotation should be copied to
  9315. */
  9316. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9317. /**
  9318. * Get the world position of a point that is in the local space of the bone
  9319. * @param position The local position
  9320. * @param mesh The mesh that this bone is attached to
  9321. * @returns The world position
  9322. */
  9323. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9324. /**
  9325. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9326. * @param position The local position
  9327. * @param mesh The mesh that this bone is attached to
  9328. * @param result The vector3 that the world position should be copied to
  9329. */
  9330. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9331. /**
  9332. * Get the local position of a point that is in world space
  9333. * @param position The world position
  9334. * @param mesh The mesh that this bone is attached to
  9335. * @returns The local position
  9336. */
  9337. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9338. /**
  9339. * Get the local position of a point that is in world space and copy it to the result param
  9340. * @param position The world position
  9341. * @param mesh The mesh that this bone is attached to
  9342. * @param result The vector3 that the local position should be copied to
  9343. */
  9344. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9345. }
  9346. }
  9347. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9348. import { Nullable } from "babylonjs/types";
  9349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9350. import { Scene } from "babylonjs/scene";
  9351. module "babylonjs/Engines/engine" {
  9352. interface Engine {
  9353. /**
  9354. * Creates a raw texture
  9355. * @param data defines the data to store in the texture
  9356. * @param width defines the width of the texture
  9357. * @param height defines the height of the texture
  9358. * @param format defines the format of the data
  9359. * @param generateMipMaps defines if the engine should generate the mip levels
  9360. * @param invertY defines if data must be stored with Y axis inverted
  9361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9362. * @param compression defines the compression used (null by default)
  9363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9364. * @returns the raw texture inside an InternalTexture
  9365. */
  9366. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9367. /**
  9368. * Update a raw texture
  9369. * @param texture defines the texture to update
  9370. * @param data defines the data to store in the texture
  9371. * @param format defines the format of the data
  9372. * @param invertY defines if data must be stored with Y axis inverted
  9373. */
  9374. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9375. /**
  9376. * Update a raw texture
  9377. * @param texture defines the texture to update
  9378. * @param data defines the data to store in the texture
  9379. * @param format defines the format of the data
  9380. * @param invertY defines if data must be stored with Y axis inverted
  9381. * @param compression defines the compression used (null by default)
  9382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9383. */
  9384. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9385. /**
  9386. * Creates a new raw cube texture
  9387. * @param data defines the array of data to use to create each face
  9388. * @param size defines the size of the textures
  9389. * @param format defines the format of the data
  9390. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9391. * @param generateMipMaps defines if the engine should generate the mip levels
  9392. * @param invertY defines if data must be stored with Y axis inverted
  9393. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9394. * @param compression defines the compression used (null by default)
  9395. * @returns the cube texture as an InternalTexture
  9396. */
  9397. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9398. /**
  9399. * Update a raw cube texture
  9400. * @param texture defines the texture to udpdate
  9401. * @param data defines the data to store
  9402. * @param format defines the data format
  9403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9404. * @param invertY defines if data must be stored with Y axis inverted
  9405. */
  9406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9407. /**
  9408. * Update a raw cube texture
  9409. * @param texture defines the texture to udpdate
  9410. * @param data defines the data to store
  9411. * @param format defines the data format
  9412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9413. * @param invertY defines if data must be stored with Y axis inverted
  9414. * @param compression defines the compression used (null by default)
  9415. */
  9416. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9417. /**
  9418. * Update a raw cube texture
  9419. * @param texture defines the texture to udpdate
  9420. * @param data defines the data to store
  9421. * @param format defines the data format
  9422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9423. * @param invertY defines if data must be stored with Y axis inverted
  9424. * @param compression defines the compression used (null by default)
  9425. * @param level defines which level of the texture to update
  9426. */
  9427. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9428. /**
  9429. * Creates a new raw cube texture from a specified url
  9430. * @param url defines the url where the data is located
  9431. * @param scene defines the current scene
  9432. * @param size defines the size of the textures
  9433. * @param format defines the format of the data
  9434. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9435. * @param noMipmap defines if the engine should avoid generating the mip levels
  9436. * @param callback defines a callback used to extract texture data from loaded data
  9437. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9438. * @param onLoad defines a callback called when texture is loaded
  9439. * @param onError defines a callback called if there is an error
  9440. * @returns the cube texture as an InternalTexture
  9441. */
  9442. 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;
  9443. /**
  9444. * Creates a new raw cube texture from a specified url
  9445. * @param url defines the url where the data is located
  9446. * @param scene defines the current scene
  9447. * @param size defines the size of the textures
  9448. * @param format defines the format of the data
  9449. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9450. * @param noMipmap defines if the engine should avoid generating the mip levels
  9451. * @param callback defines a callback used to extract texture data from loaded data
  9452. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9453. * @param onLoad defines a callback called when texture is loaded
  9454. * @param onError defines a callback called if there is an error
  9455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9456. * @param invertY defines if data must be stored with Y axis inverted
  9457. * @returns the cube texture as an InternalTexture
  9458. */
  9459. 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;
  9460. /**
  9461. * Creates a new raw 3D texture
  9462. * @param data defines the data used to create the texture
  9463. * @param width defines the width of the texture
  9464. * @param height defines the height of the texture
  9465. * @param depth defines the depth of the texture
  9466. * @param format defines the format of the texture
  9467. * @param generateMipMaps defines if the engine must generate mip levels
  9468. * @param invertY defines if data must be stored with Y axis inverted
  9469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9470. * @param compression defines the compressed used (can be null)
  9471. * @param textureType defines the compressed used (can be null)
  9472. * @returns a new raw 3D texture (stored in an InternalTexture)
  9473. */
  9474. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9475. /**
  9476. * Update a raw 3D texture
  9477. * @param texture defines the texture to update
  9478. * @param data defines the data to store
  9479. * @param format defines the data format
  9480. * @param invertY defines if data must be stored with Y axis inverted
  9481. */
  9482. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9483. /**
  9484. * Update a raw 3D texture
  9485. * @param texture defines the texture to update
  9486. * @param data defines the data to store
  9487. * @param format defines the data format
  9488. * @param invertY defines if data must be stored with Y axis inverted
  9489. * @param compression defines the used compression (can be null)
  9490. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9491. */
  9492. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9493. }
  9494. }
  9495. }
  9496. declare module "babylonjs/Materials/Textures/rawTexture" {
  9497. import { Scene } from "babylonjs/scene";
  9498. import { Texture } from "babylonjs/Materials/Textures/texture";
  9499. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9500. /**
  9501. * Raw texture can help creating a texture directly from an array of data.
  9502. * This can be super useful if you either get the data from an uncompressed source or
  9503. * if you wish to create your texture pixel by pixel.
  9504. */
  9505. export class RawTexture extends Texture {
  9506. /**
  9507. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9508. */
  9509. format: number;
  9510. private _engine;
  9511. /**
  9512. * Instantiates a new RawTexture.
  9513. * Raw texture can help creating a texture directly from an array of data.
  9514. * This can be super useful if you either get the data from an uncompressed source or
  9515. * if you wish to create your texture pixel by pixel.
  9516. * @param data define the array of data to use to create the texture
  9517. * @param width define the width of the texture
  9518. * @param height define the height of the texture
  9519. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9520. * @param scene define the scene the texture belongs to
  9521. * @param generateMipMaps define whether mip maps should be generated or not
  9522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9524. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9525. */
  9526. constructor(data: ArrayBufferView, width: number, height: number,
  9527. /**
  9528. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9529. */
  9530. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9531. /**
  9532. * Updates the texture underlying data.
  9533. * @param data Define the new data of the texture
  9534. */
  9535. update(data: ArrayBufferView): void;
  9536. /**
  9537. * Creates a luminance texture from some data.
  9538. * @param data Define the texture data
  9539. * @param width Define the width of the texture
  9540. * @param height Define the height of the texture
  9541. * @param scene Define the scene the texture belongs to
  9542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9545. * @returns the luminance texture
  9546. */
  9547. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9548. /**
  9549. * Creates a luminance alpha texture from some data.
  9550. * @param data Define the texture data
  9551. * @param width Define the width of the texture
  9552. * @param height Define the height of the texture
  9553. * @param scene Define the scene the texture belongs to
  9554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9557. * @returns the luminance alpha texture
  9558. */
  9559. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9560. /**
  9561. * Creates an alpha texture from some data.
  9562. * @param data Define the texture data
  9563. * @param width Define the width of the texture
  9564. * @param height Define the height of the texture
  9565. * @param scene Define the scene the texture belongs to
  9566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9569. * @returns the alpha texture
  9570. */
  9571. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9572. /**
  9573. * Creates a RGB texture from some data.
  9574. * @param data Define the texture data
  9575. * @param width Define the width of the texture
  9576. * @param height Define the height of the texture
  9577. * @param scene Define the scene the texture belongs to
  9578. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9579. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9580. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9581. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9582. * @returns the RGB alpha texture
  9583. */
  9584. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9585. /**
  9586. * Creates a RGBA texture from some data.
  9587. * @param data Define the texture data
  9588. * @param width Define the width of the texture
  9589. * @param height Define the height of the texture
  9590. * @param scene Define the scene the texture belongs to
  9591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9594. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9595. * @returns the RGBA texture
  9596. */
  9597. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9598. /**
  9599. * Creates a R texture from some data.
  9600. * @param data Define the texture data
  9601. * @param width Define the width of the texture
  9602. * @param height Define the height of the texture
  9603. * @param scene Define the scene the texture belongs to
  9604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9607. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9608. * @returns the R texture
  9609. */
  9610. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9611. }
  9612. }
  9613. declare module "babylonjs/Animations/runtimeAnimation" {
  9614. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9615. import { Animatable } from "babylonjs/Animations/animatable";
  9616. import { Scene } from "babylonjs/scene";
  9617. /**
  9618. * Defines a runtime animation
  9619. */
  9620. export class RuntimeAnimation {
  9621. private _events;
  9622. /**
  9623. * The current frame of the runtime animation
  9624. */
  9625. private _currentFrame;
  9626. /**
  9627. * The animation used by the runtime animation
  9628. */
  9629. private _animation;
  9630. /**
  9631. * The target of the runtime animation
  9632. */
  9633. private _target;
  9634. /**
  9635. * The initiating animatable
  9636. */
  9637. private _host;
  9638. /**
  9639. * The original value of the runtime animation
  9640. */
  9641. private _originalValue;
  9642. /**
  9643. * The original blend value of the runtime animation
  9644. */
  9645. private _originalBlendValue;
  9646. /**
  9647. * The offsets cache of the runtime animation
  9648. */
  9649. private _offsetsCache;
  9650. /**
  9651. * The high limits cache of the runtime animation
  9652. */
  9653. private _highLimitsCache;
  9654. /**
  9655. * Specifies if the runtime animation has been stopped
  9656. */
  9657. private _stopped;
  9658. /**
  9659. * The blending factor of the runtime animation
  9660. */
  9661. private _blendingFactor;
  9662. /**
  9663. * The BabylonJS scene
  9664. */
  9665. private _scene;
  9666. /**
  9667. * The current value of the runtime animation
  9668. */
  9669. private _currentValue;
  9670. /** @hidden */
  9671. _animationState: _IAnimationState;
  9672. /**
  9673. * The active target of the runtime animation
  9674. */
  9675. private _activeTargets;
  9676. private _currentActiveTarget;
  9677. private _directTarget;
  9678. /**
  9679. * The target path of the runtime animation
  9680. */
  9681. private _targetPath;
  9682. /**
  9683. * The weight of the runtime animation
  9684. */
  9685. private _weight;
  9686. /**
  9687. * The ratio offset of the runtime animation
  9688. */
  9689. private _ratioOffset;
  9690. /**
  9691. * The previous delay of the runtime animation
  9692. */
  9693. private _previousDelay;
  9694. /**
  9695. * The previous ratio of the runtime animation
  9696. */
  9697. private _previousRatio;
  9698. private _enableBlending;
  9699. private _keys;
  9700. private _minFrame;
  9701. private _maxFrame;
  9702. private _minValue;
  9703. private _maxValue;
  9704. private _targetIsArray;
  9705. /**
  9706. * Gets the current frame of the runtime animation
  9707. */
  9708. readonly currentFrame: number;
  9709. /**
  9710. * Gets the weight of the runtime animation
  9711. */
  9712. readonly weight: number;
  9713. /**
  9714. * Gets the current value of the runtime animation
  9715. */
  9716. readonly currentValue: any;
  9717. /**
  9718. * Gets the target path of the runtime animation
  9719. */
  9720. readonly targetPath: string;
  9721. /**
  9722. * Gets the actual target of the runtime animation
  9723. */
  9724. readonly target: any;
  9725. /** @hidden */
  9726. _onLoop: () => void;
  9727. /**
  9728. * Create a new RuntimeAnimation object
  9729. * @param target defines the target of the animation
  9730. * @param animation defines the source animation object
  9731. * @param scene defines the hosting scene
  9732. * @param host defines the initiating Animatable
  9733. */
  9734. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9735. private _preparePath;
  9736. /**
  9737. * Gets the animation from the runtime animation
  9738. */
  9739. readonly animation: Animation;
  9740. /**
  9741. * Resets the runtime animation to the beginning
  9742. * @param restoreOriginal defines whether to restore the target property to the original value
  9743. */
  9744. reset(restoreOriginal?: boolean): void;
  9745. /**
  9746. * Specifies if the runtime animation is stopped
  9747. * @returns Boolean specifying if the runtime animation is stopped
  9748. */
  9749. isStopped(): boolean;
  9750. /**
  9751. * Disposes of the runtime animation
  9752. */
  9753. dispose(): void;
  9754. /**
  9755. * Apply the interpolated value to the target
  9756. * @param currentValue defines the value computed by the animation
  9757. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9758. */
  9759. setValue(currentValue: any, weight: number): void;
  9760. private _getOriginalValues;
  9761. private _setValue;
  9762. /**
  9763. * Gets the loop pmode of the runtime animation
  9764. * @returns Loop Mode
  9765. */
  9766. private _getCorrectLoopMode;
  9767. /**
  9768. * Move the current animation to a given frame
  9769. * @param frame defines the frame to move to
  9770. */
  9771. goToFrame(frame: number): void;
  9772. /**
  9773. * @hidden Internal use only
  9774. */
  9775. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9776. /**
  9777. * Execute the current animation
  9778. * @param delay defines the delay to add to the current frame
  9779. * @param from defines the lower bound of the animation range
  9780. * @param to defines the upper bound of the animation range
  9781. * @param loop defines if the current animation must loop
  9782. * @param speedRatio defines the current speed ratio
  9783. * @param weight defines the weight of the animation (default is -1 so no weight)
  9784. * @param onLoop optional callback called when animation loops
  9785. * @returns a boolean indicating if the animation is running
  9786. */
  9787. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9788. }
  9789. }
  9790. declare module "babylonjs/Animations/animatable" {
  9791. import { Animation } from "babylonjs/Animations/animation";
  9792. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9793. import { Nullable } from "babylonjs/types";
  9794. import { Observable } from "babylonjs/Misc/observable";
  9795. import { Scene } from "babylonjs/scene";
  9796. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9797. import { Node } from "babylonjs/node";
  9798. /**
  9799. * Class used to store an actual running animation
  9800. */
  9801. export class Animatable {
  9802. /** defines the target object */
  9803. target: any;
  9804. /** defines the starting frame number (default is 0) */
  9805. fromFrame: number;
  9806. /** defines the ending frame number (default is 100) */
  9807. toFrame: number;
  9808. /** defines if the animation must loop (default is false) */
  9809. loopAnimation: boolean;
  9810. /** defines a callback to call when animation ends if it is not looping */
  9811. onAnimationEnd?: (() => void) | null | undefined;
  9812. /** defines a callback to call when animation loops */
  9813. onAnimationLoop?: (() => void) | null | undefined;
  9814. private _localDelayOffset;
  9815. private _pausedDelay;
  9816. private _runtimeAnimations;
  9817. private _paused;
  9818. private _scene;
  9819. private _speedRatio;
  9820. private _weight;
  9821. private _syncRoot;
  9822. /**
  9823. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9824. * This will only apply for non looping animation (default is true)
  9825. */
  9826. disposeOnEnd: boolean;
  9827. /**
  9828. * Gets a boolean indicating if the animation has started
  9829. */
  9830. animationStarted: boolean;
  9831. /**
  9832. * Observer raised when the animation ends
  9833. */
  9834. onAnimationEndObservable: Observable<Animatable>;
  9835. /**
  9836. * Observer raised when the animation loops
  9837. */
  9838. onAnimationLoopObservable: Observable<Animatable>;
  9839. /**
  9840. * Gets the root Animatable used to synchronize and normalize animations
  9841. */
  9842. readonly syncRoot: Nullable<Animatable>;
  9843. /**
  9844. * Gets the current frame of the first RuntimeAnimation
  9845. * Used to synchronize Animatables
  9846. */
  9847. readonly masterFrame: number;
  9848. /**
  9849. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9850. */
  9851. weight: number;
  9852. /**
  9853. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9854. */
  9855. speedRatio: number;
  9856. /**
  9857. * Creates a new Animatable
  9858. * @param scene defines the hosting scene
  9859. * @param target defines the target object
  9860. * @param fromFrame defines the starting frame number (default is 0)
  9861. * @param toFrame defines the ending frame number (default is 100)
  9862. * @param loopAnimation defines if the animation must loop (default is false)
  9863. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9864. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9865. * @param animations defines a group of animation to add to the new Animatable
  9866. * @param onAnimationLoop defines a callback to call when animation loops
  9867. */
  9868. constructor(scene: Scene,
  9869. /** defines the target object */
  9870. target: any,
  9871. /** defines the starting frame number (default is 0) */
  9872. fromFrame?: number,
  9873. /** defines the ending frame number (default is 100) */
  9874. toFrame?: number,
  9875. /** defines if the animation must loop (default is false) */
  9876. loopAnimation?: boolean, speedRatio?: number,
  9877. /** defines a callback to call when animation ends if it is not looping */
  9878. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9879. /** defines a callback to call when animation loops */
  9880. onAnimationLoop?: (() => void) | null | undefined);
  9881. /**
  9882. * Synchronize and normalize current Animatable with a source Animatable
  9883. * This is useful when using animation weights and when animations are not of the same length
  9884. * @param root defines the root Animatable to synchronize with
  9885. * @returns the current Animatable
  9886. */
  9887. syncWith(root: Animatable): Animatable;
  9888. /**
  9889. * Gets the list of runtime animations
  9890. * @returns an array of RuntimeAnimation
  9891. */
  9892. getAnimations(): RuntimeAnimation[];
  9893. /**
  9894. * Adds more animations to the current animatable
  9895. * @param target defines the target of the animations
  9896. * @param animations defines the new animations to add
  9897. */
  9898. appendAnimations(target: any, animations: Animation[]): void;
  9899. /**
  9900. * Gets the source animation for a specific property
  9901. * @param property defines the propertyu to look for
  9902. * @returns null or the source animation for the given property
  9903. */
  9904. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9905. /**
  9906. * Gets the runtime animation for a specific property
  9907. * @param property defines the propertyu to look for
  9908. * @returns null or the runtime animation for the given property
  9909. */
  9910. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9911. /**
  9912. * Resets the animatable to its original state
  9913. */
  9914. reset(): void;
  9915. /**
  9916. * Allows the animatable to blend with current running animations
  9917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9918. * @param blendingSpeed defines the blending speed to use
  9919. */
  9920. enableBlending(blendingSpeed: number): void;
  9921. /**
  9922. * Disable animation blending
  9923. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9924. */
  9925. disableBlending(): void;
  9926. /**
  9927. * Jump directly to a given frame
  9928. * @param frame defines the frame to jump to
  9929. */
  9930. goToFrame(frame: number): void;
  9931. /**
  9932. * Pause the animation
  9933. */
  9934. pause(): void;
  9935. /**
  9936. * Restart the animation
  9937. */
  9938. restart(): void;
  9939. private _raiseOnAnimationEnd;
  9940. /**
  9941. * Stop and delete the current animation
  9942. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9943. * @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)
  9944. */
  9945. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9946. /**
  9947. * Wait asynchronously for the animation to end
  9948. * @returns a promise which will be fullfilled when the animation ends
  9949. */
  9950. waitAsync(): Promise<Animatable>;
  9951. /** @hidden */
  9952. _animate(delay: number): boolean;
  9953. }
  9954. module "babylonjs/scene" {
  9955. interface Scene {
  9956. /** @hidden */
  9957. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9958. /** @hidden */
  9959. _processLateAnimationBindingsForMatrices(holder: {
  9960. totalWeight: number;
  9961. animations: RuntimeAnimation[];
  9962. originalValue: Matrix;
  9963. }): any;
  9964. /** @hidden */
  9965. _processLateAnimationBindingsForQuaternions(holder: {
  9966. totalWeight: number;
  9967. animations: RuntimeAnimation[];
  9968. originalValue: Quaternion;
  9969. }, refQuaternion: Quaternion): Quaternion;
  9970. /** @hidden */
  9971. _processLateAnimationBindings(): void;
  9972. /**
  9973. * Will start the animation sequence of a given target
  9974. * @param target defines the target
  9975. * @param from defines from which frame should animation start
  9976. * @param to defines until which frame should animation run.
  9977. * @param weight defines the weight to apply to the animation (1.0 by default)
  9978. * @param loop defines if the animation loops
  9979. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9980. * @param onAnimationEnd defines the function to be executed when the animation ends
  9981. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9982. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9983. * @param onAnimationLoop defines the callback to call when an animation loops
  9984. * @returns the animatable object created for this animation
  9985. */
  9986. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9987. /**
  9988. * Will start the animation sequence of a given target
  9989. * @param target defines the target
  9990. * @param from defines from which frame should animation start
  9991. * @param to defines until which frame should animation run.
  9992. * @param loop defines if the animation loops
  9993. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9994. * @param onAnimationEnd defines the function to be executed when the animation ends
  9995. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9996. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9997. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9998. * @param onAnimationLoop defines the callback to call when an animation loops
  9999. * @returns the animatable object created for this animation
  10000. */
  10001. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10002. /**
  10003. * Will start the animation sequence of a given target and its hierarchy
  10004. * @param target defines the target
  10005. * @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.
  10006. * @param from defines from which frame should animation start
  10007. * @param to defines until which frame should animation run.
  10008. * @param loop defines if the animation loops
  10009. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10010. * @param onAnimationEnd defines the function to be executed when the animation ends
  10011. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10012. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10013. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10014. * @param onAnimationLoop defines the callback to call when an animation loops
  10015. * @returns the list of created animatables
  10016. */
  10017. 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[];
  10018. /**
  10019. * Begin a new animation on a given node
  10020. * @param target defines the target where the animation will take place
  10021. * @param animations defines the list of animations to start
  10022. * @param from defines the initial value
  10023. * @param to defines the final value
  10024. * @param loop defines if you want animation to loop (off by default)
  10025. * @param speedRatio defines the speed ratio to apply to all animations
  10026. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10027. * @param onAnimationLoop defines the callback to call when an animation loops
  10028. * @returns the list of created animatables
  10029. */
  10030. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10031. /**
  10032. * Begin a new animation on a given node and its hierarchy
  10033. * @param target defines the root node where the animation will take place
  10034. * @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.
  10035. * @param animations defines the list of animations to start
  10036. * @param from defines the initial value
  10037. * @param to defines the final value
  10038. * @param loop defines if you want animation to loop (off by default)
  10039. * @param speedRatio defines the speed ratio to apply to all animations
  10040. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10041. * @param onAnimationLoop defines the callback to call when an animation loops
  10042. * @returns the list of animatables created for all nodes
  10043. */
  10044. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10045. /**
  10046. * Gets the animatable associated with a specific target
  10047. * @param target defines the target of the animatable
  10048. * @returns the required animatable if found
  10049. */
  10050. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10051. /**
  10052. * Gets all animatables associated with a given target
  10053. * @param target defines the target to look animatables for
  10054. * @returns an array of Animatables
  10055. */
  10056. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10057. /**
  10058. * Stops and removes all animations that have been applied to the scene
  10059. */
  10060. stopAllAnimations(): void;
  10061. }
  10062. }
  10063. module "babylonjs/Bones/bone" {
  10064. interface Bone {
  10065. /**
  10066. * Copy an animation range from another bone
  10067. * @param source defines the source bone
  10068. * @param rangeName defines the range name to copy
  10069. * @param frameOffset defines the frame offset
  10070. * @param rescaleAsRequired defines if rescaling must be applied if required
  10071. * @param skelDimensionsRatio defines the scaling ratio
  10072. * @returns true if operation was successful
  10073. */
  10074. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10075. }
  10076. }
  10077. }
  10078. declare module "babylonjs/Bones/skeleton" {
  10079. import { Bone } from "babylonjs/Bones/bone";
  10080. import { IAnimatable } from "babylonjs/Misc/tools";
  10081. import { Observable } from "babylonjs/Misc/observable";
  10082. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10083. import { Scene } from "babylonjs/scene";
  10084. import { Nullable } from "babylonjs/types";
  10085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10086. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10087. import { Animatable } from "babylonjs/Animations/animatable";
  10088. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10089. import { Animation } from "babylonjs/Animations/animation";
  10090. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10091. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10092. /**
  10093. * Class used to handle skinning animations
  10094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10095. */
  10096. export class Skeleton implements IAnimatable {
  10097. /** defines the skeleton name */
  10098. name: string;
  10099. /** defines the skeleton Id */
  10100. id: string;
  10101. /**
  10102. * Defines the list of child bones
  10103. */
  10104. bones: Bone[];
  10105. /**
  10106. * Defines an estimate of the dimension of the skeleton at rest
  10107. */
  10108. dimensionsAtRest: Vector3;
  10109. /**
  10110. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10111. */
  10112. needInitialSkinMatrix: boolean;
  10113. /**
  10114. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10115. */
  10116. overrideMesh: Nullable<AbstractMesh>;
  10117. /**
  10118. * Gets the list of animations attached to this skeleton
  10119. */
  10120. animations: Array<Animation>;
  10121. private _scene;
  10122. private _isDirty;
  10123. private _transformMatrices;
  10124. private _transformMatrixTexture;
  10125. private _meshesWithPoseMatrix;
  10126. private _animatables;
  10127. private _identity;
  10128. private _synchronizedWithMesh;
  10129. private _ranges;
  10130. private _lastAbsoluteTransformsUpdateId;
  10131. private _canUseTextureForBones;
  10132. private _uniqueId;
  10133. /** @hidden */
  10134. _numBonesWithLinkedTransformNode: number;
  10135. /** @hidden */
  10136. _hasWaitingData: Nullable<boolean>;
  10137. /**
  10138. * Specifies if the skeleton should be serialized
  10139. */
  10140. doNotSerialize: boolean;
  10141. private _useTextureToStoreBoneMatrices;
  10142. /**
  10143. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10144. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10145. */
  10146. useTextureToStoreBoneMatrices: boolean;
  10147. private _animationPropertiesOverride;
  10148. /**
  10149. * Gets or sets the animation properties override
  10150. */
  10151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10152. /**
  10153. * List of inspectable custom properties (used by the Inspector)
  10154. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10155. */
  10156. inspectableCustomProperties: IInspectable[];
  10157. /**
  10158. * An observable triggered before computing the skeleton's matrices
  10159. */
  10160. onBeforeComputeObservable: Observable<Skeleton>;
  10161. /**
  10162. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10163. */
  10164. readonly isUsingTextureForMatrices: boolean;
  10165. /**
  10166. * Gets the unique ID of this skeleton
  10167. */
  10168. readonly uniqueId: number;
  10169. /**
  10170. * Creates a new skeleton
  10171. * @param name defines the skeleton name
  10172. * @param id defines the skeleton Id
  10173. * @param scene defines the hosting scene
  10174. */
  10175. constructor(
  10176. /** defines the skeleton name */
  10177. name: string,
  10178. /** defines the skeleton Id */
  10179. id: string, scene: Scene);
  10180. /**
  10181. * Gets the current object class name.
  10182. * @return the class name
  10183. */
  10184. getClassName(): string;
  10185. /**
  10186. * Returns an array containing the root bones
  10187. * @returns an array containing the root bones
  10188. */
  10189. getChildren(): Array<Bone>;
  10190. /**
  10191. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10192. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10193. * @returns a Float32Array containing matrices data
  10194. */
  10195. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10196. /**
  10197. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10198. * @returns a raw texture containing the data
  10199. */
  10200. getTransformMatrixTexture(): Nullable<RawTexture>;
  10201. /**
  10202. * Gets the current hosting scene
  10203. * @returns a scene object
  10204. */
  10205. getScene(): Scene;
  10206. /**
  10207. * Gets a string representing the current skeleton data
  10208. * @param fullDetails defines a boolean indicating if we want a verbose version
  10209. * @returns a string representing the current skeleton data
  10210. */
  10211. toString(fullDetails?: boolean): string;
  10212. /**
  10213. * Get bone's index searching by name
  10214. * @param name defines bone's name to search for
  10215. * @return the indice of the bone. Returns -1 if not found
  10216. */
  10217. getBoneIndexByName(name: string): number;
  10218. /**
  10219. * Creater a new animation range
  10220. * @param name defines the name of the range
  10221. * @param from defines the start key
  10222. * @param to defines the end key
  10223. */
  10224. createAnimationRange(name: string, from: number, to: number): void;
  10225. /**
  10226. * Delete a specific animation range
  10227. * @param name defines the name of the range
  10228. * @param deleteFrames defines if frames must be removed as well
  10229. */
  10230. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10231. /**
  10232. * Gets a specific animation range
  10233. * @param name defines the name of the range to look for
  10234. * @returns the requested animation range or null if not found
  10235. */
  10236. getAnimationRange(name: string): Nullable<AnimationRange>;
  10237. /**
  10238. * Gets the list of all animation ranges defined on this skeleton
  10239. * @returns an array
  10240. */
  10241. getAnimationRanges(): Nullable<AnimationRange>[];
  10242. /**
  10243. * Copy animation range from a source skeleton.
  10244. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10245. * @param source defines the source skeleton
  10246. * @param name defines the name of the range to copy
  10247. * @param rescaleAsRequired defines if rescaling must be applied if required
  10248. * @returns true if operation was successful
  10249. */
  10250. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10251. /**
  10252. * Forces the skeleton to go to rest pose
  10253. */
  10254. returnToRest(): void;
  10255. private _getHighestAnimationFrame;
  10256. /**
  10257. * Begin a specific animation range
  10258. * @param name defines the name of the range to start
  10259. * @param loop defines if looping must be turned on (false by default)
  10260. * @param speedRatio defines the speed ratio to apply (1 by default)
  10261. * @param onAnimationEnd defines a callback which will be called when animation will end
  10262. * @returns a new animatable
  10263. */
  10264. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10265. /** @hidden */
  10266. _markAsDirty(): void;
  10267. /** @hidden */
  10268. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10269. /** @hidden */
  10270. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10271. private _computeTransformMatrices;
  10272. /**
  10273. * Build all resources required to render a skeleton
  10274. */
  10275. prepare(): void;
  10276. /**
  10277. * Gets the list of animatables currently running for this skeleton
  10278. * @returns an array of animatables
  10279. */
  10280. getAnimatables(): IAnimatable[];
  10281. /**
  10282. * Clone the current skeleton
  10283. * @param name defines the name of the new skeleton
  10284. * @param id defines the id of the new skeleton
  10285. * @returns the new skeleton
  10286. */
  10287. clone(name: string, id: string): Skeleton;
  10288. /**
  10289. * Enable animation blending for this skeleton
  10290. * @param blendingSpeed defines the blending speed to apply
  10291. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10292. */
  10293. enableBlending(blendingSpeed?: number): void;
  10294. /**
  10295. * Releases all resources associated with the current skeleton
  10296. */
  10297. dispose(): void;
  10298. /**
  10299. * Serialize the skeleton in a JSON object
  10300. * @returns a JSON object
  10301. */
  10302. serialize(): any;
  10303. /**
  10304. * Creates a new skeleton from serialized data
  10305. * @param parsedSkeleton defines the serialized data
  10306. * @param scene defines the hosting scene
  10307. * @returns a new skeleton
  10308. */
  10309. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10310. /**
  10311. * Compute all node absolute transforms
  10312. * @param forceUpdate defines if computation must be done even if cache is up to date
  10313. */
  10314. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10315. /**
  10316. * Gets the root pose matrix
  10317. * @returns a matrix
  10318. */
  10319. getPoseMatrix(): Nullable<Matrix>;
  10320. /**
  10321. * Sorts bones per internal index
  10322. */
  10323. sortBones(): void;
  10324. private _sortBones;
  10325. }
  10326. }
  10327. declare module "babylonjs/Morph/morphTarget" {
  10328. import { IAnimatable } from "babylonjs/Misc/tools";
  10329. import { Observable } from "babylonjs/Misc/observable";
  10330. import { Nullable, FloatArray } from "babylonjs/types";
  10331. import { Scene } from "babylonjs/scene";
  10332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10334. /**
  10335. * Defines a target to use with MorphTargetManager
  10336. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10337. */
  10338. export class MorphTarget implements IAnimatable {
  10339. /** defines the name of the target */
  10340. name: string;
  10341. /**
  10342. * Gets or sets the list of animations
  10343. */
  10344. animations: import("babylonjs/Animations/animation").Animation[];
  10345. private _scene;
  10346. private _positions;
  10347. private _normals;
  10348. private _tangents;
  10349. private _uvs;
  10350. private _influence;
  10351. /**
  10352. * Observable raised when the influence changes
  10353. */
  10354. onInfluenceChanged: Observable<boolean>;
  10355. /** @hidden */
  10356. _onDataLayoutChanged: Observable<void>;
  10357. /**
  10358. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10359. */
  10360. influence: number;
  10361. /**
  10362. * Gets or sets the id of the morph Target
  10363. */
  10364. id: string;
  10365. private _animationPropertiesOverride;
  10366. /**
  10367. * Gets or sets the animation properties override
  10368. */
  10369. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10370. /**
  10371. * Creates a new MorphTarget
  10372. * @param name defines the name of the target
  10373. * @param influence defines the influence to use
  10374. * @param scene defines the scene the morphtarget belongs to
  10375. */
  10376. constructor(
  10377. /** defines the name of the target */
  10378. name: string, influence?: number, scene?: Nullable<Scene>);
  10379. /**
  10380. * Gets a boolean defining if the target contains position data
  10381. */
  10382. readonly hasPositions: boolean;
  10383. /**
  10384. * Gets a boolean defining if the target contains normal data
  10385. */
  10386. readonly hasNormals: boolean;
  10387. /**
  10388. * Gets a boolean defining if the target contains tangent data
  10389. */
  10390. readonly hasTangents: boolean;
  10391. /**
  10392. * Gets a boolean defining if the target contains texture coordinates data
  10393. */
  10394. readonly hasUVs: boolean;
  10395. /**
  10396. * Affects position data to this target
  10397. * @param data defines the position data to use
  10398. */
  10399. setPositions(data: Nullable<FloatArray>): void;
  10400. /**
  10401. * Gets the position data stored in this target
  10402. * @returns a FloatArray containing the position data (or null if not present)
  10403. */
  10404. getPositions(): Nullable<FloatArray>;
  10405. /**
  10406. * Affects normal data to this target
  10407. * @param data defines the normal data to use
  10408. */
  10409. setNormals(data: Nullable<FloatArray>): void;
  10410. /**
  10411. * Gets the normal data stored in this target
  10412. * @returns a FloatArray containing the normal data (or null if not present)
  10413. */
  10414. getNormals(): Nullable<FloatArray>;
  10415. /**
  10416. * Affects tangent data to this target
  10417. * @param data defines the tangent data to use
  10418. */
  10419. setTangents(data: Nullable<FloatArray>): void;
  10420. /**
  10421. * Gets the tangent data stored in this target
  10422. * @returns a FloatArray containing the tangent data (or null if not present)
  10423. */
  10424. getTangents(): Nullable<FloatArray>;
  10425. /**
  10426. * Affects texture coordinates data to this target
  10427. * @param data defines the texture coordinates data to use
  10428. */
  10429. setUVs(data: Nullable<FloatArray>): void;
  10430. /**
  10431. * Gets the texture coordinates data stored in this target
  10432. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10433. */
  10434. getUVs(): Nullable<FloatArray>;
  10435. /**
  10436. * Serializes the current target into a Serialization object
  10437. * @returns the serialized object
  10438. */
  10439. serialize(): any;
  10440. /**
  10441. * Returns the string "MorphTarget"
  10442. * @returns "MorphTarget"
  10443. */
  10444. getClassName(): string;
  10445. /**
  10446. * Creates a new target from serialized data
  10447. * @param serializationObject defines the serialized data to use
  10448. * @returns a new MorphTarget
  10449. */
  10450. static Parse(serializationObject: any): MorphTarget;
  10451. /**
  10452. * Creates a MorphTarget from mesh data
  10453. * @param mesh defines the source mesh
  10454. * @param name defines the name to use for the new target
  10455. * @param influence defines the influence to attach to the target
  10456. * @returns a new MorphTarget
  10457. */
  10458. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10459. }
  10460. }
  10461. declare module "babylonjs/Morph/morphTargetManager" {
  10462. import { Nullable } from "babylonjs/types";
  10463. import { Scene } from "babylonjs/scene";
  10464. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10465. /**
  10466. * This class is used to deform meshes using morphing between different targets
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10468. */
  10469. export class MorphTargetManager {
  10470. private _targets;
  10471. private _targetInfluenceChangedObservers;
  10472. private _targetDataLayoutChangedObservers;
  10473. private _activeTargets;
  10474. private _scene;
  10475. private _influences;
  10476. private _supportsNormals;
  10477. private _supportsTangents;
  10478. private _supportsUVs;
  10479. private _vertexCount;
  10480. private _uniqueId;
  10481. private _tempInfluences;
  10482. /**
  10483. * Creates a new MorphTargetManager
  10484. * @param scene defines the current scene
  10485. */
  10486. constructor(scene?: Nullable<Scene>);
  10487. /**
  10488. * Gets the unique ID of this manager
  10489. */
  10490. readonly uniqueId: number;
  10491. /**
  10492. * Gets the number of vertices handled by this manager
  10493. */
  10494. readonly vertexCount: number;
  10495. /**
  10496. * Gets a boolean indicating if this manager supports morphing of normals
  10497. */
  10498. readonly supportsNormals: boolean;
  10499. /**
  10500. * Gets a boolean indicating if this manager supports morphing of tangents
  10501. */
  10502. readonly supportsTangents: boolean;
  10503. /**
  10504. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10505. */
  10506. readonly supportsUVs: boolean;
  10507. /**
  10508. * Gets the number of targets stored in this manager
  10509. */
  10510. readonly numTargets: number;
  10511. /**
  10512. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10513. */
  10514. readonly numInfluencers: number;
  10515. /**
  10516. * Gets the list of influences (one per target)
  10517. */
  10518. readonly influences: Float32Array;
  10519. /**
  10520. * Gets the active target at specified index. An active target is a target with an influence > 0
  10521. * @param index defines the index to check
  10522. * @returns the requested target
  10523. */
  10524. getActiveTarget(index: number): MorphTarget;
  10525. /**
  10526. * Gets the target at specified index
  10527. * @param index defines the index to check
  10528. * @returns the requested target
  10529. */
  10530. getTarget(index: number): MorphTarget;
  10531. /**
  10532. * Add a new target to this manager
  10533. * @param target defines the target to add
  10534. */
  10535. addTarget(target: MorphTarget): void;
  10536. /**
  10537. * Removes a target from the manager
  10538. * @param target defines the target to remove
  10539. */
  10540. removeTarget(target: MorphTarget): void;
  10541. /**
  10542. * Serializes the current manager into a Serialization object
  10543. * @returns the serialized object
  10544. */
  10545. serialize(): any;
  10546. private _syncActiveTargets;
  10547. /**
  10548. * Syncrhonize the targets with all the meshes using this morph target manager
  10549. */
  10550. synchronize(): void;
  10551. /**
  10552. * Creates a new MorphTargetManager from serialized data
  10553. * @param serializationObject defines the serialized data
  10554. * @param scene defines the hosting scene
  10555. * @returns the new MorphTargetManager
  10556. */
  10557. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10558. }
  10559. }
  10560. declare module "babylonjs/sceneComponent" {
  10561. import { Scene } from "babylonjs/scene";
  10562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10564. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10565. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10566. import { Nullable } from "babylonjs/types";
  10567. import { Camera } from "babylonjs/Cameras/camera";
  10568. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10569. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10570. import { AbstractScene } from "babylonjs/abstractScene";
  10571. /**
  10572. * Groups all the scene component constants in one place to ease maintenance.
  10573. * @hidden
  10574. */
  10575. export class SceneComponentConstants {
  10576. static readonly NAME_EFFECTLAYER: string;
  10577. static readonly NAME_LAYER: string;
  10578. static readonly NAME_LENSFLARESYSTEM: string;
  10579. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10580. static readonly NAME_PARTICLESYSTEM: string;
  10581. static readonly NAME_GAMEPAD: string;
  10582. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10583. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10584. static readonly NAME_DEPTHRENDERER: string;
  10585. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10586. static readonly NAME_SPRITE: string;
  10587. static readonly NAME_OUTLINERENDERER: string;
  10588. static readonly NAME_PROCEDURALTEXTURE: string;
  10589. static readonly NAME_SHADOWGENERATOR: string;
  10590. static readonly NAME_OCTREE: string;
  10591. static readonly NAME_PHYSICSENGINE: string;
  10592. static readonly NAME_AUDIO: string;
  10593. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10594. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10595. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10596. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10597. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10598. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10599. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10600. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10601. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10602. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10603. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10604. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10605. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10606. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10607. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10608. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10609. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10610. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10611. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10612. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10613. static readonly STEP_AFTERRENDER_AUDIO: number;
  10614. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10615. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10616. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10617. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10618. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10619. static readonly STEP_POINTERMOVE_SPRITE: number;
  10620. static readonly STEP_POINTERDOWN_SPRITE: number;
  10621. static readonly STEP_POINTERUP_SPRITE: number;
  10622. }
  10623. /**
  10624. * This represents a scene component.
  10625. *
  10626. * This is used to decouple the dependency the scene is having on the different workloads like
  10627. * layers, post processes...
  10628. */
  10629. export interface ISceneComponent {
  10630. /**
  10631. * The name of the component. Each component must have a unique name.
  10632. */
  10633. name: string;
  10634. /**
  10635. * The scene the component belongs to.
  10636. */
  10637. scene: Scene;
  10638. /**
  10639. * Register the component to one instance of a scene.
  10640. */
  10641. register(): void;
  10642. /**
  10643. * Rebuilds the elements related to this component in case of
  10644. * context lost for instance.
  10645. */
  10646. rebuild(): void;
  10647. /**
  10648. * Disposes the component and the associated ressources.
  10649. */
  10650. dispose(): void;
  10651. }
  10652. /**
  10653. * This represents a SERIALIZABLE scene component.
  10654. *
  10655. * This extends Scene Component to add Serialization methods on top.
  10656. */
  10657. export interface ISceneSerializableComponent extends ISceneComponent {
  10658. /**
  10659. * Adds all the elements from the container to the scene
  10660. * @param container the container holding the elements
  10661. */
  10662. addFromContainer(container: AbstractScene): void;
  10663. /**
  10664. * Removes all the elements in the container from the scene
  10665. * @param container contains the elements to remove
  10666. * @param dispose if the removed element should be disposed (default: false)
  10667. */
  10668. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10669. /**
  10670. * Serializes the component data to the specified json object
  10671. * @param serializationObject The object to serialize to
  10672. */
  10673. serialize(serializationObject: any): void;
  10674. }
  10675. /**
  10676. * Strong typing of a Mesh related stage step action
  10677. */
  10678. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10679. /**
  10680. * Strong typing of a Evaluate Sub Mesh related stage step action
  10681. */
  10682. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10683. /**
  10684. * Strong typing of a Active Mesh related stage step action
  10685. */
  10686. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10687. /**
  10688. * Strong typing of a Camera related stage step action
  10689. */
  10690. export type CameraStageAction = (camera: Camera) => void;
  10691. /**
  10692. * Strong typing of a Camera Frame buffer related stage step action
  10693. */
  10694. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10695. /**
  10696. * Strong typing of a Render Target related stage step action
  10697. */
  10698. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10699. /**
  10700. * Strong typing of a RenderingGroup related stage step action
  10701. */
  10702. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10703. /**
  10704. * Strong typing of a Mesh Render related stage step action
  10705. */
  10706. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10707. /**
  10708. * Strong typing of a simple stage step action
  10709. */
  10710. export type SimpleStageAction = () => void;
  10711. /**
  10712. * Strong typing of a render target action.
  10713. */
  10714. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10715. /**
  10716. * Strong typing of a pointer move action.
  10717. */
  10718. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10719. /**
  10720. * Strong typing of a pointer up/down action.
  10721. */
  10722. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10723. /**
  10724. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10725. * @hidden
  10726. */
  10727. export class Stage<T extends Function> extends Array<{
  10728. index: number;
  10729. component: ISceneComponent;
  10730. action: T;
  10731. }> {
  10732. /**
  10733. * Hide ctor from the rest of the world.
  10734. * @param items The items to add.
  10735. */
  10736. private constructor();
  10737. /**
  10738. * Creates a new Stage.
  10739. * @returns A new instance of a Stage
  10740. */
  10741. static Create<T extends Function>(): Stage<T>;
  10742. /**
  10743. * Registers a step in an ordered way in the targeted stage.
  10744. * @param index Defines the position to register the step in
  10745. * @param component Defines the component attached to the step
  10746. * @param action Defines the action to launch during the step
  10747. */
  10748. registerStep(index: number, component: ISceneComponent, action: T): void;
  10749. /**
  10750. * Clears all the steps from the stage.
  10751. */
  10752. clear(): void;
  10753. }
  10754. }
  10755. declare module "babylonjs/Meshes/meshLODLevel" {
  10756. import { Mesh } from "babylonjs/Meshes/mesh";
  10757. import { Nullable } from "babylonjs/types";
  10758. /**
  10759. * Class used to represent a specific level of detail of a mesh
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10761. */
  10762. export class MeshLODLevel {
  10763. /** Defines the distance where this level should star being displayed */
  10764. distance: number;
  10765. /** Defines the mesh to use to render this level */
  10766. mesh: Nullable<Mesh>;
  10767. /**
  10768. * Creates a new LOD level
  10769. * @param distance defines the distance where this level should star being displayed
  10770. * @param mesh defines the mesh to use to render this level
  10771. */
  10772. constructor(
  10773. /** Defines the distance where this level should star being displayed */
  10774. distance: number,
  10775. /** Defines the mesh to use to render this level */
  10776. mesh: Nullable<Mesh>);
  10777. }
  10778. }
  10779. declare module "babylonjs/Lights/shadowLight" {
  10780. import { Camera } from "babylonjs/Cameras/camera";
  10781. import { Scene } from "babylonjs/scene";
  10782. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10784. import { Light } from "babylonjs/Lights/light";
  10785. /**
  10786. * Interface describing all the common properties and methods a shadow light needs to implement.
  10787. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10788. * as well as binding the different shadow properties to the effects.
  10789. */
  10790. export interface IShadowLight extends Light {
  10791. /**
  10792. * The light id in the scene (used in scene.findLighById for instance)
  10793. */
  10794. id: string;
  10795. /**
  10796. * The position the shdow will be casted from.
  10797. */
  10798. position: Vector3;
  10799. /**
  10800. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10801. */
  10802. direction: Vector3;
  10803. /**
  10804. * The transformed position. Position of the light in world space taking parenting in account.
  10805. */
  10806. transformedPosition: Vector3;
  10807. /**
  10808. * The transformed direction. Direction of the light in world space taking parenting in account.
  10809. */
  10810. transformedDirection: Vector3;
  10811. /**
  10812. * The friendly name of the light in the scene.
  10813. */
  10814. name: string;
  10815. /**
  10816. * Defines the shadow projection clipping minimum z value.
  10817. */
  10818. shadowMinZ: number;
  10819. /**
  10820. * Defines the shadow projection clipping maximum z value.
  10821. */
  10822. shadowMaxZ: number;
  10823. /**
  10824. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10825. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10826. */
  10827. computeTransformedInformation(): boolean;
  10828. /**
  10829. * Gets the scene the light belongs to.
  10830. * @returns The scene
  10831. */
  10832. getScene(): Scene;
  10833. /**
  10834. * Callback defining a custom Projection Matrix Builder.
  10835. * This can be used to override the default projection matrix computation.
  10836. */
  10837. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10838. /**
  10839. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10840. * @param matrix The materix to updated with the projection information
  10841. * @param viewMatrix The transform matrix of the light
  10842. * @param renderList The list of mesh to render in the map
  10843. * @returns The current light
  10844. */
  10845. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10846. /**
  10847. * Gets the current depth scale used in ESM.
  10848. * @returns The scale
  10849. */
  10850. getDepthScale(): number;
  10851. /**
  10852. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10853. * @returns true if a cube texture needs to be use
  10854. */
  10855. needCube(): boolean;
  10856. /**
  10857. * Detects if the projection matrix requires to be recomputed this frame.
  10858. * @returns true if it requires to be recomputed otherwise, false.
  10859. */
  10860. needProjectionMatrixCompute(): boolean;
  10861. /**
  10862. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10863. */
  10864. forceProjectionMatrixCompute(): void;
  10865. /**
  10866. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10867. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10868. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10869. */
  10870. getShadowDirection(faceIndex?: number): Vector3;
  10871. /**
  10872. * Gets the minZ used for shadow according to both the scene and the light.
  10873. * @param activeCamera The camera we are returning the min for
  10874. * @returns the depth min z
  10875. */
  10876. getDepthMinZ(activeCamera: Camera): number;
  10877. /**
  10878. * Gets the maxZ used for shadow according to both the scene and the light.
  10879. * @param activeCamera The camera we are returning the max for
  10880. * @returns the depth max z
  10881. */
  10882. getDepthMaxZ(activeCamera: Camera): number;
  10883. }
  10884. /**
  10885. * Base implementation IShadowLight
  10886. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10887. */
  10888. export abstract class ShadowLight extends Light implements IShadowLight {
  10889. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10890. protected _position: Vector3;
  10891. protected _setPosition(value: Vector3): void;
  10892. /**
  10893. * Sets the position the shadow will be casted from. Also use as the light position for both
  10894. * point and spot lights.
  10895. */
  10896. /**
  10897. * Sets the position the shadow will be casted from. Also use as the light position for both
  10898. * point and spot lights.
  10899. */
  10900. position: Vector3;
  10901. protected _direction: Vector3;
  10902. protected _setDirection(value: Vector3): void;
  10903. /**
  10904. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10905. * Also use as the light direction on spot and directional lights.
  10906. */
  10907. /**
  10908. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10909. * Also use as the light direction on spot and directional lights.
  10910. */
  10911. direction: Vector3;
  10912. private _shadowMinZ;
  10913. /**
  10914. * Gets the shadow projection clipping minimum z value.
  10915. */
  10916. /**
  10917. * Sets the shadow projection clipping minimum z value.
  10918. */
  10919. shadowMinZ: number;
  10920. private _shadowMaxZ;
  10921. /**
  10922. * Sets the shadow projection clipping maximum z value.
  10923. */
  10924. /**
  10925. * Gets the shadow projection clipping maximum z value.
  10926. */
  10927. shadowMaxZ: number;
  10928. /**
  10929. * Callback defining a custom Projection Matrix Builder.
  10930. * This can be used to override the default projection matrix computation.
  10931. */
  10932. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10933. /**
  10934. * The transformed position. Position of the light in world space taking parenting in account.
  10935. */
  10936. transformedPosition: Vector3;
  10937. /**
  10938. * The transformed direction. Direction of the light in world space taking parenting in account.
  10939. */
  10940. transformedDirection: Vector3;
  10941. private _needProjectionMatrixCompute;
  10942. /**
  10943. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10944. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10945. */
  10946. computeTransformedInformation(): boolean;
  10947. /**
  10948. * Return the depth scale used for the shadow map.
  10949. * @returns the depth scale.
  10950. */
  10951. getDepthScale(): number;
  10952. /**
  10953. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10954. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10955. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10956. */
  10957. getShadowDirection(faceIndex?: number): Vector3;
  10958. /**
  10959. * Returns the ShadowLight absolute position in the World.
  10960. * @returns the position vector in world space
  10961. */
  10962. getAbsolutePosition(): Vector3;
  10963. /**
  10964. * Sets the ShadowLight direction toward the passed target.
  10965. * @param target The point to target in local space
  10966. * @returns the updated ShadowLight direction
  10967. */
  10968. setDirectionToTarget(target: Vector3): Vector3;
  10969. /**
  10970. * Returns the light rotation in euler definition.
  10971. * @returns the x y z rotation in local space.
  10972. */
  10973. getRotation(): Vector3;
  10974. /**
  10975. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10976. * @returns true if a cube texture needs to be use
  10977. */
  10978. needCube(): boolean;
  10979. /**
  10980. * Detects if the projection matrix requires to be recomputed this frame.
  10981. * @returns true if it requires to be recomputed otherwise, false.
  10982. */
  10983. needProjectionMatrixCompute(): boolean;
  10984. /**
  10985. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10986. */
  10987. forceProjectionMatrixCompute(): void;
  10988. /** @hidden */
  10989. _initCache(): void;
  10990. /** @hidden */
  10991. _isSynchronized(): boolean;
  10992. /**
  10993. * Computes the world matrix of the node
  10994. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10995. * @returns the world matrix
  10996. */
  10997. computeWorldMatrix(force?: boolean): Matrix;
  10998. /**
  10999. * Gets the minZ used for shadow according to both the scene and the light.
  11000. * @param activeCamera The camera we are returning the min for
  11001. * @returns the depth min z
  11002. */
  11003. getDepthMinZ(activeCamera: Camera): number;
  11004. /**
  11005. * Gets the maxZ used for shadow according to both the scene and the light.
  11006. * @param activeCamera The camera we are returning the max for
  11007. * @returns the depth max z
  11008. */
  11009. getDepthMaxZ(activeCamera: Camera): number;
  11010. /**
  11011. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11012. * @param matrix The materix to updated with the projection information
  11013. * @param viewMatrix The transform matrix of the light
  11014. * @param renderList The list of mesh to render in the map
  11015. * @returns The current light
  11016. */
  11017. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11018. }
  11019. }
  11020. declare module "babylonjs/Materials/materialHelper" {
  11021. import { Nullable } from "babylonjs/types";
  11022. import { Scene } from "babylonjs/scene";
  11023. import { Engine } from "babylonjs/Engines/engine";
  11024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11025. import { Light } from "babylonjs/Lights/light";
  11026. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11027. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11029. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11030. /**
  11031. * "Static Class" containing the most commonly used helper while dealing with material for
  11032. * rendering purpose.
  11033. *
  11034. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11035. *
  11036. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11037. */
  11038. export class MaterialHelper {
  11039. /**
  11040. * Bind the current view position to an effect.
  11041. * @param effect The effect to be bound
  11042. * @param scene The scene the eyes position is used from
  11043. */
  11044. static BindEyePosition(effect: Effect, scene: Scene): void;
  11045. /**
  11046. * Helps preparing the defines values about the UVs in used in the effect.
  11047. * UVs are shared as much as we can accross channels in the shaders.
  11048. * @param texture The texture we are preparing the UVs for
  11049. * @param defines The defines to update
  11050. * @param key The channel key "diffuse", "specular"... used in the shader
  11051. */
  11052. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11053. /**
  11054. * Binds a texture matrix value to its corrsponding uniform
  11055. * @param texture The texture to bind the matrix for
  11056. * @param uniformBuffer The uniform buffer receivin the data
  11057. * @param key The channel key "diffuse", "specular"... used in the shader
  11058. */
  11059. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11060. /**
  11061. * Gets the current status of the fog (should it be enabled?)
  11062. * @param mesh defines the mesh to evaluate for fog support
  11063. * @param scene defines the hosting scene
  11064. * @returns true if fog must be enabled
  11065. */
  11066. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11067. /**
  11068. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11069. * @param mesh defines the current mesh
  11070. * @param scene defines the current scene
  11071. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11072. * @param pointsCloud defines if point cloud rendering has to be turned on
  11073. * @param fogEnabled defines if fog has to be turned on
  11074. * @param alphaTest defines if alpha testing has to be turned on
  11075. * @param defines defines the current list of defines
  11076. */
  11077. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11078. /**
  11079. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11080. * @param scene defines the current scene
  11081. * @param engine defines the current engine
  11082. * @param defines specifies the list of active defines
  11083. * @param useInstances defines if instances have to be turned on
  11084. * @param useClipPlane defines if clip plane have to be turned on
  11085. */
  11086. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11087. /**
  11088. * Prepares the defines for bones
  11089. * @param mesh The mesh containing the geometry data we will draw
  11090. * @param defines The defines to update
  11091. */
  11092. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11093. /**
  11094. * Prepares the defines for morph targets
  11095. * @param mesh The mesh containing the geometry data we will draw
  11096. * @param defines The defines to update
  11097. */
  11098. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11099. /**
  11100. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11101. * @param mesh The mesh containing the geometry data we will draw
  11102. * @param defines The defines to update
  11103. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11104. * @param useBones Precise whether bones should be used or not (override mesh info)
  11105. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11106. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11107. * @returns false if defines are considered not dirty and have not been checked
  11108. */
  11109. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11110. /**
  11111. * Prepares the defines related to multiview
  11112. * @param scene The scene we are intending to draw
  11113. * @param defines The defines to update
  11114. */
  11115. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11116. /**
  11117. * Prepares the defines related to the light information passed in parameter
  11118. * @param scene The scene we are intending to draw
  11119. * @param mesh The mesh the effect is compiling for
  11120. * @param light The light the effect is compiling for
  11121. * @param lightIndex The index of the light
  11122. * @param defines The defines to update
  11123. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11124. * @param state Defines the current state regarding what is needed (normals, etc...)
  11125. */
  11126. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  11127. needNormals: boolean;
  11128. needRebuild: boolean;
  11129. shadowEnabled: boolean;
  11130. specularEnabled: boolean;
  11131. lightmapMode: boolean;
  11132. }): void;
  11133. /**
  11134. * Prepares the defines related to the light information passed in parameter
  11135. * @param scene The scene we are intending to draw
  11136. * @param mesh The mesh the effect is compiling for
  11137. * @param defines The defines to update
  11138. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11139. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11140. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11141. * @returns true if normals will be required for the rest of the effect
  11142. */
  11143. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11144. /**
  11145. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  11146. * @param lightIndex defines the light index
  11147. * @param uniformsList The uniform list
  11148. * @param samplersList The sampler list
  11149. * @param projectedLightTexture defines if projected texture must be used
  11150. * @param uniformBuffersList defines an optional list of uniform buffers
  11151. */
  11152. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11153. /**
  11154. * Prepares the uniforms and samplers list to be used in the effect
  11155. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11156. * @param samplersList The sampler list
  11157. * @param defines The defines helping in the list generation
  11158. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11159. */
  11160. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11161. /**
  11162. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11163. * @param defines The defines to update while falling back
  11164. * @param fallbacks The authorized effect fallbacks
  11165. * @param maxSimultaneousLights The maximum number of lights allowed
  11166. * @param rank the current rank of the Effect
  11167. * @returns The newly affected rank
  11168. */
  11169. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11170. private static _TmpMorphInfluencers;
  11171. /**
  11172. * Prepares the list of attributes required for morph targets according to the effect defines.
  11173. * @param attribs The current list of supported attribs
  11174. * @param mesh The mesh to prepare the morph targets attributes for
  11175. * @param influencers The number of influencers
  11176. */
  11177. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11178. /**
  11179. * Prepares the list of attributes required for morph targets according to the effect defines.
  11180. * @param attribs The current list of supported attribs
  11181. * @param mesh The mesh to prepare the morph targets attributes for
  11182. * @param defines The current Defines of the effect
  11183. */
  11184. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11185. /**
  11186. * Prepares the list of attributes required for bones according to the effect defines.
  11187. * @param attribs The current list of supported attribs
  11188. * @param mesh The mesh to prepare the bones attributes for
  11189. * @param defines The current Defines of the effect
  11190. * @param fallbacks The current efffect fallback strategy
  11191. */
  11192. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11193. /**
  11194. * Check and prepare the list of attributes required for instances according to the effect defines.
  11195. * @param attribs The current list of supported attribs
  11196. * @param defines The current MaterialDefines of the effect
  11197. */
  11198. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11199. /**
  11200. * Add the list of attributes required for instances to the attribs array.
  11201. * @param attribs The current list of supported attribs
  11202. */
  11203. static PushAttributesForInstances(attribs: string[]): void;
  11204. /**
  11205. * Binds the light shadow information to the effect for the given mesh.
  11206. * @param light The light containing the generator
  11207. * @param scene The scene the lights belongs to
  11208. * @param mesh The mesh we are binding the information to render
  11209. * @param lightIndex The light index in the effect used to render the mesh
  11210. * @param effect The effect we are binding the data to
  11211. */
  11212. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11213. /**
  11214. * Binds the light information to the effect.
  11215. * @param light The light containing the generator
  11216. * @param effect The effect we are binding the data to
  11217. * @param lightIndex The light index in the effect used to render
  11218. */
  11219. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11220. /**
  11221. * Binds the lights information from the scene to the effect for the given mesh.
  11222. * @param light Light to bind
  11223. * @param lightIndex Light index
  11224. * @param scene The scene where the light belongs to
  11225. * @param mesh The mesh we are binding the information to render
  11226. * @param effect The effect we are binding the data to
  11227. * @param useSpecular Defines if specular is supported
  11228. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11229. */
  11230. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11231. /**
  11232. * Binds the lights information from the scene to the effect for the given mesh.
  11233. * @param scene The scene the lights belongs to
  11234. * @param mesh The mesh we are binding the information to render
  11235. * @param effect The effect we are binding the data to
  11236. * @param defines The generated defines for the effect
  11237. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11238. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11239. */
  11240. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11241. private static _tempFogColor;
  11242. /**
  11243. * Binds the fog information from the scene to the effect for the given mesh.
  11244. * @param scene The scene the lights belongs to
  11245. * @param mesh The mesh we are binding the information to render
  11246. * @param effect The effect we are binding the data to
  11247. * @param linearSpace Defines if the fog effect is applied in linear space
  11248. */
  11249. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11250. /**
  11251. * Binds the bones information from the mesh to the effect.
  11252. * @param mesh The mesh we are binding the information to render
  11253. * @param effect The effect we are binding the data to
  11254. */
  11255. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11256. /**
  11257. * Binds the morph targets information from the mesh to the effect.
  11258. * @param abstractMesh The mesh we are binding the information to render
  11259. * @param effect The effect we are binding the data to
  11260. */
  11261. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11262. /**
  11263. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11264. * @param defines The generated defines used in the effect
  11265. * @param effect The effect we are binding the data to
  11266. * @param scene The scene we are willing to render with logarithmic scale for
  11267. */
  11268. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11269. /**
  11270. * Binds the clip plane information from the scene to the effect.
  11271. * @param scene The scene the clip plane information are extracted from
  11272. * @param effect The effect we are binding the data to
  11273. */
  11274. static BindClipPlane(effect: Effect, scene: Scene): void;
  11275. }
  11276. }
  11277. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11278. /** @hidden */
  11279. export var shadowMapPixelShader: {
  11280. name: string;
  11281. shader: string;
  11282. };
  11283. }
  11284. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11285. /** @hidden */
  11286. export var bonesDeclaration: {
  11287. name: string;
  11288. shader: string;
  11289. };
  11290. }
  11291. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11292. /** @hidden */
  11293. export var morphTargetsVertexGlobalDeclaration: {
  11294. name: string;
  11295. shader: string;
  11296. };
  11297. }
  11298. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11299. /** @hidden */
  11300. export var morphTargetsVertexDeclaration: {
  11301. name: string;
  11302. shader: string;
  11303. };
  11304. }
  11305. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11306. /** @hidden */
  11307. export var instancesDeclaration: {
  11308. name: string;
  11309. shader: string;
  11310. };
  11311. }
  11312. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11313. /** @hidden */
  11314. export var helperFunctions: {
  11315. name: string;
  11316. shader: string;
  11317. };
  11318. }
  11319. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11320. /** @hidden */
  11321. export var morphTargetsVertex: {
  11322. name: string;
  11323. shader: string;
  11324. };
  11325. }
  11326. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11327. /** @hidden */
  11328. export var instancesVertex: {
  11329. name: string;
  11330. shader: string;
  11331. };
  11332. }
  11333. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11334. /** @hidden */
  11335. export var bonesVertex: {
  11336. name: string;
  11337. shader: string;
  11338. };
  11339. }
  11340. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11341. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11343. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11344. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11345. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11346. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11347. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11348. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11349. /** @hidden */
  11350. export var shadowMapVertexShader: {
  11351. name: string;
  11352. shader: string;
  11353. };
  11354. }
  11355. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11356. /** @hidden */
  11357. export var depthBoxBlurPixelShader: {
  11358. name: string;
  11359. shader: string;
  11360. };
  11361. }
  11362. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11363. import { Nullable } from "babylonjs/types";
  11364. import { Scene } from "babylonjs/scene";
  11365. import { Matrix } from "babylonjs/Maths/math";
  11366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11368. import { Mesh } from "babylonjs/Meshes/mesh";
  11369. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11370. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11371. import { Effect } from "babylonjs/Materials/effect";
  11372. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11373. import "babylonjs/Shaders/shadowMap.fragment";
  11374. import "babylonjs/Shaders/shadowMap.vertex";
  11375. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11376. import { Observable } from "babylonjs/Misc/observable";
  11377. /**
  11378. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11379. */
  11380. export interface ICustomShaderOptions {
  11381. /**
  11382. * Gets or sets the custom shader name to use
  11383. */
  11384. shaderName: string;
  11385. /**
  11386. * The list of attribute names used in the shader
  11387. */
  11388. attributes?: string[];
  11389. /**
  11390. * The list of unifrom names used in the shader
  11391. */
  11392. uniforms?: string[];
  11393. /**
  11394. * The list of sampler names used in the shader
  11395. */
  11396. samplers?: string[];
  11397. /**
  11398. * The list of defines used in the shader
  11399. */
  11400. defines?: string[];
  11401. }
  11402. /**
  11403. * Interface to implement to create a shadow generator compatible with BJS.
  11404. */
  11405. export interface IShadowGenerator {
  11406. /**
  11407. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11408. * @returns The render target texture if present otherwise, null
  11409. */
  11410. getShadowMap(): Nullable<RenderTargetTexture>;
  11411. /**
  11412. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11413. * @returns The render target texture if the shadow map is present otherwise, null
  11414. */
  11415. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11416. /**
  11417. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11418. * @param subMesh The submesh we want to render in the shadow map
  11419. * @param useInstances Defines wether will draw in the map using instances
  11420. * @returns true if ready otherwise, false
  11421. */
  11422. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11423. /**
  11424. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11425. * @param defines Defines of the material we want to update
  11426. * @param lightIndex Index of the light in the enabled light list of the material
  11427. */
  11428. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11429. /**
  11430. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11431. * defined in the generator but impacting the effect).
  11432. * It implies the unifroms available on the materials are the standard BJS ones.
  11433. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11434. * @param effect The effect we are binfing the information for
  11435. */
  11436. bindShadowLight(lightIndex: string, effect: Effect): void;
  11437. /**
  11438. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11439. * (eq to shadow prjection matrix * light transform matrix)
  11440. * @returns The transform matrix used to create the shadow map
  11441. */
  11442. getTransformMatrix(): Matrix;
  11443. /**
  11444. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11445. * Cube and 2D textures for instance.
  11446. */
  11447. recreateShadowMap(): void;
  11448. /**
  11449. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11450. * @param onCompiled Callback triggered at the and of the effects compilation
  11451. * @param options Sets of optional options forcing the compilation with different modes
  11452. */
  11453. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11454. useInstances: boolean;
  11455. }>): void;
  11456. /**
  11457. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11458. * @param options Sets of optional options forcing the compilation with different modes
  11459. * @returns A promise that resolves when the compilation completes
  11460. */
  11461. forceCompilationAsync(options?: Partial<{
  11462. useInstances: boolean;
  11463. }>): Promise<void>;
  11464. /**
  11465. * Serializes the shadow generator setup to a json object.
  11466. * @returns The serialized JSON object
  11467. */
  11468. serialize(): any;
  11469. /**
  11470. * Disposes the Shadow map and related Textures and effects.
  11471. */
  11472. dispose(): void;
  11473. }
  11474. /**
  11475. * Default implementation IShadowGenerator.
  11476. * This is the main object responsible of generating shadows in the framework.
  11477. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11478. */
  11479. export class ShadowGenerator implements IShadowGenerator {
  11480. /**
  11481. * Shadow generator mode None: no filtering applied.
  11482. */
  11483. static readonly FILTER_NONE: number;
  11484. /**
  11485. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11486. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11487. */
  11488. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11489. /**
  11490. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11491. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11492. */
  11493. static readonly FILTER_POISSONSAMPLING: number;
  11494. /**
  11495. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11497. */
  11498. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11499. /**
  11500. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11501. * edge artifacts on steep falloff.
  11502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11503. */
  11504. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11505. /**
  11506. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11507. * edge artifacts on steep falloff.
  11508. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11509. */
  11510. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11511. /**
  11512. * Shadow generator mode PCF: Percentage Closer Filtering
  11513. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11514. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11515. */
  11516. static readonly FILTER_PCF: number;
  11517. /**
  11518. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11519. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11520. * Contact Hardening
  11521. */
  11522. static readonly FILTER_PCSS: number;
  11523. /**
  11524. * Reserved for PCF and PCSS
  11525. * Highest Quality.
  11526. *
  11527. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11528. *
  11529. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11530. */
  11531. static readonly QUALITY_HIGH: number;
  11532. /**
  11533. * Reserved for PCF and PCSS
  11534. * Good tradeoff for quality/perf cross devices
  11535. *
  11536. * Execute PCF on a 3*3 kernel.
  11537. *
  11538. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11539. */
  11540. static readonly QUALITY_MEDIUM: number;
  11541. /**
  11542. * Reserved for PCF and PCSS
  11543. * The lowest quality but the fastest.
  11544. *
  11545. * Execute PCF on a 1*1 kernel.
  11546. *
  11547. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11548. */
  11549. static readonly QUALITY_LOW: number;
  11550. /** Gets or sets the custom shader name to use */
  11551. customShaderOptions: ICustomShaderOptions;
  11552. /**
  11553. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11554. */
  11555. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11556. /**
  11557. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11558. */
  11559. onAfterShadowMapRenderObservable: Observable<Effect>;
  11560. /**
  11561. * Observable triggered before a mesh is rendered in the shadow map.
  11562. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11563. */
  11564. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11565. /**
  11566. * Observable triggered after a mesh is rendered in the shadow map.
  11567. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11568. */
  11569. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11570. private _bias;
  11571. /**
  11572. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11573. */
  11574. /**
  11575. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11576. */
  11577. bias: number;
  11578. private _normalBias;
  11579. /**
  11580. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11581. */
  11582. /**
  11583. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11584. */
  11585. normalBias: number;
  11586. private _blurBoxOffset;
  11587. /**
  11588. * Gets the blur box offset: offset applied during the blur pass.
  11589. * Only useful if useKernelBlur = false
  11590. */
  11591. /**
  11592. * Sets the blur box offset: offset applied during the blur pass.
  11593. * Only useful if useKernelBlur = false
  11594. */
  11595. blurBoxOffset: number;
  11596. private _blurScale;
  11597. /**
  11598. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11599. * 2 means half of the size.
  11600. */
  11601. /**
  11602. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11603. * 2 means half of the size.
  11604. */
  11605. blurScale: number;
  11606. private _blurKernel;
  11607. /**
  11608. * Gets the blur kernel: kernel size of the blur pass.
  11609. * Only useful if useKernelBlur = true
  11610. */
  11611. /**
  11612. * Sets the blur kernel: kernel size of the blur pass.
  11613. * Only useful if useKernelBlur = true
  11614. */
  11615. blurKernel: number;
  11616. private _useKernelBlur;
  11617. /**
  11618. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11619. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11620. */
  11621. /**
  11622. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11623. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11624. */
  11625. useKernelBlur: boolean;
  11626. private _depthScale;
  11627. /**
  11628. * Gets the depth scale used in ESM mode.
  11629. */
  11630. /**
  11631. * Sets the depth scale used in ESM mode.
  11632. * This can override the scale stored on the light.
  11633. */
  11634. depthScale: number;
  11635. private _filter;
  11636. /**
  11637. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11638. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11639. */
  11640. /**
  11641. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11642. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11643. */
  11644. filter: number;
  11645. /**
  11646. * Gets if the current filter is set to Poisson Sampling.
  11647. */
  11648. /**
  11649. * Sets the current filter to Poisson Sampling.
  11650. */
  11651. usePoissonSampling: boolean;
  11652. /**
  11653. * Gets if the current filter is set to ESM.
  11654. */
  11655. /**
  11656. * Sets the current filter is to ESM.
  11657. */
  11658. useExponentialShadowMap: boolean;
  11659. /**
  11660. * Gets if the current filter is set to filtered ESM.
  11661. */
  11662. /**
  11663. * Gets if the current filter is set to filtered ESM.
  11664. */
  11665. useBlurExponentialShadowMap: boolean;
  11666. /**
  11667. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11668. * exponential to prevent steep falloff artifacts).
  11669. */
  11670. /**
  11671. * Sets the current filter to "close ESM" (using the inverse of the
  11672. * exponential to prevent steep falloff artifacts).
  11673. */
  11674. useCloseExponentialShadowMap: boolean;
  11675. /**
  11676. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11677. * exponential to prevent steep falloff artifacts).
  11678. */
  11679. /**
  11680. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11681. * exponential to prevent steep falloff artifacts).
  11682. */
  11683. useBlurCloseExponentialShadowMap: boolean;
  11684. /**
  11685. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11686. */
  11687. /**
  11688. * Sets the current filter to "PCF" (percentage closer filtering).
  11689. */
  11690. usePercentageCloserFiltering: boolean;
  11691. private _filteringQuality;
  11692. /**
  11693. * Gets the PCF or PCSS Quality.
  11694. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11695. */
  11696. /**
  11697. * Sets the PCF or PCSS Quality.
  11698. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11699. */
  11700. filteringQuality: number;
  11701. /**
  11702. * Gets if the current filter is set to "PCSS" (contact hardening).
  11703. */
  11704. /**
  11705. * Sets the current filter to "PCSS" (contact hardening).
  11706. */
  11707. useContactHardeningShadow: boolean;
  11708. private _contactHardeningLightSizeUVRatio;
  11709. /**
  11710. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11711. * Using a ratio helps keeping shape stability independently of the map size.
  11712. *
  11713. * It does not account for the light projection as it was having too much
  11714. * instability during the light setup or during light position changes.
  11715. *
  11716. * Only valid if useContactHardeningShadow is true.
  11717. */
  11718. /**
  11719. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11720. * Using a ratio helps keeping shape stability independently of the map size.
  11721. *
  11722. * It does not account for the light projection as it was having too much
  11723. * instability during the light setup or during light position changes.
  11724. *
  11725. * Only valid if useContactHardeningShadow is true.
  11726. */
  11727. contactHardeningLightSizeUVRatio: number;
  11728. private _darkness;
  11729. /** Gets or sets the actual darkness of a shadow */
  11730. darkness: number;
  11731. /**
  11732. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11733. * 0 means strongest and 1 would means no shadow.
  11734. * @returns the darkness.
  11735. */
  11736. getDarkness(): number;
  11737. /**
  11738. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11739. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11740. * @returns the shadow generator allowing fluent coding.
  11741. */
  11742. setDarkness(darkness: number): ShadowGenerator;
  11743. private _transparencyShadow;
  11744. /** Gets or sets the ability to have transparent shadow */
  11745. transparencyShadow: boolean;
  11746. /**
  11747. * Sets the ability to have transparent shadow (boolean).
  11748. * @param transparent True if transparent else False
  11749. * @returns the shadow generator allowing fluent coding
  11750. */
  11751. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11752. private _shadowMap;
  11753. private _shadowMap2;
  11754. /**
  11755. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11756. * @returns The render target texture if present otherwise, null
  11757. */
  11758. getShadowMap(): Nullable<RenderTargetTexture>;
  11759. /**
  11760. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11761. * @returns The render target texture if the shadow map is present otherwise, null
  11762. */
  11763. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11764. /**
  11765. * Gets the class name of that object
  11766. * @returns "ShadowGenerator"
  11767. */
  11768. getClassName(): string;
  11769. /**
  11770. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11771. * @param mesh Mesh to add
  11772. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11773. * @returns the Shadow Generator itself
  11774. */
  11775. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11776. /**
  11777. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11778. * @param mesh Mesh to remove
  11779. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11780. * @returns the Shadow Generator itself
  11781. */
  11782. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11783. /**
  11784. * Controls the extent to which the shadows fade out at the edge of the frustum
  11785. * Used only by directionals and spots
  11786. */
  11787. frustumEdgeFalloff: number;
  11788. private _light;
  11789. /**
  11790. * Returns the associated light object.
  11791. * @returns the light generating the shadow
  11792. */
  11793. getLight(): IShadowLight;
  11794. /**
  11795. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11796. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11797. * It might on the other hand introduce peter panning.
  11798. */
  11799. forceBackFacesOnly: boolean;
  11800. private _scene;
  11801. private _lightDirection;
  11802. private _effect;
  11803. private _viewMatrix;
  11804. private _projectionMatrix;
  11805. private _transformMatrix;
  11806. private _cachedPosition;
  11807. private _cachedDirection;
  11808. private _cachedDefines;
  11809. private _currentRenderID;
  11810. private _boxBlurPostprocess;
  11811. private _kernelBlurXPostprocess;
  11812. private _kernelBlurYPostprocess;
  11813. private _blurPostProcesses;
  11814. private _mapSize;
  11815. private _currentFaceIndex;
  11816. private _currentFaceIndexCache;
  11817. private _textureType;
  11818. private _defaultTextureMatrix;
  11819. /** @hidden */
  11820. static _SceneComponentInitialization: (scene: Scene) => void;
  11821. /**
  11822. * Creates a ShadowGenerator object.
  11823. * A ShadowGenerator is the required tool to use the shadows.
  11824. * Each light casting shadows needs to use its own ShadowGenerator.
  11825. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11826. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11827. * @param light The light object generating the shadows.
  11828. * @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.
  11829. */
  11830. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11831. private _initializeGenerator;
  11832. private _initializeShadowMap;
  11833. private _initializeBlurRTTAndPostProcesses;
  11834. private _renderForShadowMap;
  11835. private _renderSubMeshForShadowMap;
  11836. private _applyFilterValues;
  11837. /**
  11838. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11839. * @param onCompiled Callback triggered at the and of the effects compilation
  11840. * @param options Sets of optional options forcing the compilation with different modes
  11841. */
  11842. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11843. useInstances: boolean;
  11844. }>): void;
  11845. /**
  11846. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11847. * @param options Sets of optional options forcing the compilation with different modes
  11848. * @returns A promise that resolves when the compilation completes
  11849. */
  11850. forceCompilationAsync(options?: Partial<{
  11851. useInstances: boolean;
  11852. }>): Promise<void>;
  11853. /**
  11854. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11855. * @param subMesh The submesh we want to render in the shadow map
  11856. * @param useInstances Defines wether will draw in the map using instances
  11857. * @returns true if ready otherwise, false
  11858. */
  11859. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11860. /**
  11861. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11862. * @param defines Defines of the material we want to update
  11863. * @param lightIndex Index of the light in the enabled light list of the material
  11864. */
  11865. prepareDefines(defines: any, lightIndex: number): void;
  11866. /**
  11867. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11868. * defined in the generator but impacting the effect).
  11869. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11870. * @param effect The effect we are binfing the information for
  11871. */
  11872. bindShadowLight(lightIndex: string, effect: Effect): void;
  11873. /**
  11874. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11875. * (eq to shadow prjection matrix * light transform matrix)
  11876. * @returns The transform matrix used to create the shadow map
  11877. */
  11878. getTransformMatrix(): Matrix;
  11879. /**
  11880. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11881. * Cube and 2D textures for instance.
  11882. */
  11883. recreateShadowMap(): void;
  11884. private _disposeBlurPostProcesses;
  11885. private _disposeRTTandPostProcesses;
  11886. /**
  11887. * Disposes the ShadowGenerator.
  11888. * Returns nothing.
  11889. */
  11890. dispose(): void;
  11891. /**
  11892. * Serializes the shadow generator setup to a json object.
  11893. * @returns The serialized JSON object
  11894. */
  11895. serialize(): any;
  11896. /**
  11897. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11898. * @param parsedShadowGenerator The JSON object to parse
  11899. * @param scene The scene to create the shadow map for
  11900. * @returns The parsed shadow generator
  11901. */
  11902. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11903. }
  11904. }
  11905. declare module "babylonjs/Lights/light" {
  11906. import { Nullable } from "babylonjs/types";
  11907. import { Scene } from "babylonjs/scene";
  11908. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11909. import { Node } from "babylonjs/node";
  11910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11911. import { Effect } from "babylonjs/Materials/effect";
  11912. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11913. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11914. /**
  11915. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11916. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11917. * 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.
  11918. */
  11919. export abstract class Light extends Node {
  11920. /**
  11921. * Falloff Default: light is falling off following the material specification:
  11922. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11923. */
  11924. static readonly FALLOFF_DEFAULT: number;
  11925. /**
  11926. * Falloff Physical: light is falling off following the inverse squared distance law.
  11927. */
  11928. static readonly FALLOFF_PHYSICAL: number;
  11929. /**
  11930. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11931. * to enhance interoperability with other engines.
  11932. */
  11933. static readonly FALLOFF_GLTF: number;
  11934. /**
  11935. * Falloff Standard: light is falling off like in the standard material
  11936. * to enhance interoperability with other materials.
  11937. */
  11938. static readonly FALLOFF_STANDARD: number;
  11939. /**
  11940. * If every light affecting the material is in this lightmapMode,
  11941. * material.lightmapTexture adds or multiplies
  11942. * (depends on material.useLightmapAsShadowmap)
  11943. * after every other light calculations.
  11944. */
  11945. static readonly LIGHTMAP_DEFAULT: number;
  11946. /**
  11947. * material.lightmapTexture as only diffuse lighting from this light
  11948. * adds only specular lighting from this light
  11949. * adds dynamic shadows
  11950. */
  11951. static readonly LIGHTMAP_SPECULAR: number;
  11952. /**
  11953. * material.lightmapTexture as only lighting
  11954. * no light calculation from this light
  11955. * only adds dynamic shadows from this light
  11956. */
  11957. static readonly LIGHTMAP_SHADOWSONLY: number;
  11958. /**
  11959. * Each light type uses the default quantity according to its type:
  11960. * point/spot lights use luminous intensity
  11961. * directional lights use illuminance
  11962. */
  11963. static readonly INTENSITYMODE_AUTOMATIC: number;
  11964. /**
  11965. * lumen (lm)
  11966. */
  11967. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11968. /**
  11969. * candela (lm/sr)
  11970. */
  11971. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11972. /**
  11973. * lux (lm/m^2)
  11974. */
  11975. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11976. /**
  11977. * nit (cd/m^2)
  11978. */
  11979. static readonly INTENSITYMODE_LUMINANCE: number;
  11980. /**
  11981. * Light type const id of the point light.
  11982. */
  11983. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11984. /**
  11985. * Light type const id of the directional light.
  11986. */
  11987. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11988. /**
  11989. * Light type const id of the spot light.
  11990. */
  11991. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11992. /**
  11993. * Light type const id of the hemispheric light.
  11994. */
  11995. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11996. /**
  11997. * Diffuse gives the basic color to an object.
  11998. */
  11999. diffuse: Color3;
  12000. /**
  12001. * Specular produces a highlight color on an object.
  12002. * Note: This is note affecting PBR materials.
  12003. */
  12004. specular: Color3;
  12005. /**
  12006. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12007. * falling off base on range or angle.
  12008. * This can be set to any values in Light.FALLOFF_x.
  12009. *
  12010. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12011. * other types of materials.
  12012. */
  12013. falloffType: number;
  12014. /**
  12015. * Strength of the light.
  12016. * Note: By default it is define in the framework own unit.
  12017. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12018. */
  12019. intensity: number;
  12020. private _range;
  12021. protected _inverseSquaredRange: number;
  12022. /**
  12023. * Defines how far from the source the light is impacting in scene units.
  12024. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12025. */
  12026. /**
  12027. * Defines how far from the source the light is impacting in scene units.
  12028. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12029. */
  12030. range: number;
  12031. /**
  12032. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12033. * of light.
  12034. */
  12035. private _photometricScale;
  12036. private _intensityMode;
  12037. /**
  12038. * Gets the photometric scale used to interpret the intensity.
  12039. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12040. */
  12041. /**
  12042. * Sets the photometric scale used to interpret the intensity.
  12043. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12044. */
  12045. intensityMode: number;
  12046. private _radius;
  12047. /**
  12048. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12049. */
  12050. /**
  12051. * sets the light radius used by PBR Materials to simulate soft area lights.
  12052. */
  12053. radius: number;
  12054. private _renderPriority;
  12055. /**
  12056. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12057. * exceeding the number allowed of the materials.
  12058. */
  12059. renderPriority: number;
  12060. private _shadowEnabled;
  12061. /**
  12062. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12063. * the current shadow generator.
  12064. */
  12065. /**
  12066. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12067. * the current shadow generator.
  12068. */
  12069. shadowEnabled: boolean;
  12070. private _includedOnlyMeshes;
  12071. /**
  12072. * Gets the only meshes impacted by this light.
  12073. */
  12074. /**
  12075. * Sets the only meshes impacted by this light.
  12076. */
  12077. includedOnlyMeshes: AbstractMesh[];
  12078. private _excludedMeshes;
  12079. /**
  12080. * Gets the meshes not impacted by this light.
  12081. */
  12082. /**
  12083. * Sets the meshes not impacted by this light.
  12084. */
  12085. excludedMeshes: AbstractMesh[];
  12086. private _excludeWithLayerMask;
  12087. /**
  12088. * Gets the layer id use to find what meshes are not impacted by the light.
  12089. * Inactive if 0
  12090. */
  12091. /**
  12092. * Sets the layer id use to find what meshes are not impacted by the light.
  12093. * Inactive if 0
  12094. */
  12095. excludeWithLayerMask: number;
  12096. private _includeOnlyWithLayerMask;
  12097. /**
  12098. * Gets the layer id use to find what meshes are impacted by the light.
  12099. * Inactive if 0
  12100. */
  12101. /**
  12102. * Sets the layer id use to find what meshes are impacted by the light.
  12103. * Inactive if 0
  12104. */
  12105. includeOnlyWithLayerMask: number;
  12106. private _lightmapMode;
  12107. /**
  12108. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12109. */
  12110. /**
  12111. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12112. */
  12113. lightmapMode: number;
  12114. /**
  12115. * Shadow generator associted to the light.
  12116. * @hidden Internal use only.
  12117. */
  12118. _shadowGenerator: Nullable<IShadowGenerator>;
  12119. /**
  12120. * @hidden Internal use only.
  12121. */
  12122. _excludedMeshesIds: string[];
  12123. /**
  12124. * @hidden Internal use only.
  12125. */
  12126. _includedOnlyMeshesIds: string[];
  12127. /**
  12128. * The current light unifom buffer.
  12129. * @hidden Internal use only.
  12130. */
  12131. _uniformBuffer: UniformBuffer;
  12132. /**
  12133. * Creates a Light object in the scene.
  12134. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12135. * @param name The firendly name of the light
  12136. * @param scene The scene the light belongs too
  12137. */
  12138. constructor(name: string, scene: Scene);
  12139. protected abstract _buildUniformLayout(): void;
  12140. /**
  12141. * Sets the passed Effect "effect" with the Light information.
  12142. * @param effect The effect to update
  12143. * @param lightIndex The index of the light in the effect to update
  12144. * @returns The light
  12145. */
  12146. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12147. /**
  12148. * Returns the string "Light".
  12149. * @returns the class name
  12150. */
  12151. getClassName(): string;
  12152. /** @hidden */
  12153. readonly _isLight: boolean;
  12154. /**
  12155. * Converts the light information to a readable string for debug purpose.
  12156. * @param fullDetails Supports for multiple levels of logging within scene loading
  12157. * @returns the human readable light info
  12158. */
  12159. toString(fullDetails?: boolean): string;
  12160. /** @hidden */
  12161. protected _syncParentEnabledState(): void;
  12162. /**
  12163. * Set the enabled state of this node.
  12164. * @param value - the new enabled state
  12165. */
  12166. setEnabled(value: boolean): void;
  12167. /**
  12168. * Returns the Light associated shadow generator if any.
  12169. * @return the associated shadow generator.
  12170. */
  12171. getShadowGenerator(): Nullable<IShadowGenerator>;
  12172. /**
  12173. * Returns a Vector3, the absolute light position in the World.
  12174. * @returns the world space position of the light
  12175. */
  12176. getAbsolutePosition(): Vector3;
  12177. /**
  12178. * Specifies if the light will affect the passed mesh.
  12179. * @param mesh The mesh to test against the light
  12180. * @return true the mesh is affected otherwise, false.
  12181. */
  12182. canAffectMesh(mesh: AbstractMesh): boolean;
  12183. /**
  12184. * Sort function to order lights for rendering.
  12185. * @param a First Light object to compare to second.
  12186. * @param b Second Light object to compare first.
  12187. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12188. */
  12189. static CompareLightsPriority(a: Light, b: Light): number;
  12190. /**
  12191. * Releases resources associated with this node.
  12192. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12193. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12194. */
  12195. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12196. /**
  12197. * Returns the light type ID (integer).
  12198. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12199. */
  12200. getTypeID(): number;
  12201. /**
  12202. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12203. * @returns the scaled intensity in intensity mode unit
  12204. */
  12205. getScaledIntensity(): number;
  12206. /**
  12207. * Returns a new Light object, named "name", from the current one.
  12208. * @param name The name of the cloned light
  12209. * @returns the new created light
  12210. */
  12211. clone(name: string): Nullable<Light>;
  12212. /**
  12213. * Serializes the current light into a Serialization object.
  12214. * @returns the serialized object.
  12215. */
  12216. serialize(): any;
  12217. /**
  12218. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12219. * This new light is named "name" and added to the passed scene.
  12220. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12221. * @param name The friendly name of the light
  12222. * @param scene The scene the new light will belong to
  12223. * @returns the constructor function
  12224. */
  12225. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12226. /**
  12227. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12228. * @param parsedLight The JSON representation of the light
  12229. * @param scene The scene to create the parsed light in
  12230. * @returns the created light after parsing
  12231. */
  12232. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12233. private _hookArrayForExcluded;
  12234. private _hookArrayForIncludedOnly;
  12235. private _resyncMeshes;
  12236. /**
  12237. * Forces the meshes to update their light related information in their rendering used effects
  12238. * @hidden Internal Use Only
  12239. */
  12240. _markMeshesAsLightDirty(): void;
  12241. /**
  12242. * Recomputes the cached photometric scale if needed.
  12243. */
  12244. private _computePhotometricScale;
  12245. /**
  12246. * Returns the Photometric Scale according to the light type and intensity mode.
  12247. */
  12248. private _getPhotometricScale;
  12249. /**
  12250. * Reorder the light in the scene according to their defined priority.
  12251. * @hidden Internal Use Only
  12252. */
  12253. _reorderLightsInScene(): void;
  12254. /**
  12255. * Prepares the list of defines specific to the light type.
  12256. * @param defines the list of defines
  12257. * @param lightIndex defines the index of the light for the effect
  12258. */
  12259. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12260. }
  12261. }
  12262. declare module "babylonjs/Meshes/instancedMesh" {
  12263. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12264. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12265. import { Camera } from "babylonjs/Cameras/camera";
  12266. import { Node } from "babylonjs/node";
  12267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12268. import { Mesh } from "babylonjs/Meshes/mesh";
  12269. import { Material } from "babylonjs/Materials/material";
  12270. import { Skeleton } from "babylonjs/Bones/skeleton";
  12271. import { Light } from "babylonjs/Lights/light";
  12272. /**
  12273. * Creates an instance based on a source mesh.
  12274. */
  12275. export class InstancedMesh extends AbstractMesh {
  12276. private _sourceMesh;
  12277. private _currentLOD;
  12278. /** @hidden */
  12279. _indexInSourceMeshInstanceArray: number;
  12280. constructor(name: string, source: Mesh);
  12281. /**
  12282. * Returns the string "InstancedMesh".
  12283. */
  12284. getClassName(): string;
  12285. /** Gets the list of lights affecting that mesh */
  12286. readonly lightSources: Light[];
  12287. _resyncLightSources(): void;
  12288. _resyncLighSource(light: Light): void;
  12289. _removeLightSource(light: Light): void;
  12290. /**
  12291. * If the source mesh receives shadows
  12292. */
  12293. readonly receiveShadows: boolean;
  12294. /**
  12295. * The material of the source mesh
  12296. */
  12297. readonly material: Nullable<Material>;
  12298. /**
  12299. * Visibility of the source mesh
  12300. */
  12301. readonly visibility: number;
  12302. /**
  12303. * Skeleton of the source mesh
  12304. */
  12305. readonly skeleton: Nullable<Skeleton>;
  12306. /**
  12307. * Rendering ground id of the source mesh
  12308. */
  12309. renderingGroupId: number;
  12310. /**
  12311. * Returns the total number of vertices (integer).
  12312. */
  12313. getTotalVertices(): number;
  12314. /**
  12315. * Returns a positive integer : the total number of indices in this mesh geometry.
  12316. * @returns the numner of indices or zero if the mesh has no geometry.
  12317. */
  12318. getTotalIndices(): number;
  12319. /**
  12320. * The source mesh of the instance
  12321. */
  12322. readonly sourceMesh: Mesh;
  12323. /**
  12324. * Is this node ready to be used/rendered
  12325. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12326. * @return {boolean} is it ready
  12327. */
  12328. isReady(completeCheck?: boolean): boolean;
  12329. /**
  12330. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12331. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12332. * @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.
  12333. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12334. */
  12335. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12336. /**
  12337. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12338. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12339. * The `data` are either a numeric array either a Float32Array.
  12340. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12341. * 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).
  12342. * Note that a new underlying VertexBuffer object is created each call.
  12343. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12344. *
  12345. * Possible `kind` values :
  12346. * - VertexBuffer.PositionKind
  12347. * - VertexBuffer.UVKind
  12348. * - VertexBuffer.UV2Kind
  12349. * - VertexBuffer.UV3Kind
  12350. * - VertexBuffer.UV4Kind
  12351. * - VertexBuffer.UV5Kind
  12352. * - VertexBuffer.UV6Kind
  12353. * - VertexBuffer.ColorKind
  12354. * - VertexBuffer.MatricesIndicesKind
  12355. * - VertexBuffer.MatricesIndicesExtraKind
  12356. * - VertexBuffer.MatricesWeightsKind
  12357. * - VertexBuffer.MatricesWeightsExtraKind
  12358. *
  12359. * Returns the Mesh.
  12360. */
  12361. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12362. /**
  12363. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12364. * If the mesh has no geometry, it is simply returned as it is.
  12365. * The `data` are either a numeric array either a Float32Array.
  12366. * No new underlying VertexBuffer object is created.
  12367. * 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.
  12368. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12369. *
  12370. * Possible `kind` values :
  12371. * - VertexBuffer.PositionKind
  12372. * - VertexBuffer.UVKind
  12373. * - VertexBuffer.UV2Kind
  12374. * - VertexBuffer.UV3Kind
  12375. * - VertexBuffer.UV4Kind
  12376. * - VertexBuffer.UV5Kind
  12377. * - VertexBuffer.UV6Kind
  12378. * - VertexBuffer.ColorKind
  12379. * - VertexBuffer.MatricesIndicesKind
  12380. * - VertexBuffer.MatricesIndicesExtraKind
  12381. * - VertexBuffer.MatricesWeightsKind
  12382. * - VertexBuffer.MatricesWeightsExtraKind
  12383. *
  12384. * Returns the Mesh.
  12385. */
  12386. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12387. /**
  12388. * Sets the mesh indices.
  12389. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12390. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12391. * This method creates a new index buffer each call.
  12392. * Returns the Mesh.
  12393. */
  12394. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12395. /**
  12396. * Boolean : True if the mesh owns the requested kind of data.
  12397. */
  12398. isVerticesDataPresent(kind: string): boolean;
  12399. /**
  12400. * Returns an array of indices (IndicesArray).
  12401. */
  12402. getIndices(): Nullable<IndicesArray>;
  12403. readonly _positions: Nullable<Vector3[]>;
  12404. /**
  12405. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12406. * This means the mesh underlying bounding box and sphere are recomputed.
  12407. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12408. * @returns the current mesh
  12409. */
  12410. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12411. /** @hidden */
  12412. _preActivate(): InstancedMesh;
  12413. /** @hidden */
  12414. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12415. /** @hidden */
  12416. _postActivate(): void;
  12417. getWorldMatrix(): Matrix;
  12418. readonly isAnInstance: boolean;
  12419. /**
  12420. * Returns the current associated LOD AbstractMesh.
  12421. */
  12422. getLOD(camera: Camera): AbstractMesh;
  12423. /** @hidden */
  12424. _syncSubMeshes(): InstancedMesh;
  12425. /** @hidden */
  12426. _generatePointsArray(): boolean;
  12427. /**
  12428. * Creates a new InstancedMesh from the current mesh.
  12429. * - name (string) : the cloned mesh name
  12430. * - newParent (optional Node) : the optional Node to parent the clone to.
  12431. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12432. *
  12433. * Returns the clone.
  12434. */
  12435. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12436. /**
  12437. * Disposes the InstancedMesh.
  12438. * Returns nothing.
  12439. */
  12440. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12441. }
  12442. }
  12443. declare module "babylonjs/Materials/shaderMaterial" {
  12444. import { Scene } from "babylonjs/scene";
  12445. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12447. import { Mesh } from "babylonjs/Meshes/mesh";
  12448. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12450. import { Texture } from "babylonjs/Materials/Textures/texture";
  12451. import { Material } from "babylonjs/Materials/material";
  12452. /**
  12453. * Defines the options associated with the creation of a shader material.
  12454. */
  12455. export interface IShaderMaterialOptions {
  12456. /**
  12457. * Does the material work in alpha blend mode
  12458. */
  12459. needAlphaBlending: boolean;
  12460. /**
  12461. * Does the material work in alpha test mode
  12462. */
  12463. needAlphaTesting: boolean;
  12464. /**
  12465. * The list of attribute names used in the shader
  12466. */
  12467. attributes: string[];
  12468. /**
  12469. * The list of unifrom names used in the shader
  12470. */
  12471. uniforms: string[];
  12472. /**
  12473. * The list of UBO names used in the shader
  12474. */
  12475. uniformBuffers: string[];
  12476. /**
  12477. * The list of sampler names used in the shader
  12478. */
  12479. samplers: string[];
  12480. /**
  12481. * The list of defines used in the shader
  12482. */
  12483. defines: string[];
  12484. }
  12485. /**
  12486. * 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.
  12487. *
  12488. * This returned material effects how the mesh will look based on the code in the shaders.
  12489. *
  12490. * @see http://doc.babylonjs.com/how_to/shader_material
  12491. */
  12492. export class ShaderMaterial extends Material {
  12493. private _shaderPath;
  12494. private _options;
  12495. private _textures;
  12496. private _textureArrays;
  12497. private _floats;
  12498. private _ints;
  12499. private _floatsArrays;
  12500. private _colors3;
  12501. private _colors3Arrays;
  12502. private _colors4;
  12503. private _colors4Arrays;
  12504. private _vectors2;
  12505. private _vectors3;
  12506. private _vectors4;
  12507. private _matrices;
  12508. private _matrices3x3;
  12509. private _matrices2x2;
  12510. private _vectors2Arrays;
  12511. private _vectors3Arrays;
  12512. private _vectors4Arrays;
  12513. private _cachedWorldViewMatrix;
  12514. private _cachedWorldViewProjectionMatrix;
  12515. private _renderId;
  12516. /**
  12517. * Instantiate a new shader material.
  12518. * 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.
  12519. * This returned material effects how the mesh will look based on the code in the shaders.
  12520. * @see http://doc.babylonjs.com/how_to/shader_material
  12521. * @param name Define the name of the material in the scene
  12522. * @param scene Define the scene the material belongs to
  12523. * @param shaderPath Defines the route to the shader code in one of three ways:
  12524. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12525. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12526. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12527. * @param options Define the options used to create the shader
  12528. */
  12529. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12530. /**
  12531. * Gets the options used to compile the shader.
  12532. * They can be modified to trigger a new compilation
  12533. */
  12534. readonly options: IShaderMaterialOptions;
  12535. /**
  12536. * Gets the current class name of the material e.g. "ShaderMaterial"
  12537. * Mainly use in serialization.
  12538. * @returns the class name
  12539. */
  12540. getClassName(): string;
  12541. /**
  12542. * Specifies if the material will require alpha blending
  12543. * @returns a boolean specifying if alpha blending is needed
  12544. */
  12545. needAlphaBlending(): boolean;
  12546. /**
  12547. * Specifies if this material should be rendered in alpha test mode
  12548. * @returns a boolean specifying if an alpha test is needed.
  12549. */
  12550. needAlphaTesting(): boolean;
  12551. private _checkUniform;
  12552. /**
  12553. * Set a texture in the shader.
  12554. * @param name Define the name of the uniform samplers as defined in the shader
  12555. * @param texture Define the texture to bind to this sampler
  12556. * @return the material itself allowing "fluent" like uniform updates
  12557. */
  12558. setTexture(name: string, texture: Texture): ShaderMaterial;
  12559. /**
  12560. * Set a texture array in the shader.
  12561. * @param name Define the name of the uniform sampler array as defined in the shader
  12562. * @param textures Define the list of textures to bind to this sampler
  12563. * @return the material itself allowing "fluent" like uniform updates
  12564. */
  12565. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12566. /**
  12567. * Set a float in the shader.
  12568. * @param name Define the name of the uniform as defined in the shader
  12569. * @param value Define the value to give to the uniform
  12570. * @return the material itself allowing "fluent" like uniform updates
  12571. */
  12572. setFloat(name: string, value: number): ShaderMaterial;
  12573. /**
  12574. * Set a int in the shader.
  12575. * @param name Define the name of the uniform as defined in the shader
  12576. * @param value Define the value to give to the uniform
  12577. * @return the material itself allowing "fluent" like uniform updates
  12578. */
  12579. setInt(name: string, value: number): ShaderMaterial;
  12580. /**
  12581. * Set an array of floats in the shader.
  12582. * @param name Define the name of the uniform as defined in the shader
  12583. * @param value Define the value to give to the uniform
  12584. * @return the material itself allowing "fluent" like uniform updates
  12585. */
  12586. setFloats(name: string, value: number[]): ShaderMaterial;
  12587. /**
  12588. * Set a vec3 in the shader from a Color3.
  12589. * @param name Define the name of the uniform as defined in the shader
  12590. * @param value Define the value to give to the uniform
  12591. * @return the material itself allowing "fluent" like uniform updates
  12592. */
  12593. setColor3(name: string, value: Color3): ShaderMaterial;
  12594. /**
  12595. * Set a vec3 array in the shader from a Color3 array.
  12596. * @param name Define the name of the uniform as defined in the shader
  12597. * @param value Define the value to give to the uniform
  12598. * @return the material itself allowing "fluent" like uniform updates
  12599. */
  12600. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12601. /**
  12602. * Set a vec4 in the shader from a Color4.
  12603. * @param name Define the name of the uniform as defined in the shader
  12604. * @param value Define the value to give to the uniform
  12605. * @return the material itself allowing "fluent" like uniform updates
  12606. */
  12607. setColor4(name: string, value: Color4): ShaderMaterial;
  12608. /**
  12609. * Set a vec4 array in the shader from a Color4 array.
  12610. * @param name Define the name of the uniform as defined in the shader
  12611. * @param value Define the value to give to the uniform
  12612. * @return the material itself allowing "fluent" like uniform updates
  12613. */
  12614. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12615. /**
  12616. * Set a vec2 in the shader from a Vector2.
  12617. * @param name Define the name of the uniform as defined in the shader
  12618. * @param value Define the value to give to the uniform
  12619. * @return the material itself allowing "fluent" like uniform updates
  12620. */
  12621. setVector2(name: string, value: Vector2): ShaderMaterial;
  12622. /**
  12623. * Set a vec3 in the shader from a Vector3.
  12624. * @param name Define the name of the uniform as defined in the shader
  12625. * @param value Define the value to give to the uniform
  12626. * @return the material itself allowing "fluent" like uniform updates
  12627. */
  12628. setVector3(name: string, value: Vector3): ShaderMaterial;
  12629. /**
  12630. * Set a vec4 in the shader from a Vector4.
  12631. * @param name Define the name of the uniform as defined in the shader
  12632. * @param value Define the value to give to the uniform
  12633. * @return the material itself allowing "fluent" like uniform updates
  12634. */
  12635. setVector4(name: string, value: Vector4): ShaderMaterial;
  12636. /**
  12637. * Set a mat4 in the shader from a Matrix.
  12638. * @param name Define the name of the uniform as defined in the shader
  12639. * @param value Define the value to give to the uniform
  12640. * @return the material itself allowing "fluent" like uniform updates
  12641. */
  12642. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12643. /**
  12644. * Set a mat3 in the shader from a Float32Array.
  12645. * @param name Define the name of the uniform as defined in the shader
  12646. * @param value Define the value to give to the uniform
  12647. * @return the material itself allowing "fluent" like uniform updates
  12648. */
  12649. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12650. /**
  12651. * Set a mat2 in the shader from a Float32Array.
  12652. * @param name Define the name of the uniform as defined in the shader
  12653. * @param value Define the value to give to the uniform
  12654. * @return the material itself allowing "fluent" like uniform updates
  12655. */
  12656. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12657. /**
  12658. * Set a vec2 array in the shader from a number array.
  12659. * @param name Define the name of the uniform as defined in the shader
  12660. * @param value Define the value to give to the uniform
  12661. * @return the material itself allowing "fluent" like uniform updates
  12662. */
  12663. setArray2(name: string, value: number[]): ShaderMaterial;
  12664. /**
  12665. * Set a vec3 array in the shader from a number array.
  12666. * @param name Define the name of the uniform as defined in the shader
  12667. * @param value Define the value to give to the uniform
  12668. * @return the material itself allowing "fluent" like uniform updates
  12669. */
  12670. setArray3(name: string, value: number[]): ShaderMaterial;
  12671. /**
  12672. * Set a vec4 array in the shader from a number array.
  12673. * @param name Define the name of the uniform as defined in the shader
  12674. * @param value Define the value to give to the uniform
  12675. * @return the material itself allowing "fluent" like uniform updates
  12676. */
  12677. setArray4(name: string, value: number[]): ShaderMaterial;
  12678. private _checkCache;
  12679. /**
  12680. * Specifies that the submesh is ready to be used
  12681. * @param mesh defines the mesh to check
  12682. * @param subMesh defines which submesh to check
  12683. * @param useInstances specifies that instances should be used
  12684. * @returns a boolean indicating that the submesh is ready or not
  12685. */
  12686. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12687. /**
  12688. * Checks if the material is ready to render the requested mesh
  12689. * @param mesh Define the mesh to render
  12690. * @param useInstances Define whether or not the material is used with instances
  12691. * @returns true if ready, otherwise false
  12692. */
  12693. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12694. /**
  12695. * Binds the world matrix to the material
  12696. * @param world defines the world transformation matrix
  12697. */
  12698. bindOnlyWorldMatrix(world: Matrix): void;
  12699. /**
  12700. * Binds the material to the mesh
  12701. * @param world defines the world transformation matrix
  12702. * @param mesh defines the mesh to bind the material to
  12703. */
  12704. bind(world: Matrix, mesh?: Mesh): void;
  12705. /**
  12706. * Gets the active textures from the material
  12707. * @returns an array of textures
  12708. */
  12709. getActiveTextures(): BaseTexture[];
  12710. /**
  12711. * Specifies if the material uses a texture
  12712. * @param texture defines the texture to check against the material
  12713. * @returns a boolean specifying if the material uses the texture
  12714. */
  12715. hasTexture(texture: BaseTexture): boolean;
  12716. /**
  12717. * Makes a duplicate of the material, and gives it a new name
  12718. * @param name defines the new name for the duplicated material
  12719. * @returns the cloned material
  12720. */
  12721. clone(name: string): ShaderMaterial;
  12722. /**
  12723. * Disposes the material
  12724. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12725. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12726. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12727. */
  12728. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12729. /**
  12730. * Serializes this material in a JSON representation
  12731. * @returns the serialized material object
  12732. */
  12733. serialize(): any;
  12734. /**
  12735. * Creates a shader material from parsed shader material data
  12736. * @param source defines the JSON represnetation of the material
  12737. * @param scene defines the hosting scene
  12738. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12739. * @returns a new material
  12740. */
  12741. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12742. }
  12743. }
  12744. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12745. /** @hidden */
  12746. export var clipPlaneFragmentDeclaration: {
  12747. name: string;
  12748. shader: string;
  12749. };
  12750. }
  12751. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12752. /** @hidden */
  12753. export var clipPlaneFragment: {
  12754. name: string;
  12755. shader: string;
  12756. };
  12757. }
  12758. declare module "babylonjs/Shaders/color.fragment" {
  12759. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12760. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12761. /** @hidden */
  12762. export var colorPixelShader: {
  12763. name: string;
  12764. shader: string;
  12765. };
  12766. }
  12767. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12768. /** @hidden */
  12769. export var clipPlaneVertexDeclaration: {
  12770. name: string;
  12771. shader: string;
  12772. };
  12773. }
  12774. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12775. /** @hidden */
  12776. export var clipPlaneVertex: {
  12777. name: string;
  12778. shader: string;
  12779. };
  12780. }
  12781. declare module "babylonjs/Shaders/color.vertex" {
  12782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12783. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12784. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12785. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12786. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12787. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12788. /** @hidden */
  12789. export var colorVertexShader: {
  12790. name: string;
  12791. shader: string;
  12792. };
  12793. }
  12794. declare module "babylonjs/Meshes/linesMesh" {
  12795. import { Nullable } from "babylonjs/types";
  12796. import { Scene } from "babylonjs/scene";
  12797. import { Color3 } from "babylonjs/Maths/math";
  12798. import { Node } from "babylonjs/node";
  12799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12800. import { Mesh } from "babylonjs/Meshes/mesh";
  12801. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12802. import { Effect } from "babylonjs/Materials/effect";
  12803. import { Material } from "babylonjs/Materials/material";
  12804. import "babylonjs/Shaders/color.fragment";
  12805. import "babylonjs/Shaders/color.vertex";
  12806. /**
  12807. * Line mesh
  12808. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12809. */
  12810. export class LinesMesh extends Mesh {
  12811. /**
  12812. * If vertex color should be applied to the mesh
  12813. */
  12814. readonly useVertexColor?: boolean | undefined;
  12815. /**
  12816. * If vertex alpha should be applied to the mesh
  12817. */
  12818. readonly useVertexAlpha?: boolean | undefined;
  12819. /**
  12820. * Color of the line (Default: White)
  12821. */
  12822. color: Color3;
  12823. /**
  12824. * Alpha of the line (Default: 1)
  12825. */
  12826. alpha: number;
  12827. /**
  12828. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12829. * This margin is expressed in world space coordinates, so its value may vary.
  12830. * Default value is 0.1
  12831. */
  12832. intersectionThreshold: number;
  12833. private _colorShader;
  12834. private color4;
  12835. /**
  12836. * Creates a new LinesMesh
  12837. * @param name defines the name
  12838. * @param scene defines the hosting scene
  12839. * @param parent defines the parent mesh if any
  12840. * @param source defines the optional source LinesMesh used to clone data from
  12841. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12842. * When false, achieved by calling a clone(), also passing False.
  12843. * This will make creation of children, recursive.
  12844. * @param useVertexColor defines if this LinesMesh supports vertex color
  12845. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12846. */
  12847. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12848. /**
  12849. * If vertex color should be applied to the mesh
  12850. */
  12851. useVertexColor?: boolean | undefined,
  12852. /**
  12853. * If vertex alpha should be applied to the mesh
  12854. */
  12855. useVertexAlpha?: boolean | undefined);
  12856. private _addClipPlaneDefine;
  12857. private _removeClipPlaneDefine;
  12858. isReady(): boolean;
  12859. /**
  12860. * Returns the string "LineMesh"
  12861. */
  12862. getClassName(): string;
  12863. /**
  12864. * @hidden
  12865. */
  12866. /**
  12867. * @hidden
  12868. */
  12869. material: Material;
  12870. /**
  12871. * @hidden
  12872. */
  12873. readonly checkCollisions: boolean;
  12874. /** @hidden */
  12875. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12876. /** @hidden */
  12877. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12878. /**
  12879. * Disposes of the line mesh
  12880. * @param doNotRecurse If children should be disposed
  12881. */
  12882. dispose(doNotRecurse?: boolean): void;
  12883. /**
  12884. * Returns a new LineMesh object cloned from the current one.
  12885. */
  12886. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12887. /**
  12888. * Creates a new InstancedLinesMesh object from the mesh model.
  12889. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12890. * @param name defines the name of the new instance
  12891. * @returns a new InstancedLinesMesh
  12892. */
  12893. createInstance(name: string): InstancedLinesMesh;
  12894. }
  12895. /**
  12896. * Creates an instance based on a source LinesMesh
  12897. */
  12898. export class InstancedLinesMesh extends InstancedMesh {
  12899. /**
  12900. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12901. * This margin is expressed in world space coordinates, so its value may vary.
  12902. * Initilized with the intersectionThreshold value of the source LinesMesh
  12903. */
  12904. intersectionThreshold: number;
  12905. constructor(name: string, source: LinesMesh);
  12906. /**
  12907. * Returns the string "InstancedLinesMesh".
  12908. */
  12909. getClassName(): string;
  12910. }
  12911. }
  12912. declare module "babylonjs/Meshes/groundMesh" {
  12913. import { Scene } from "babylonjs/scene";
  12914. import { Vector3 } from "babylonjs/Maths/math";
  12915. import { Mesh } from "babylonjs/Meshes/mesh";
  12916. /**
  12917. * Mesh representing the gorund
  12918. */
  12919. export class GroundMesh extends Mesh {
  12920. /** If octree should be generated */
  12921. generateOctree: boolean;
  12922. private _heightQuads;
  12923. /** @hidden */
  12924. _subdivisionsX: number;
  12925. /** @hidden */
  12926. _subdivisionsY: number;
  12927. /** @hidden */
  12928. _width: number;
  12929. /** @hidden */
  12930. _height: number;
  12931. /** @hidden */
  12932. _minX: number;
  12933. /** @hidden */
  12934. _maxX: number;
  12935. /** @hidden */
  12936. _minZ: number;
  12937. /** @hidden */
  12938. _maxZ: number;
  12939. constructor(name: string, scene: Scene);
  12940. /**
  12941. * "GroundMesh"
  12942. * @returns "GroundMesh"
  12943. */
  12944. getClassName(): string;
  12945. /**
  12946. * The minimum of x and y subdivisions
  12947. */
  12948. readonly subdivisions: number;
  12949. /**
  12950. * X subdivisions
  12951. */
  12952. readonly subdivisionsX: number;
  12953. /**
  12954. * Y subdivisions
  12955. */
  12956. readonly subdivisionsY: number;
  12957. /**
  12958. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12959. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12960. * @param chunksCount the number of subdivisions for x and y
  12961. * @param octreeBlocksSize (Default: 32)
  12962. */
  12963. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12964. /**
  12965. * Returns a height (y) value in the Worl system :
  12966. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12967. * @param x x coordinate
  12968. * @param z z coordinate
  12969. * @returns the ground y position if (x, z) are outside the ground surface.
  12970. */
  12971. getHeightAtCoordinates(x: number, z: number): number;
  12972. /**
  12973. * Returns a normalized vector (Vector3) orthogonal to the ground
  12974. * at the ground coordinates (x, z) expressed in the World system.
  12975. * @param x x coordinate
  12976. * @param z z coordinate
  12977. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12978. */
  12979. getNormalAtCoordinates(x: number, z: number): Vector3;
  12980. /**
  12981. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12982. * at the ground coordinates (x, z) expressed in the World system.
  12983. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12984. * @param x x coordinate
  12985. * @param z z coordinate
  12986. * @param ref vector to store the result
  12987. * @returns the GroundMesh.
  12988. */
  12989. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12990. /**
  12991. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12992. * if the ground has been updated.
  12993. * This can be used in the render loop.
  12994. * @returns the GroundMesh.
  12995. */
  12996. updateCoordinateHeights(): GroundMesh;
  12997. private _getFacetAt;
  12998. private _initHeightQuads;
  12999. private _computeHeightQuads;
  13000. /**
  13001. * Serializes this ground mesh
  13002. * @param serializationObject object to write serialization to
  13003. */
  13004. serialize(serializationObject: any): void;
  13005. /**
  13006. * Parses a serialized ground mesh
  13007. * @param parsedMesh the serialized mesh
  13008. * @param scene the scene to create the ground mesh in
  13009. * @returns the created ground mesh
  13010. */
  13011. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13012. }
  13013. }
  13014. declare module "babylonjs/Physics/physicsJoint" {
  13015. import { Vector3 } from "babylonjs/Maths/math";
  13016. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13017. /**
  13018. * Interface for Physics-Joint data
  13019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13020. */
  13021. export interface PhysicsJointData {
  13022. /**
  13023. * The main pivot of the joint
  13024. */
  13025. mainPivot?: Vector3;
  13026. /**
  13027. * The connected pivot of the joint
  13028. */
  13029. connectedPivot?: Vector3;
  13030. /**
  13031. * The main axis of the joint
  13032. */
  13033. mainAxis?: Vector3;
  13034. /**
  13035. * The connected axis of the joint
  13036. */
  13037. connectedAxis?: Vector3;
  13038. /**
  13039. * The collision of the joint
  13040. */
  13041. collision?: boolean;
  13042. /**
  13043. * Native Oimo/Cannon/Energy data
  13044. */
  13045. nativeParams?: any;
  13046. }
  13047. /**
  13048. * This is a holder class for the physics joint created by the physics plugin
  13049. * It holds a set of functions to control the underlying joint
  13050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13051. */
  13052. export class PhysicsJoint {
  13053. /**
  13054. * The type of the physics joint
  13055. */
  13056. type: number;
  13057. /**
  13058. * The data for the physics joint
  13059. */
  13060. jointData: PhysicsJointData;
  13061. private _physicsJoint;
  13062. protected _physicsPlugin: IPhysicsEnginePlugin;
  13063. /**
  13064. * Initializes the physics joint
  13065. * @param type The type of the physics joint
  13066. * @param jointData The data for the physics joint
  13067. */
  13068. constructor(
  13069. /**
  13070. * The type of the physics joint
  13071. */
  13072. type: number,
  13073. /**
  13074. * The data for the physics joint
  13075. */
  13076. jointData: PhysicsJointData);
  13077. /**
  13078. * Gets the physics joint
  13079. */
  13080. /**
  13081. * Sets the physics joint
  13082. */
  13083. physicsJoint: any;
  13084. /**
  13085. * Sets the physics plugin
  13086. */
  13087. physicsPlugin: IPhysicsEnginePlugin;
  13088. /**
  13089. * Execute a function that is physics-plugin specific.
  13090. * @param {Function} func the function that will be executed.
  13091. * It accepts two parameters: the physics world and the physics joint
  13092. */
  13093. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13094. /**
  13095. * Distance-Joint type
  13096. */
  13097. static DistanceJoint: number;
  13098. /**
  13099. * Hinge-Joint type
  13100. */
  13101. static HingeJoint: number;
  13102. /**
  13103. * Ball-and-Socket joint type
  13104. */
  13105. static BallAndSocketJoint: number;
  13106. /**
  13107. * Wheel-Joint type
  13108. */
  13109. static WheelJoint: number;
  13110. /**
  13111. * Slider-Joint type
  13112. */
  13113. static SliderJoint: number;
  13114. /**
  13115. * Prismatic-Joint type
  13116. */
  13117. static PrismaticJoint: number;
  13118. /**
  13119. * Universal-Joint type
  13120. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13121. */
  13122. static UniversalJoint: number;
  13123. /**
  13124. * Hinge-Joint 2 type
  13125. */
  13126. static Hinge2Joint: number;
  13127. /**
  13128. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13129. */
  13130. static PointToPointJoint: number;
  13131. /**
  13132. * Spring-Joint type
  13133. */
  13134. static SpringJoint: number;
  13135. /**
  13136. * Lock-Joint type
  13137. */
  13138. static LockJoint: number;
  13139. }
  13140. /**
  13141. * A class representing a physics distance joint
  13142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13143. */
  13144. export class DistanceJoint extends PhysicsJoint {
  13145. /**
  13146. *
  13147. * @param jointData The data for the Distance-Joint
  13148. */
  13149. constructor(jointData: DistanceJointData);
  13150. /**
  13151. * Update the predefined distance.
  13152. * @param maxDistance The maximum preferred distance
  13153. * @param minDistance The minimum preferred distance
  13154. */
  13155. updateDistance(maxDistance: number, minDistance?: number): void;
  13156. }
  13157. /**
  13158. * Represents a Motor-Enabled Joint
  13159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13160. */
  13161. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13162. /**
  13163. * Initializes the Motor-Enabled Joint
  13164. * @param type The type of the joint
  13165. * @param jointData The physica joint data for the joint
  13166. */
  13167. constructor(type: number, jointData: PhysicsJointData);
  13168. /**
  13169. * Set the motor values.
  13170. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13171. * @param force the force to apply
  13172. * @param maxForce max force for this motor.
  13173. */
  13174. setMotor(force?: number, maxForce?: number): void;
  13175. /**
  13176. * Set the motor's limits.
  13177. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13178. * @param upperLimit The upper limit of the motor
  13179. * @param lowerLimit The lower limit of the motor
  13180. */
  13181. setLimit(upperLimit: number, lowerLimit?: number): void;
  13182. }
  13183. /**
  13184. * This class represents a single physics Hinge-Joint
  13185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13186. */
  13187. export class HingeJoint extends MotorEnabledJoint {
  13188. /**
  13189. * Initializes the Hinge-Joint
  13190. * @param jointData The joint data for the Hinge-Joint
  13191. */
  13192. constructor(jointData: PhysicsJointData);
  13193. /**
  13194. * Set the motor values.
  13195. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13196. * @param {number} force the force to apply
  13197. * @param {number} maxForce max force for this motor.
  13198. */
  13199. setMotor(force?: number, maxForce?: number): void;
  13200. /**
  13201. * Set the motor's limits.
  13202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13203. * @param upperLimit The upper limit of the motor
  13204. * @param lowerLimit The lower limit of the motor
  13205. */
  13206. setLimit(upperLimit: number, lowerLimit?: number): void;
  13207. }
  13208. /**
  13209. * This class represents a dual hinge physics joint (same as wheel joint)
  13210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13211. */
  13212. export class Hinge2Joint extends MotorEnabledJoint {
  13213. /**
  13214. * Initializes the Hinge2-Joint
  13215. * @param jointData The joint data for the Hinge2-Joint
  13216. */
  13217. constructor(jointData: PhysicsJointData);
  13218. /**
  13219. * Set the motor values.
  13220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13221. * @param {number} targetSpeed the speed the motor is to reach
  13222. * @param {number} maxForce max force for this motor.
  13223. * @param {motorIndex} the motor's index, 0 or 1.
  13224. */
  13225. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13226. /**
  13227. * Set the motor limits.
  13228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13229. * @param {number} upperLimit the upper limit
  13230. * @param {number} lowerLimit lower limit
  13231. * @param {motorIndex} the motor's index, 0 or 1.
  13232. */
  13233. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13234. }
  13235. /**
  13236. * Interface for a motor enabled joint
  13237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13238. */
  13239. export interface IMotorEnabledJoint {
  13240. /**
  13241. * Physics joint
  13242. */
  13243. physicsJoint: any;
  13244. /**
  13245. * Sets the motor of the motor-enabled joint
  13246. * @param force The force of the motor
  13247. * @param maxForce The maximum force of the motor
  13248. * @param motorIndex The index of the motor
  13249. */
  13250. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13251. /**
  13252. * Sets the limit of the motor
  13253. * @param upperLimit The upper limit of the motor
  13254. * @param lowerLimit The lower limit of the motor
  13255. * @param motorIndex The index of the motor
  13256. */
  13257. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13258. }
  13259. /**
  13260. * Joint data for a Distance-Joint
  13261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13262. */
  13263. export interface DistanceJointData extends PhysicsJointData {
  13264. /**
  13265. * Max distance the 2 joint objects can be apart
  13266. */
  13267. maxDistance: number;
  13268. }
  13269. /**
  13270. * Joint data from a spring joint
  13271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13272. */
  13273. export interface SpringJointData extends PhysicsJointData {
  13274. /**
  13275. * Length of the spring
  13276. */
  13277. length: number;
  13278. /**
  13279. * Stiffness of the spring
  13280. */
  13281. stiffness: number;
  13282. /**
  13283. * Damping of the spring
  13284. */
  13285. damping: number;
  13286. /** this callback will be called when applying the force to the impostors. */
  13287. forceApplicationCallback: () => void;
  13288. }
  13289. }
  13290. declare module "babylonjs/Physics/physicsRaycastResult" {
  13291. import { Vector3 } from "babylonjs/Maths/math";
  13292. /**
  13293. * Holds the data for the raycast result
  13294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13295. */
  13296. export class PhysicsRaycastResult {
  13297. private _hasHit;
  13298. private _hitDistance;
  13299. private _hitNormalWorld;
  13300. private _hitPointWorld;
  13301. private _rayFromWorld;
  13302. private _rayToWorld;
  13303. /**
  13304. * Gets if there was a hit
  13305. */
  13306. readonly hasHit: boolean;
  13307. /**
  13308. * Gets the distance from the hit
  13309. */
  13310. readonly hitDistance: number;
  13311. /**
  13312. * Gets the hit normal/direction in the world
  13313. */
  13314. readonly hitNormalWorld: Vector3;
  13315. /**
  13316. * Gets the hit point in the world
  13317. */
  13318. readonly hitPointWorld: Vector3;
  13319. /**
  13320. * Gets the ray "start point" of the ray in the world
  13321. */
  13322. readonly rayFromWorld: Vector3;
  13323. /**
  13324. * Gets the ray "end point" of the ray in the world
  13325. */
  13326. readonly rayToWorld: Vector3;
  13327. /**
  13328. * Sets the hit data (normal & point in world space)
  13329. * @param hitNormalWorld defines the normal in world space
  13330. * @param hitPointWorld defines the point in world space
  13331. */
  13332. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13333. /**
  13334. * Sets the distance from the start point to the hit point
  13335. * @param distance
  13336. */
  13337. setHitDistance(distance: number): void;
  13338. /**
  13339. * Calculates the distance manually
  13340. */
  13341. calculateHitDistance(): void;
  13342. /**
  13343. * Resets all the values to default
  13344. * @param from The from point on world space
  13345. * @param to The to point on world space
  13346. */
  13347. reset(from?: Vector3, to?: Vector3): void;
  13348. }
  13349. /**
  13350. * Interface for the size containing width and height
  13351. */
  13352. interface IXYZ {
  13353. /**
  13354. * X
  13355. */
  13356. x: number;
  13357. /**
  13358. * Y
  13359. */
  13360. y: number;
  13361. /**
  13362. * Z
  13363. */
  13364. z: number;
  13365. }
  13366. }
  13367. declare module "babylonjs/Physics/IPhysicsEngine" {
  13368. import { Nullable } from "babylonjs/types";
  13369. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13371. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13372. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13373. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13374. /**
  13375. * Interface used to describe a physics joint
  13376. */
  13377. export interface PhysicsImpostorJoint {
  13378. /** Defines the main impostor to which the joint is linked */
  13379. mainImpostor: PhysicsImpostor;
  13380. /** Defines the impostor that is connected to the main impostor using this joint */
  13381. connectedImpostor: PhysicsImpostor;
  13382. /** Defines the joint itself */
  13383. joint: PhysicsJoint;
  13384. }
  13385. /** @hidden */
  13386. export interface IPhysicsEnginePlugin {
  13387. world: any;
  13388. name: string;
  13389. setGravity(gravity: Vector3): void;
  13390. setTimeStep(timeStep: number): void;
  13391. getTimeStep(): number;
  13392. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13393. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13394. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13395. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13396. removePhysicsBody(impostor: PhysicsImpostor): void;
  13397. generateJoint(joint: PhysicsImpostorJoint): void;
  13398. removeJoint(joint: PhysicsImpostorJoint): void;
  13399. isSupported(): boolean;
  13400. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13401. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13402. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13403. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13404. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13405. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13406. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13407. getBodyMass(impostor: PhysicsImpostor): number;
  13408. getBodyFriction(impostor: PhysicsImpostor): number;
  13409. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13410. getBodyRestitution(impostor: PhysicsImpostor): number;
  13411. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13412. getBodyPressure?(impostor: PhysicsImpostor): number;
  13413. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13414. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13415. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13416. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13417. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13418. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13419. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13420. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13421. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13422. sleepBody(impostor: PhysicsImpostor): void;
  13423. wakeUpBody(impostor: PhysicsImpostor): void;
  13424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13425. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13426. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13427. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13428. getRadius(impostor: PhysicsImpostor): number;
  13429. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13430. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13431. dispose(): void;
  13432. }
  13433. /**
  13434. * Interface used to define a physics engine
  13435. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13436. */
  13437. export interface IPhysicsEngine {
  13438. /**
  13439. * Gets the gravity vector used by the simulation
  13440. */
  13441. gravity: Vector3;
  13442. /**
  13443. * Sets the gravity vector used by the simulation
  13444. * @param gravity defines the gravity vector to use
  13445. */
  13446. setGravity(gravity: Vector3): void;
  13447. /**
  13448. * Set the time step of the physics engine.
  13449. * Default is 1/60.
  13450. * To slow it down, enter 1/600 for example.
  13451. * To speed it up, 1/30
  13452. * @param newTimeStep the new timestep to apply to this world.
  13453. */
  13454. setTimeStep(newTimeStep: number): void;
  13455. /**
  13456. * Get the time step of the physics engine.
  13457. * @returns the current time step
  13458. */
  13459. getTimeStep(): number;
  13460. /**
  13461. * Release all resources
  13462. */
  13463. dispose(): void;
  13464. /**
  13465. * Gets the name of the current physics plugin
  13466. * @returns the name of the plugin
  13467. */
  13468. getPhysicsPluginName(): string;
  13469. /**
  13470. * Adding a new impostor for the impostor tracking.
  13471. * This will be done by the impostor itself.
  13472. * @param impostor the impostor to add
  13473. */
  13474. addImpostor(impostor: PhysicsImpostor): void;
  13475. /**
  13476. * Remove an impostor from the engine.
  13477. * This impostor and its mesh will not longer be updated by the physics engine.
  13478. * @param impostor the impostor to remove
  13479. */
  13480. removeImpostor(impostor: PhysicsImpostor): void;
  13481. /**
  13482. * Add a joint to the physics engine
  13483. * @param mainImpostor defines the main impostor to which the joint is added.
  13484. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13485. * @param joint defines the joint that will connect both impostors.
  13486. */
  13487. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13488. /**
  13489. * Removes a joint from the simulation
  13490. * @param mainImpostor defines the impostor used with the joint
  13491. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13492. * @param joint defines the joint to remove
  13493. */
  13494. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13495. /**
  13496. * Gets the current plugin used to run the simulation
  13497. * @returns current plugin
  13498. */
  13499. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13500. /**
  13501. * Gets the list of physic impostors
  13502. * @returns an array of PhysicsImpostor
  13503. */
  13504. getImpostors(): Array<PhysicsImpostor>;
  13505. /**
  13506. * Gets the impostor for a physics enabled object
  13507. * @param object defines the object impersonated by the impostor
  13508. * @returns the PhysicsImpostor or null if not found
  13509. */
  13510. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13511. /**
  13512. * Gets the impostor for a physics body object
  13513. * @param body defines physics body used by the impostor
  13514. * @returns the PhysicsImpostor or null if not found
  13515. */
  13516. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13517. /**
  13518. * Does a raycast in the physics world
  13519. * @param from when should the ray start?
  13520. * @param to when should the ray end?
  13521. * @returns PhysicsRaycastResult
  13522. */
  13523. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13524. /**
  13525. * Called by the scene. No need to call it.
  13526. * @param delta defines the timespam between frames
  13527. */
  13528. _step(delta: number): void;
  13529. }
  13530. }
  13531. declare module "babylonjs/Physics/physicsImpostor" {
  13532. import { Nullable, IndicesArray } from "babylonjs/types";
  13533. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13534. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13536. import { Scene } from "babylonjs/scene";
  13537. import { Bone } from "babylonjs/Bones/bone";
  13538. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13539. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13540. /**
  13541. * The interface for the physics imposter parameters
  13542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13543. */
  13544. export interface PhysicsImpostorParameters {
  13545. /**
  13546. * The mass of the physics imposter
  13547. */
  13548. mass: number;
  13549. /**
  13550. * The friction of the physics imposter
  13551. */
  13552. friction?: number;
  13553. /**
  13554. * The coefficient of restitution of the physics imposter
  13555. */
  13556. restitution?: number;
  13557. /**
  13558. * The native options of the physics imposter
  13559. */
  13560. nativeOptions?: any;
  13561. /**
  13562. * Specifies if the parent should be ignored
  13563. */
  13564. ignoreParent?: boolean;
  13565. /**
  13566. * Specifies if bi-directional transformations should be disabled
  13567. */
  13568. disableBidirectionalTransformation?: boolean;
  13569. /**
  13570. * The pressure inside the physics imposter, soft object only
  13571. */
  13572. pressure?: number;
  13573. /**
  13574. * The stiffness the physics imposter, soft object only
  13575. */
  13576. stiffness?: number;
  13577. /**
  13578. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13579. */
  13580. velocityIterations?: number;
  13581. /**
  13582. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13583. */
  13584. positionIterations?: number;
  13585. /**
  13586. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13587. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13588. * Add to fix multiple points
  13589. */
  13590. fixedPoints?: number;
  13591. /**
  13592. * The collision margin around a soft object
  13593. */
  13594. margin?: number;
  13595. /**
  13596. * The collision margin around a soft object
  13597. */
  13598. damping?: number;
  13599. /**
  13600. * The path for a rope based on an extrusion
  13601. */
  13602. path?: any;
  13603. /**
  13604. * The shape of an extrusion used for a rope based on an extrusion
  13605. */
  13606. shape?: any;
  13607. }
  13608. /**
  13609. * Interface for a physics-enabled object
  13610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13611. */
  13612. export interface IPhysicsEnabledObject {
  13613. /**
  13614. * The position of the physics-enabled object
  13615. */
  13616. position: Vector3;
  13617. /**
  13618. * The rotation of the physics-enabled object
  13619. */
  13620. rotationQuaternion: Nullable<Quaternion>;
  13621. /**
  13622. * The scale of the physics-enabled object
  13623. */
  13624. scaling: Vector3;
  13625. /**
  13626. * The rotation of the physics-enabled object
  13627. */
  13628. rotation?: Vector3;
  13629. /**
  13630. * The parent of the physics-enabled object
  13631. */
  13632. parent?: any;
  13633. /**
  13634. * The bounding info of the physics-enabled object
  13635. * @returns The bounding info of the physics-enabled object
  13636. */
  13637. getBoundingInfo(): BoundingInfo;
  13638. /**
  13639. * Computes the world matrix
  13640. * @param force Specifies if the world matrix should be computed by force
  13641. * @returns A world matrix
  13642. */
  13643. computeWorldMatrix(force: boolean): Matrix;
  13644. /**
  13645. * Gets the world matrix
  13646. * @returns A world matrix
  13647. */
  13648. getWorldMatrix?(): Matrix;
  13649. /**
  13650. * Gets the child meshes
  13651. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13652. * @returns An array of abstract meshes
  13653. */
  13654. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13655. /**
  13656. * Gets the vertex data
  13657. * @param kind The type of vertex data
  13658. * @returns A nullable array of numbers, or a float32 array
  13659. */
  13660. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13661. /**
  13662. * Gets the indices from the mesh
  13663. * @returns A nullable array of index arrays
  13664. */
  13665. getIndices?(): Nullable<IndicesArray>;
  13666. /**
  13667. * Gets the scene from the mesh
  13668. * @returns the indices array or null
  13669. */
  13670. getScene?(): Scene;
  13671. /**
  13672. * Gets the absolute position from the mesh
  13673. * @returns the absolute position
  13674. */
  13675. getAbsolutePosition(): Vector3;
  13676. /**
  13677. * Gets the absolute pivot point from the mesh
  13678. * @returns the absolute pivot point
  13679. */
  13680. getAbsolutePivotPoint(): Vector3;
  13681. /**
  13682. * Rotates the mesh
  13683. * @param axis The axis of rotation
  13684. * @param amount The amount of rotation
  13685. * @param space The space of the rotation
  13686. * @returns The rotation transform node
  13687. */
  13688. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13689. /**
  13690. * Translates the mesh
  13691. * @param axis The axis of translation
  13692. * @param distance The distance of translation
  13693. * @param space The space of the translation
  13694. * @returns The transform node
  13695. */
  13696. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13697. /**
  13698. * Sets the absolute position of the mesh
  13699. * @param absolutePosition The absolute position of the mesh
  13700. * @returns The transform node
  13701. */
  13702. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13703. /**
  13704. * Gets the class name of the mesh
  13705. * @returns The class name
  13706. */
  13707. getClassName(): string;
  13708. }
  13709. /**
  13710. * Represents a physics imposter
  13711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13712. */
  13713. export class PhysicsImpostor {
  13714. /**
  13715. * The physics-enabled object used as the physics imposter
  13716. */
  13717. object: IPhysicsEnabledObject;
  13718. /**
  13719. * The type of the physics imposter
  13720. */
  13721. type: number;
  13722. private _options;
  13723. private _scene?;
  13724. /**
  13725. * The default object size of the imposter
  13726. */
  13727. static DEFAULT_OBJECT_SIZE: Vector3;
  13728. /**
  13729. * The identity quaternion of the imposter
  13730. */
  13731. static IDENTITY_QUATERNION: Quaternion;
  13732. /** @hidden */
  13733. _pluginData: any;
  13734. private _physicsEngine;
  13735. private _physicsBody;
  13736. private _bodyUpdateRequired;
  13737. private _onBeforePhysicsStepCallbacks;
  13738. private _onAfterPhysicsStepCallbacks;
  13739. /** @hidden */
  13740. _onPhysicsCollideCallbacks: Array<{
  13741. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13742. otherImpostors: Array<PhysicsImpostor>;
  13743. }>;
  13744. private _deltaPosition;
  13745. private _deltaRotation;
  13746. private _deltaRotationConjugated;
  13747. /** @hidden */
  13748. _isFromLine: boolean;
  13749. private _parent;
  13750. private _isDisposed;
  13751. private static _tmpVecs;
  13752. private static _tmpQuat;
  13753. /**
  13754. * Specifies if the physics imposter is disposed
  13755. */
  13756. readonly isDisposed: boolean;
  13757. /**
  13758. * Gets the mass of the physics imposter
  13759. */
  13760. mass: number;
  13761. /**
  13762. * Gets the coefficient of friction
  13763. */
  13764. /**
  13765. * Sets the coefficient of friction
  13766. */
  13767. friction: number;
  13768. /**
  13769. * Gets the coefficient of restitution
  13770. */
  13771. /**
  13772. * Sets the coefficient of restitution
  13773. */
  13774. restitution: number;
  13775. /**
  13776. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13777. */
  13778. /**
  13779. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13780. */
  13781. pressure: number;
  13782. /**
  13783. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13784. */
  13785. /**
  13786. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13787. */
  13788. stiffness: number;
  13789. /**
  13790. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13791. */
  13792. /**
  13793. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13794. */
  13795. velocityIterations: number;
  13796. /**
  13797. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13798. */
  13799. /**
  13800. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13801. */
  13802. positionIterations: number;
  13803. /**
  13804. * The unique id of the physics imposter
  13805. * set by the physics engine when adding this impostor to the array
  13806. */
  13807. uniqueId: number;
  13808. /**
  13809. * @hidden
  13810. */
  13811. soft: boolean;
  13812. /**
  13813. * @hidden
  13814. */
  13815. segments: number;
  13816. private _joints;
  13817. /**
  13818. * Initializes the physics imposter
  13819. * @param object The physics-enabled object used as the physics imposter
  13820. * @param type The type of the physics imposter
  13821. * @param _options The options for the physics imposter
  13822. * @param _scene The Babylon scene
  13823. */
  13824. constructor(
  13825. /**
  13826. * The physics-enabled object used as the physics imposter
  13827. */
  13828. object: IPhysicsEnabledObject,
  13829. /**
  13830. * The type of the physics imposter
  13831. */
  13832. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13833. /**
  13834. * This function will completly initialize this impostor.
  13835. * It will create a new body - but only if this mesh has no parent.
  13836. * If it has, this impostor will not be used other than to define the impostor
  13837. * of the child mesh.
  13838. * @hidden
  13839. */
  13840. _init(): void;
  13841. private _getPhysicsParent;
  13842. /**
  13843. * Should a new body be generated.
  13844. * @returns boolean specifying if body initialization is required
  13845. */
  13846. isBodyInitRequired(): boolean;
  13847. /**
  13848. * Sets the updated scaling
  13849. * @param updated Specifies if the scaling is updated
  13850. */
  13851. setScalingUpdated(): void;
  13852. /**
  13853. * Force a regeneration of this or the parent's impostor's body.
  13854. * Use under cautious - This will remove all joints already implemented.
  13855. */
  13856. forceUpdate(): void;
  13857. /**
  13858. * Gets the body that holds this impostor. Either its own, or its parent.
  13859. */
  13860. /**
  13861. * Set the physics body. Used mainly by the physics engine/plugin
  13862. */
  13863. physicsBody: any;
  13864. /**
  13865. * Get the parent of the physics imposter
  13866. * @returns Physics imposter or null
  13867. */
  13868. /**
  13869. * Sets the parent of the physics imposter
  13870. */
  13871. parent: Nullable<PhysicsImpostor>;
  13872. /**
  13873. * Resets the update flags
  13874. */
  13875. resetUpdateFlags(): void;
  13876. /**
  13877. * Gets the object extend size
  13878. * @returns the object extend size
  13879. */
  13880. getObjectExtendSize(): Vector3;
  13881. /**
  13882. * Gets the object center
  13883. * @returns The object center
  13884. */
  13885. getObjectCenter(): Vector3;
  13886. /**
  13887. * Get a specific parametes from the options parameter
  13888. * @param paramName The object parameter name
  13889. * @returns The object parameter
  13890. */
  13891. getParam(paramName: string): any;
  13892. /**
  13893. * Sets a specific parameter in the options given to the physics plugin
  13894. * @param paramName The parameter name
  13895. * @param value The value of the parameter
  13896. */
  13897. setParam(paramName: string, value: number): void;
  13898. /**
  13899. * Specifically change the body's mass option. Won't recreate the physics body object
  13900. * @param mass The mass of the physics imposter
  13901. */
  13902. setMass(mass: number): void;
  13903. /**
  13904. * Gets the linear velocity
  13905. * @returns linear velocity or null
  13906. */
  13907. getLinearVelocity(): Nullable<Vector3>;
  13908. /**
  13909. * Sets the linear velocity
  13910. * @param velocity linear velocity or null
  13911. */
  13912. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13913. /**
  13914. * Gets the angular velocity
  13915. * @returns angular velocity or null
  13916. */
  13917. getAngularVelocity(): Nullable<Vector3>;
  13918. /**
  13919. * Sets the angular velocity
  13920. * @param velocity The velocity or null
  13921. */
  13922. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13923. /**
  13924. * Execute a function with the physics plugin native code
  13925. * Provide a function the will have two variables - the world object and the physics body object
  13926. * @param func The function to execute with the physics plugin native code
  13927. */
  13928. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13929. /**
  13930. * Register a function that will be executed before the physics world is stepping forward
  13931. * @param func The function to execute before the physics world is stepped forward
  13932. */
  13933. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13934. /**
  13935. * Unregister a function that will be executed before the physics world is stepping forward
  13936. * @param func The function to execute before the physics world is stepped forward
  13937. */
  13938. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13939. /**
  13940. * Register a function that will be executed after the physics step
  13941. * @param func The function to execute after physics step
  13942. */
  13943. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13944. /**
  13945. * Unregisters a function that will be executed after the physics step
  13946. * @param func The function to execute after physics step
  13947. */
  13948. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13949. /**
  13950. * register a function that will be executed when this impostor collides against a different body
  13951. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13952. * @param func Callback that is executed on collision
  13953. */
  13954. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13955. /**
  13956. * Unregisters the physics imposter on contact
  13957. * @param collideAgainst The physics object to collide against
  13958. * @param func Callback to execute on collision
  13959. */
  13960. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13961. private _tmpQuat;
  13962. private _tmpQuat2;
  13963. /**
  13964. * Get the parent rotation
  13965. * @returns The parent rotation
  13966. */
  13967. getParentsRotation(): Quaternion;
  13968. /**
  13969. * this function is executed by the physics engine.
  13970. */
  13971. beforeStep: () => void;
  13972. /**
  13973. * this function is executed by the physics engine
  13974. */
  13975. afterStep: () => void;
  13976. /**
  13977. * Legacy collision detection event support
  13978. */
  13979. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13980. /**
  13981. * event and body object due to cannon's event-based architecture.
  13982. */
  13983. onCollide: (e: {
  13984. body: any;
  13985. }) => void;
  13986. /**
  13987. * Apply a force
  13988. * @param force The force to apply
  13989. * @param contactPoint The contact point for the force
  13990. * @returns The physics imposter
  13991. */
  13992. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13993. /**
  13994. * Apply an impulse
  13995. * @param force The impulse force
  13996. * @param contactPoint The contact point for the impulse force
  13997. * @returns The physics imposter
  13998. */
  13999. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14000. /**
  14001. * A help function to create a joint
  14002. * @param otherImpostor A physics imposter used to create a joint
  14003. * @param jointType The type of joint
  14004. * @param jointData The data for the joint
  14005. * @returns The physics imposter
  14006. */
  14007. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14008. /**
  14009. * Add a joint to this impostor with a different impostor
  14010. * @param otherImpostor A physics imposter used to add a joint
  14011. * @param joint The joint to add
  14012. * @returns The physics imposter
  14013. */
  14014. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14015. /**
  14016. * Add an anchor to a cloth impostor
  14017. * @param otherImpostor rigid impostor to anchor to
  14018. * @param width ratio across width from 0 to 1
  14019. * @param height ratio up height from 0 to 1
  14020. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14021. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14022. * @returns impostor the soft imposter
  14023. */
  14024. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14025. /**
  14026. * Add a hook to a rope impostor
  14027. * @param otherImpostor rigid impostor to anchor to
  14028. * @param length ratio across rope from 0 to 1
  14029. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14030. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14031. * @returns impostor the rope imposter
  14032. */
  14033. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14034. /**
  14035. * Will keep this body still, in a sleep mode.
  14036. * @returns the physics imposter
  14037. */
  14038. sleep(): PhysicsImpostor;
  14039. /**
  14040. * Wake the body up.
  14041. * @returns The physics imposter
  14042. */
  14043. wakeUp(): PhysicsImpostor;
  14044. /**
  14045. * Clones the physics imposter
  14046. * @param newObject The physics imposter clones to this physics-enabled object
  14047. * @returns A nullable physics imposter
  14048. */
  14049. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14050. /**
  14051. * Disposes the physics imposter
  14052. */
  14053. dispose(): void;
  14054. /**
  14055. * Sets the delta position
  14056. * @param position The delta position amount
  14057. */
  14058. setDeltaPosition(position: Vector3): void;
  14059. /**
  14060. * Sets the delta rotation
  14061. * @param rotation The delta rotation amount
  14062. */
  14063. setDeltaRotation(rotation: Quaternion): void;
  14064. /**
  14065. * Gets the box size of the physics imposter and stores the result in the input parameter
  14066. * @param result Stores the box size
  14067. * @returns The physics imposter
  14068. */
  14069. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14070. /**
  14071. * Gets the radius of the physics imposter
  14072. * @returns Radius of the physics imposter
  14073. */
  14074. getRadius(): number;
  14075. /**
  14076. * Sync a bone with this impostor
  14077. * @param bone The bone to sync to the impostor.
  14078. * @param boneMesh The mesh that the bone is influencing.
  14079. * @param jointPivot The pivot of the joint / bone in local space.
  14080. * @param distToJoint Optional distance from the impostor to the joint.
  14081. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14082. */
  14083. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14084. /**
  14085. * Sync impostor to a bone
  14086. * @param bone The bone that the impostor will be synced to.
  14087. * @param boneMesh The mesh that the bone is influencing.
  14088. * @param jointPivot The pivot of the joint / bone in local space.
  14089. * @param distToJoint Optional distance from the impostor to the joint.
  14090. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14091. * @param boneAxis Optional vector3 axis the bone is aligned with
  14092. */
  14093. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14094. /**
  14095. * No-Imposter type
  14096. */
  14097. static NoImpostor: number;
  14098. /**
  14099. * Sphere-Imposter type
  14100. */
  14101. static SphereImpostor: number;
  14102. /**
  14103. * Box-Imposter type
  14104. */
  14105. static BoxImpostor: number;
  14106. /**
  14107. * Plane-Imposter type
  14108. */
  14109. static PlaneImpostor: number;
  14110. /**
  14111. * Mesh-imposter type
  14112. */
  14113. static MeshImpostor: number;
  14114. /**
  14115. * Capsule-Impostor type (Ammo.js plugin only)
  14116. */
  14117. static CapsuleImpostor: number;
  14118. /**
  14119. * Cylinder-Imposter type
  14120. */
  14121. static CylinderImpostor: number;
  14122. /**
  14123. * Particle-Imposter type
  14124. */
  14125. static ParticleImpostor: number;
  14126. /**
  14127. * Heightmap-Imposter type
  14128. */
  14129. static HeightmapImpostor: number;
  14130. /**
  14131. * ConvexHull-Impostor type (Ammo.js plugin only)
  14132. */
  14133. static ConvexHullImpostor: number;
  14134. /**
  14135. * Rope-Imposter type
  14136. */
  14137. static RopeImpostor: number;
  14138. /**
  14139. * Cloth-Imposter type
  14140. */
  14141. static ClothImpostor: number;
  14142. /**
  14143. * Softbody-Imposter type
  14144. */
  14145. static SoftbodyImpostor: number;
  14146. }
  14147. }
  14148. declare module "babylonjs/Meshes/mesh" {
  14149. import { Observable } from "babylonjs/Misc/observable";
  14150. import { IAnimatable } from "babylonjs/Misc/tools";
  14151. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14152. import { Camera } from "babylonjs/Cameras/camera";
  14153. import { Scene } from "babylonjs/scene";
  14154. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14155. import { Engine } from "babylonjs/Engines/engine";
  14156. import { Node } from "babylonjs/node";
  14157. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14158. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14159. import { Buffer } from "babylonjs/Meshes/buffer";
  14160. import { Geometry } from "babylonjs/Meshes/geometry";
  14161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14163. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14164. import { Effect } from "babylonjs/Materials/effect";
  14165. import { Material } from "babylonjs/Materials/material";
  14166. import { Skeleton } from "babylonjs/Bones/skeleton";
  14167. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14168. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14169. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14170. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14171. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14172. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14173. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14174. /**
  14175. * @hidden
  14176. **/
  14177. export class _CreationDataStorage {
  14178. closePath?: boolean;
  14179. closeArray?: boolean;
  14180. idx: number[];
  14181. dashSize: number;
  14182. gapSize: number;
  14183. path3D: Path3D;
  14184. pathArray: Vector3[][];
  14185. arc: number;
  14186. radius: number;
  14187. cap: number;
  14188. tessellation: number;
  14189. }
  14190. /**
  14191. * @hidden
  14192. **/
  14193. class _InstanceDataStorage {
  14194. visibleInstances: any;
  14195. batchCache: _InstancesBatch;
  14196. instancesBufferSize: number;
  14197. instancesBuffer: Nullable<Buffer>;
  14198. instancesData: Float32Array;
  14199. overridenInstanceCount: number;
  14200. isFrozen: boolean;
  14201. previousBatch: Nullable<_InstancesBatch>;
  14202. hardwareInstancedRendering: boolean;
  14203. sideOrientation: number;
  14204. }
  14205. /**
  14206. * @hidden
  14207. **/
  14208. export class _InstancesBatch {
  14209. mustReturn: boolean;
  14210. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14211. renderSelf: boolean[];
  14212. hardwareInstancedRendering: boolean[];
  14213. }
  14214. /**
  14215. * Class used to represent renderable models
  14216. */
  14217. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14218. /**
  14219. * Mesh side orientation : usually the external or front surface
  14220. */
  14221. static readonly FRONTSIDE: number;
  14222. /**
  14223. * Mesh side orientation : usually the internal or back surface
  14224. */
  14225. static readonly BACKSIDE: number;
  14226. /**
  14227. * Mesh side orientation : both internal and external or front and back surfaces
  14228. */
  14229. static readonly DOUBLESIDE: number;
  14230. /**
  14231. * Mesh side orientation : by default, `FRONTSIDE`
  14232. */
  14233. static readonly DEFAULTSIDE: number;
  14234. /**
  14235. * Mesh cap setting : no cap
  14236. */
  14237. static readonly NO_CAP: number;
  14238. /**
  14239. * Mesh cap setting : one cap at the beginning of the mesh
  14240. */
  14241. static readonly CAP_START: number;
  14242. /**
  14243. * Mesh cap setting : one cap at the end of the mesh
  14244. */
  14245. static readonly CAP_END: number;
  14246. /**
  14247. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14248. */
  14249. static readonly CAP_ALL: number;
  14250. /**
  14251. * Mesh pattern setting : no flip or rotate
  14252. */
  14253. static readonly NO_FLIP: number;
  14254. /**
  14255. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14256. */
  14257. static readonly FLIP_TILE: number;
  14258. /**
  14259. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14260. */
  14261. static readonly ROTATE_TILE: number;
  14262. /**
  14263. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14264. */
  14265. static readonly FLIP_ROW: number;
  14266. /**
  14267. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14268. */
  14269. static readonly ROTATE_ROW: number;
  14270. /**
  14271. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14272. */
  14273. static readonly FLIP_N_ROTATE_TILE: number;
  14274. /**
  14275. * Mesh pattern setting : rotate pattern and rotate
  14276. */
  14277. static readonly FLIP_N_ROTATE_ROW: number;
  14278. /**
  14279. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14280. */
  14281. static readonly CENTER: number;
  14282. /**
  14283. * Mesh tile positioning : part tiles on left
  14284. */
  14285. static readonly LEFT: number;
  14286. /**
  14287. * Mesh tile positioning : part tiles on right
  14288. */
  14289. static readonly RIGHT: number;
  14290. /**
  14291. * Mesh tile positioning : part tiles on top
  14292. */
  14293. static readonly TOP: number;
  14294. /**
  14295. * Mesh tile positioning : part tiles on bottom
  14296. */
  14297. static readonly BOTTOM: number;
  14298. /**
  14299. * Gets the default side orientation.
  14300. * @param orientation the orientation to value to attempt to get
  14301. * @returns the default orientation
  14302. * @hidden
  14303. */
  14304. static _GetDefaultSideOrientation(orientation?: number): number;
  14305. private _internalMeshDataInfo;
  14306. /**
  14307. * An event triggered before rendering the mesh
  14308. */
  14309. readonly onBeforeRenderObservable: Observable<Mesh>;
  14310. /**
  14311. * An event triggered before binding the mesh
  14312. */
  14313. readonly onBeforeBindObservable: Observable<Mesh>;
  14314. /**
  14315. * An event triggered after rendering the mesh
  14316. */
  14317. readonly onAfterRenderObservable: Observable<Mesh>;
  14318. /**
  14319. * An event triggered before drawing the mesh
  14320. */
  14321. readonly onBeforeDrawObservable: Observable<Mesh>;
  14322. private _onBeforeDrawObserver;
  14323. /**
  14324. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14325. */
  14326. onBeforeDraw: () => void;
  14327. /**
  14328. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14329. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14330. */
  14331. delayLoadState: number;
  14332. /**
  14333. * Gets the list of instances created from this mesh
  14334. * it is not supposed to be modified manually.
  14335. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14336. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14337. */
  14338. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14339. /**
  14340. * Gets the file containing delay loading data for this mesh
  14341. */
  14342. delayLoadingFile: string;
  14343. /** @hidden */
  14344. _binaryInfo: any;
  14345. /**
  14346. * User defined function used to change how LOD level selection is done
  14347. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14348. */
  14349. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14350. /**
  14351. * Gets or sets the morph target manager
  14352. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14353. */
  14354. morphTargetManager: Nullable<MorphTargetManager>;
  14355. /** @hidden */
  14356. _creationDataStorage: Nullable<_CreationDataStorage>;
  14357. /** @hidden */
  14358. _geometry: Nullable<Geometry>;
  14359. /** @hidden */
  14360. _delayInfo: Array<string>;
  14361. /** @hidden */
  14362. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14363. /** @hidden */
  14364. _instanceDataStorage: _InstanceDataStorage;
  14365. private _effectiveMaterial;
  14366. /** @hidden */
  14367. _shouldGenerateFlatShading: boolean;
  14368. /** @hidden */
  14369. _originalBuilderSideOrientation: number;
  14370. /**
  14371. * Use this property to change the original side orientation defined at construction time
  14372. */
  14373. overrideMaterialSideOrientation: Nullable<number>;
  14374. /**
  14375. * Gets the source mesh (the one used to clone this one from)
  14376. */
  14377. readonly source: Nullable<Mesh>;
  14378. /**
  14379. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14380. */
  14381. isUnIndexed: boolean;
  14382. /**
  14383. * @constructor
  14384. * @param name The value used by scene.getMeshByName() to do a lookup.
  14385. * @param scene The scene to add this mesh to.
  14386. * @param parent The parent of this mesh, if it has one
  14387. * @param source An optional Mesh from which geometry is shared, cloned.
  14388. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14389. * When false, achieved by calling a clone(), also passing False.
  14390. * This will make creation of children, recursive.
  14391. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14392. */
  14393. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14394. /**
  14395. * Gets the class name
  14396. * @returns the string "Mesh".
  14397. */
  14398. getClassName(): string;
  14399. /** @hidden */
  14400. readonly _isMesh: boolean;
  14401. /**
  14402. * Returns a description of this mesh
  14403. * @param fullDetails define if full details about this mesh must be used
  14404. * @returns a descriptive string representing this mesh
  14405. */
  14406. toString(fullDetails?: boolean): string;
  14407. /** @hidden */
  14408. _unBindEffect(): void;
  14409. /**
  14410. * Gets a boolean indicating if this mesh has LOD
  14411. */
  14412. readonly hasLODLevels: boolean;
  14413. /**
  14414. * Gets the list of MeshLODLevel associated with the current mesh
  14415. * @returns an array of MeshLODLevel
  14416. */
  14417. getLODLevels(): MeshLODLevel[];
  14418. private _sortLODLevels;
  14419. /**
  14420. * Add a mesh as LOD level triggered at the given distance.
  14421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14422. * @param distance The distance from the center of the object to show this level
  14423. * @param mesh The mesh to be added as LOD level (can be null)
  14424. * @return This mesh (for chaining)
  14425. */
  14426. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14427. /**
  14428. * Returns the LOD level mesh at the passed distance or null if not found.
  14429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14430. * @param distance The distance from the center of the object to show this level
  14431. * @returns a Mesh or `null`
  14432. */
  14433. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14434. /**
  14435. * Remove a mesh from the LOD array
  14436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14437. * @param mesh defines the mesh to be removed
  14438. * @return This mesh (for chaining)
  14439. */
  14440. removeLODLevel(mesh: Mesh): Mesh;
  14441. /**
  14442. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14444. * @param camera defines the camera to use to compute distance
  14445. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14446. * @return This mesh (for chaining)
  14447. */
  14448. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14449. /**
  14450. * Gets the mesh internal Geometry object
  14451. */
  14452. readonly geometry: Nullable<Geometry>;
  14453. /**
  14454. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14455. * @returns the total number of vertices
  14456. */
  14457. getTotalVertices(): number;
  14458. /**
  14459. * Returns the content of an associated vertex buffer
  14460. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14461. * - VertexBuffer.PositionKind
  14462. * - VertexBuffer.UVKind
  14463. * - VertexBuffer.UV2Kind
  14464. * - VertexBuffer.UV3Kind
  14465. * - VertexBuffer.UV4Kind
  14466. * - VertexBuffer.UV5Kind
  14467. * - VertexBuffer.UV6Kind
  14468. * - VertexBuffer.ColorKind
  14469. * - VertexBuffer.MatricesIndicesKind
  14470. * - VertexBuffer.MatricesIndicesExtraKind
  14471. * - VertexBuffer.MatricesWeightsKind
  14472. * - VertexBuffer.MatricesWeightsExtraKind
  14473. * @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
  14474. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14475. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14476. */
  14477. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14478. /**
  14479. * Returns the mesh VertexBuffer object from the requested `kind`
  14480. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14481. * - VertexBuffer.PositionKind
  14482. * - VertexBuffer.NormalKind
  14483. * - VertexBuffer.UVKind
  14484. * - VertexBuffer.UV2Kind
  14485. * - VertexBuffer.UV3Kind
  14486. * - VertexBuffer.UV4Kind
  14487. * - VertexBuffer.UV5Kind
  14488. * - VertexBuffer.UV6Kind
  14489. * - VertexBuffer.ColorKind
  14490. * - VertexBuffer.MatricesIndicesKind
  14491. * - VertexBuffer.MatricesIndicesExtraKind
  14492. * - VertexBuffer.MatricesWeightsKind
  14493. * - VertexBuffer.MatricesWeightsExtraKind
  14494. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14495. */
  14496. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14497. /**
  14498. * Tests if a specific vertex buffer is associated with this mesh
  14499. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14500. * - VertexBuffer.PositionKind
  14501. * - VertexBuffer.NormalKind
  14502. * - VertexBuffer.UVKind
  14503. * - VertexBuffer.UV2Kind
  14504. * - VertexBuffer.UV3Kind
  14505. * - VertexBuffer.UV4Kind
  14506. * - VertexBuffer.UV5Kind
  14507. * - VertexBuffer.UV6Kind
  14508. * - VertexBuffer.ColorKind
  14509. * - VertexBuffer.MatricesIndicesKind
  14510. * - VertexBuffer.MatricesIndicesExtraKind
  14511. * - VertexBuffer.MatricesWeightsKind
  14512. * - VertexBuffer.MatricesWeightsExtraKind
  14513. * @returns a boolean
  14514. */
  14515. isVerticesDataPresent(kind: string): boolean;
  14516. /**
  14517. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14518. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14519. * - VertexBuffer.PositionKind
  14520. * - VertexBuffer.UVKind
  14521. * - VertexBuffer.UV2Kind
  14522. * - VertexBuffer.UV3Kind
  14523. * - VertexBuffer.UV4Kind
  14524. * - VertexBuffer.UV5Kind
  14525. * - VertexBuffer.UV6Kind
  14526. * - VertexBuffer.ColorKind
  14527. * - VertexBuffer.MatricesIndicesKind
  14528. * - VertexBuffer.MatricesIndicesExtraKind
  14529. * - VertexBuffer.MatricesWeightsKind
  14530. * - VertexBuffer.MatricesWeightsExtraKind
  14531. * @returns a boolean
  14532. */
  14533. isVertexBufferUpdatable(kind: string): boolean;
  14534. /**
  14535. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14536. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14537. * - VertexBuffer.PositionKind
  14538. * - VertexBuffer.NormalKind
  14539. * - VertexBuffer.UVKind
  14540. * - VertexBuffer.UV2Kind
  14541. * - VertexBuffer.UV3Kind
  14542. * - VertexBuffer.UV4Kind
  14543. * - VertexBuffer.UV5Kind
  14544. * - VertexBuffer.UV6Kind
  14545. * - VertexBuffer.ColorKind
  14546. * - VertexBuffer.MatricesIndicesKind
  14547. * - VertexBuffer.MatricesIndicesExtraKind
  14548. * - VertexBuffer.MatricesWeightsKind
  14549. * - VertexBuffer.MatricesWeightsExtraKind
  14550. * @returns an array of strings
  14551. */
  14552. getVerticesDataKinds(): string[];
  14553. /**
  14554. * Returns a positive integer : the total number of indices in this mesh geometry.
  14555. * @returns the numner of indices or zero if the mesh has no geometry.
  14556. */
  14557. getTotalIndices(): number;
  14558. /**
  14559. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14560. * @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.
  14561. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14562. * @returns the indices array or an empty array if the mesh has no geometry
  14563. */
  14564. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14565. readonly isBlocked: boolean;
  14566. /**
  14567. * Determine if the current mesh is ready to be rendered
  14568. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14569. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14570. * @returns true if all associated assets are ready (material, textures, shaders)
  14571. */
  14572. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14573. /**
  14574. * 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.
  14575. */
  14576. readonly areNormalsFrozen: boolean;
  14577. /**
  14578. * 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.
  14579. * @returns the current mesh
  14580. */
  14581. freezeNormals(): Mesh;
  14582. /**
  14583. * 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
  14584. * @returns the current mesh
  14585. */
  14586. unfreezeNormals(): Mesh;
  14587. /**
  14588. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14589. */
  14590. overridenInstanceCount: number;
  14591. /** @hidden */
  14592. _preActivate(): Mesh;
  14593. /** @hidden */
  14594. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14595. /** @hidden */
  14596. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14597. /**
  14598. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14599. * This means the mesh underlying bounding box and sphere are recomputed.
  14600. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14601. * @returns the current mesh
  14602. */
  14603. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14604. /** @hidden */
  14605. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14606. /**
  14607. * This function will subdivide the mesh into multiple submeshes
  14608. * @param count defines the expected number of submeshes
  14609. */
  14610. subdivide(count: number): void;
  14611. /**
  14612. * Copy a FloatArray into a specific associated vertex buffer
  14613. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14614. * - VertexBuffer.PositionKind
  14615. * - VertexBuffer.UVKind
  14616. * - VertexBuffer.UV2Kind
  14617. * - VertexBuffer.UV3Kind
  14618. * - VertexBuffer.UV4Kind
  14619. * - VertexBuffer.UV5Kind
  14620. * - VertexBuffer.UV6Kind
  14621. * - VertexBuffer.ColorKind
  14622. * - VertexBuffer.MatricesIndicesKind
  14623. * - VertexBuffer.MatricesIndicesExtraKind
  14624. * - VertexBuffer.MatricesWeightsKind
  14625. * - VertexBuffer.MatricesWeightsExtraKind
  14626. * @param data defines the data source
  14627. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14628. * @param stride defines the data stride size (can be null)
  14629. * @returns the current mesh
  14630. */
  14631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14632. /**
  14633. * Flags an associated vertex buffer as updatable
  14634. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14635. * - VertexBuffer.PositionKind
  14636. * - VertexBuffer.UVKind
  14637. * - VertexBuffer.UV2Kind
  14638. * - VertexBuffer.UV3Kind
  14639. * - VertexBuffer.UV4Kind
  14640. * - VertexBuffer.UV5Kind
  14641. * - VertexBuffer.UV6Kind
  14642. * - VertexBuffer.ColorKind
  14643. * - VertexBuffer.MatricesIndicesKind
  14644. * - VertexBuffer.MatricesIndicesExtraKind
  14645. * - VertexBuffer.MatricesWeightsKind
  14646. * - VertexBuffer.MatricesWeightsExtraKind
  14647. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14648. */
  14649. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14650. /**
  14651. * Sets the mesh global Vertex Buffer
  14652. * @param buffer defines the buffer to use
  14653. * @returns the current mesh
  14654. */
  14655. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14656. /**
  14657. * Update a specific associated vertex buffer
  14658. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14659. * - VertexBuffer.PositionKind
  14660. * - VertexBuffer.UVKind
  14661. * - VertexBuffer.UV2Kind
  14662. * - VertexBuffer.UV3Kind
  14663. * - VertexBuffer.UV4Kind
  14664. * - VertexBuffer.UV5Kind
  14665. * - VertexBuffer.UV6Kind
  14666. * - VertexBuffer.ColorKind
  14667. * - VertexBuffer.MatricesIndicesKind
  14668. * - VertexBuffer.MatricesIndicesExtraKind
  14669. * - VertexBuffer.MatricesWeightsKind
  14670. * - VertexBuffer.MatricesWeightsExtraKind
  14671. * @param data defines the data source
  14672. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14673. * @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)
  14674. * @returns the current mesh
  14675. */
  14676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14677. /**
  14678. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14679. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14680. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14681. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14682. * @returns the current mesh
  14683. */
  14684. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14685. /**
  14686. * Creates a un-shared specific occurence of the geometry for the mesh.
  14687. * @returns the current mesh
  14688. */
  14689. makeGeometryUnique(): Mesh;
  14690. /**
  14691. * Set the index buffer of this mesh
  14692. * @param indices defines the source data
  14693. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14694. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14695. * @returns the current mesh
  14696. */
  14697. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14698. /**
  14699. * Update the current index buffer
  14700. * @param indices defines the source data
  14701. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14702. * @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)
  14703. * @returns the current mesh
  14704. */
  14705. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14706. /**
  14707. * Invert the geometry to move from a right handed system to a left handed one.
  14708. * @returns the current mesh
  14709. */
  14710. toLeftHanded(): Mesh;
  14711. /** @hidden */
  14712. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14713. /** @hidden */
  14714. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14715. /**
  14716. * Registers for this mesh a javascript function called just before the rendering process
  14717. * @param func defines the function to call before rendering this mesh
  14718. * @returns the current mesh
  14719. */
  14720. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14721. /**
  14722. * Disposes a previously registered javascript function called before the rendering
  14723. * @param func defines the function to remove
  14724. * @returns the current mesh
  14725. */
  14726. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14727. /**
  14728. * Registers for this mesh a javascript function called just after the rendering is complete
  14729. * @param func defines the function to call after rendering this mesh
  14730. * @returns the current mesh
  14731. */
  14732. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14733. /**
  14734. * Disposes a previously registered javascript function called after the rendering.
  14735. * @param func defines the function to remove
  14736. * @returns the current mesh
  14737. */
  14738. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14739. /** @hidden */
  14740. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14741. /** @hidden */
  14742. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14743. /** @hidden */
  14744. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14745. /** @hidden */
  14746. _rebuild(): void;
  14747. /** @hidden */
  14748. _freeze(): void;
  14749. /** @hidden */
  14750. _unFreeze(): void;
  14751. /**
  14752. * 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
  14753. * @param subMesh defines the subMesh to render
  14754. * @param enableAlphaMode defines if alpha mode can be changed
  14755. * @returns the current mesh
  14756. */
  14757. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14758. private _onBeforeDraw;
  14759. /**
  14760. * Renormalize the mesh and patch it up if there are no weights
  14761. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14762. * However in the case of zero weights then we set just a single influence to 1.
  14763. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14764. */
  14765. cleanMatrixWeights(): void;
  14766. private normalizeSkinFourWeights;
  14767. private normalizeSkinWeightsAndExtra;
  14768. /**
  14769. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14770. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14771. * the user know there was an issue with importing the mesh
  14772. * @returns a validation object with skinned, valid and report string
  14773. */
  14774. validateSkinning(): {
  14775. skinned: boolean;
  14776. valid: boolean;
  14777. report: string;
  14778. };
  14779. /** @hidden */
  14780. _checkDelayState(): Mesh;
  14781. private _queueLoad;
  14782. /**
  14783. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14784. * A mesh is in the frustum if its bounding box intersects the frustum
  14785. * @param frustumPlanes defines the frustum to test
  14786. * @returns true if the mesh is in the frustum planes
  14787. */
  14788. isInFrustum(frustumPlanes: Plane[]): boolean;
  14789. /**
  14790. * Sets the mesh material by the material or multiMaterial `id` property
  14791. * @param id is a string identifying the material or the multiMaterial
  14792. * @returns the current mesh
  14793. */
  14794. setMaterialByID(id: string): Mesh;
  14795. /**
  14796. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14797. * @returns an array of IAnimatable
  14798. */
  14799. getAnimatables(): IAnimatable[];
  14800. /**
  14801. * Modifies the mesh geometry according to the passed transformation matrix.
  14802. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14803. * The mesh normals are modified using the same transformation.
  14804. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14805. * @param transform defines the transform matrix to use
  14806. * @see http://doc.babylonjs.com/resources/baking_transformations
  14807. * @returns the current mesh
  14808. */
  14809. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14810. /**
  14811. * Modifies the mesh geometry according to its own current World Matrix.
  14812. * The mesh World Matrix is then reset.
  14813. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14814. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14815. * @see http://doc.babylonjs.com/resources/baking_transformations
  14816. * @returns the current mesh
  14817. */
  14818. bakeCurrentTransformIntoVertices(): Mesh;
  14819. /** @hidden */
  14820. readonly _positions: Nullable<Vector3[]>;
  14821. /** @hidden */
  14822. _resetPointsArrayCache(): Mesh;
  14823. /** @hidden */
  14824. _generatePointsArray(): boolean;
  14825. /**
  14826. * Returns a new Mesh object generated from the current mesh properties.
  14827. * This method must not get confused with createInstance()
  14828. * @param name is a string, the name given to the new mesh
  14829. * @param newParent can be any Node object (default `null`)
  14830. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14831. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14832. * @returns a new mesh
  14833. */
  14834. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14835. /**
  14836. * Releases resources associated with this mesh.
  14837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14839. */
  14840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14841. /**
  14842. * Modifies the mesh geometry according to a displacement map.
  14843. * 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.
  14844. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14845. * @param url is a string, the URL from the image file is to be downloaded.
  14846. * @param minHeight is the lower limit of the displacement.
  14847. * @param maxHeight is the upper limit of the displacement.
  14848. * @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.
  14849. * @param uvOffset is an optional vector2 used to offset UV.
  14850. * @param uvScale is an optional vector2 used to scale UV.
  14851. * @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.
  14852. * @returns the Mesh.
  14853. */
  14854. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14855. /**
  14856. * Modifies the mesh geometry according to a displacementMap buffer.
  14857. * 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.
  14858. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14859. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14860. * @param heightMapWidth is the width of the buffer image.
  14861. * @param heightMapHeight is the height of the buffer image.
  14862. * @param minHeight is the lower limit of the displacement.
  14863. * @param maxHeight is the upper limit of the displacement.
  14864. * @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.
  14865. * @param uvOffset is an optional vector2 used to offset UV.
  14866. * @param uvScale is an optional vector2 used to scale UV.
  14867. * @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.
  14868. * @returns the Mesh.
  14869. */
  14870. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14871. /**
  14872. * Modify the mesh to get a flat shading rendering.
  14873. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14874. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14875. * @returns current mesh
  14876. */
  14877. convertToFlatShadedMesh(): Mesh;
  14878. /**
  14879. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14880. * In other words, more vertices, no more indices and a single bigger VBO.
  14881. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14882. * @returns current mesh
  14883. */
  14884. convertToUnIndexedMesh(): Mesh;
  14885. /**
  14886. * Inverses facet orientations.
  14887. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14888. * @param flipNormals will also inverts the normals
  14889. * @returns current mesh
  14890. */
  14891. flipFaces(flipNormals?: boolean): Mesh;
  14892. /**
  14893. * Increase the number of facets and hence vertices in a mesh
  14894. * Vertex normals are interpolated from existing vertex normals
  14895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14896. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14897. */
  14898. increaseVertices(numberPerEdge: number): void;
  14899. /**
  14900. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14901. * This will undo any application of covertToFlatShadedMesh
  14902. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14903. */
  14904. forceSharedVertices(): void;
  14905. /** @hidden */
  14906. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14907. /** @hidden */
  14908. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14909. /**
  14910. * Creates a new InstancedMesh object from the mesh model.
  14911. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14912. * @param name defines the name of the new instance
  14913. * @returns a new InstancedMesh
  14914. */
  14915. createInstance(name: string): InstancedMesh;
  14916. /**
  14917. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14918. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14919. * @returns the current mesh
  14920. */
  14921. synchronizeInstances(): Mesh;
  14922. /**
  14923. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14924. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14925. * This should be used together with the simplification to avoid disappearing triangles.
  14926. * @param successCallback an optional success callback to be called after the optimization finished.
  14927. * @returns the current mesh
  14928. */
  14929. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14930. /**
  14931. * Serialize current mesh
  14932. * @param serializationObject defines the object which will receive the serialization data
  14933. */
  14934. serialize(serializationObject: any): void;
  14935. /** @hidden */
  14936. _syncGeometryWithMorphTargetManager(): void;
  14937. /** @hidden */
  14938. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14939. /**
  14940. * Returns a new Mesh object parsed from the source provided.
  14941. * @param parsedMesh is the source
  14942. * @param scene defines the hosting scene
  14943. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14944. * @returns a new Mesh
  14945. */
  14946. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14947. /**
  14948. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14949. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14950. * @param name defines the name of the mesh to create
  14951. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14952. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14953. * @param closePath creates a seam between the first and the last points of each path of the path array
  14954. * @param offset is taken in account only if the `pathArray` is containing a single path
  14955. * @param scene defines the hosting scene
  14956. * @param updatable defines if the mesh must be flagged as updatable
  14957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14958. * @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)
  14959. * @returns a new Mesh
  14960. */
  14961. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14962. /**
  14963. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14964. * @param name defines the name of the mesh to create
  14965. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14966. * @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
  14967. * @param scene defines the hosting scene
  14968. * @param updatable defines if the mesh must be flagged as updatable
  14969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14970. * @returns a new Mesh
  14971. */
  14972. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14973. /**
  14974. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14975. * @param name defines the name of the mesh to create
  14976. * @param size sets the size (float) of each box side (default 1)
  14977. * @param scene defines the hosting scene
  14978. * @param updatable defines if the mesh must be flagged as updatable
  14979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14980. * @returns a new Mesh
  14981. */
  14982. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14983. /**
  14984. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14985. * @param name defines the name of the mesh to create
  14986. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14987. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14988. * @param scene defines the hosting scene
  14989. * @param updatable defines if the mesh must be flagged as updatable
  14990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14991. * @returns a new Mesh
  14992. */
  14993. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14994. /**
  14995. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14996. * @param name defines the name of the mesh to create
  14997. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14998. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14999. * @param scene defines the hosting scene
  15000. * @returns a new Mesh
  15001. */
  15002. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15003. /**
  15004. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15005. * @param name defines the name of the mesh to create
  15006. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15007. * @param diameterTop set the top cap diameter (floats, default 1)
  15008. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15009. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15010. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15011. * @param scene defines the hosting scene
  15012. * @param updatable defines if the mesh must be flagged as updatable
  15013. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15014. * @returns a new Mesh
  15015. */
  15016. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15017. /**
  15018. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15019. * @param name defines the name of the mesh to create
  15020. * @param diameter sets the diameter size (float) of the torus (default 1)
  15021. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15022. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15023. * @param scene defines the hosting scene
  15024. * @param updatable defines if the mesh must be flagged as updatable
  15025. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15026. * @returns a new Mesh
  15027. */
  15028. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15029. /**
  15030. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15031. * @param name defines the name of the mesh to create
  15032. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15033. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15034. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15035. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15036. * @param p the number of windings on X axis (positive integers, default 2)
  15037. * @param q the number of windings on Y axis (positive integers, default 3)
  15038. * @param scene defines the hosting scene
  15039. * @param updatable defines if the mesh must be flagged as updatable
  15040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15041. * @returns a new Mesh
  15042. */
  15043. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15044. /**
  15045. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15046. * @param name defines the name of the mesh to create
  15047. * @param points is an array successive Vector3
  15048. * @param scene defines the hosting scene
  15049. * @param updatable defines if the mesh must be flagged as updatable
  15050. * @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).
  15051. * @returns a new Mesh
  15052. */
  15053. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15054. /**
  15055. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15056. * @param name defines the name of the mesh to create
  15057. * @param points is an array successive Vector3
  15058. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15059. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15060. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15061. * @param scene defines the hosting scene
  15062. * @param updatable defines if the mesh must be flagged as updatable
  15063. * @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)
  15064. * @returns a new Mesh
  15065. */
  15066. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15067. /**
  15068. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15070. * 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.
  15071. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15072. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15073. * Remember you can only change the shape positions, not their number when updating a polygon.
  15074. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15075. * @param name defines the name of the mesh to create
  15076. * @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
  15077. * @param scene defines the hosting scene
  15078. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15079. * @param updatable defines if the mesh must be flagged as updatable
  15080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15081. * @param earcutInjection can be used to inject your own earcut reference
  15082. * @returns a new Mesh
  15083. */
  15084. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15085. /**
  15086. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15087. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15088. * @param name defines the name of the mesh to create
  15089. * @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
  15090. * @param depth defines the height of extrusion
  15091. * @param scene defines the hosting scene
  15092. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15093. * @param updatable defines if the mesh must be flagged as updatable
  15094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15095. * @param earcutInjection can be used to inject your own earcut reference
  15096. * @returns a new Mesh
  15097. */
  15098. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15099. /**
  15100. * Creates an extruded shape mesh.
  15101. * 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
  15102. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15104. * @param name defines the name of the mesh to create
  15105. * @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
  15106. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15107. * @param scale is the value to scale the shape
  15108. * @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
  15109. * @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
  15110. * @param scene defines the hosting scene
  15111. * @param updatable defines if the mesh must be flagged as updatable
  15112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15113. * @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)
  15114. * @returns a new Mesh
  15115. */
  15116. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15117. /**
  15118. * Creates an custom extruded shape mesh.
  15119. * The custom extrusion is a parametric shape.
  15120. * It has no predefined shape. Its final shape will depend on the input parameters.
  15121. * Please consider using the same method from the MeshBuilder class instead
  15122. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15123. * @param name defines the name of the mesh to create
  15124. * @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
  15125. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15126. * @param scaleFunction is a custom Javascript function called on each path point
  15127. * @param rotationFunction is a custom Javascript function called on each path point
  15128. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15129. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15130. * @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
  15131. * @param scene defines the hosting scene
  15132. * @param updatable defines if the mesh must be flagged as updatable
  15133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15134. * @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)
  15135. * @returns a new Mesh
  15136. */
  15137. 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;
  15138. /**
  15139. * Creates lathe mesh.
  15140. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15141. * Please consider using the same method from the MeshBuilder class instead
  15142. * @param name defines the name of the mesh to create
  15143. * @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
  15144. * @param radius is the radius value of the lathe
  15145. * @param tessellation is the side number of the lathe.
  15146. * @param scene defines the hosting scene
  15147. * @param updatable defines if the mesh must be flagged as updatable
  15148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15149. * @returns a new Mesh
  15150. */
  15151. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15152. /**
  15153. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15154. * @param name defines the name of the mesh to create
  15155. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15156. * @param scene defines the hosting scene
  15157. * @param updatable defines if the mesh must be flagged as updatable
  15158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15159. * @returns a new Mesh
  15160. */
  15161. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15162. /**
  15163. * Creates a ground mesh.
  15164. * Please consider using the same method from the MeshBuilder class instead
  15165. * @param name defines the name of the mesh to create
  15166. * @param width set the width of the ground
  15167. * @param height set the height of the ground
  15168. * @param subdivisions sets the number of subdivisions per side
  15169. * @param scene defines the hosting scene
  15170. * @param updatable defines if the mesh must be flagged as updatable
  15171. * @returns a new Mesh
  15172. */
  15173. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15174. /**
  15175. * Creates a tiled ground mesh.
  15176. * Please consider using the same method from the MeshBuilder class instead
  15177. * @param name defines the name of the mesh to create
  15178. * @param xmin set the ground minimum X coordinate
  15179. * @param zmin set the ground minimum Y coordinate
  15180. * @param xmax set the ground maximum X coordinate
  15181. * @param zmax set the ground maximum Z coordinate
  15182. * @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
  15183. * @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
  15184. * @param scene defines the hosting scene
  15185. * @param updatable defines if the mesh must be flagged as updatable
  15186. * @returns a new Mesh
  15187. */
  15188. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15189. w: number;
  15190. h: number;
  15191. }, precision: {
  15192. w: number;
  15193. h: number;
  15194. }, scene: Scene, updatable?: boolean): Mesh;
  15195. /**
  15196. * Creates a ground mesh from a height map.
  15197. * Please consider using the same method from the MeshBuilder class instead
  15198. * @see http://doc.babylonjs.com/babylon101/height_map
  15199. * @param name defines the name of the mesh to create
  15200. * @param url sets the URL of the height map image resource
  15201. * @param width set the ground width size
  15202. * @param height set the ground height size
  15203. * @param subdivisions sets the number of subdivision per side
  15204. * @param minHeight is the minimum altitude on the ground
  15205. * @param maxHeight is the maximum altitude on the ground
  15206. * @param scene defines the hosting scene
  15207. * @param updatable defines if the mesh must be flagged as updatable
  15208. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15209. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15210. * @returns a new Mesh
  15211. */
  15212. 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;
  15213. /**
  15214. * Creates a tube mesh.
  15215. * The tube is a parametric shape.
  15216. * It has no predefined shape. Its final shape will depend on the input parameters.
  15217. * Please consider using the same method from the MeshBuilder class instead
  15218. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15219. * @param name defines the name of the mesh to create
  15220. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15221. * @param radius sets the tube radius size
  15222. * @param tessellation is the number of sides on the tubular surface
  15223. * @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
  15224. * @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
  15225. * @param scene defines the hosting scene
  15226. * @param updatable defines if the mesh must be flagged as updatable
  15227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15228. * @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)
  15229. * @returns a new Mesh
  15230. */
  15231. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15232. (i: number, distance: number): number;
  15233. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15234. /**
  15235. * Creates a polyhedron mesh.
  15236. * Please consider using the same method from the MeshBuilder class instead.
  15237. * * 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
  15238. * * The parameter `size` (positive float, default 1) sets the polygon size
  15239. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15240. * * 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`
  15241. * * 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
  15242. * * 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)`)
  15243. * * 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
  15244. * * 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
  15245. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15246. * * If you create a double-sided mesh, you can choose what parts of 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
  15247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15248. * @param name defines the name of the mesh to create
  15249. * @param options defines the options used to create the mesh
  15250. * @param scene defines the hosting scene
  15251. * @returns a new Mesh
  15252. */
  15253. static CreatePolyhedron(name: string, options: {
  15254. type?: number;
  15255. size?: number;
  15256. sizeX?: number;
  15257. sizeY?: number;
  15258. sizeZ?: number;
  15259. custom?: any;
  15260. faceUV?: Vector4[];
  15261. faceColors?: Color4[];
  15262. updatable?: boolean;
  15263. sideOrientation?: number;
  15264. }, scene: Scene): Mesh;
  15265. /**
  15266. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15267. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15268. * * 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`)
  15269. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15270. * * 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
  15271. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15272. * * If you create a double-sided mesh, you can choose what parts of 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
  15273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15274. * @param name defines the name of the mesh
  15275. * @param options defines the options used to create the mesh
  15276. * @param scene defines the hosting scene
  15277. * @returns a new Mesh
  15278. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15279. */
  15280. static CreateIcoSphere(name: string, options: {
  15281. radius?: number;
  15282. flat?: boolean;
  15283. subdivisions?: number;
  15284. sideOrientation?: number;
  15285. updatable?: boolean;
  15286. }, scene: Scene): Mesh;
  15287. /**
  15288. * Creates a decal mesh.
  15289. * Please consider using the same method from the MeshBuilder class instead.
  15290. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15291. * @param name defines the name of the mesh
  15292. * @param sourceMesh defines the mesh receiving the decal
  15293. * @param position sets the position of the decal in world coordinates
  15294. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15295. * @param size sets the decal scaling
  15296. * @param angle sets the angle to rotate the decal
  15297. * @returns a new Mesh
  15298. */
  15299. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15300. /**
  15301. * Prepare internal position array for software CPU skinning
  15302. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15303. */
  15304. setPositionsForCPUSkinning(): Float32Array;
  15305. /**
  15306. * Prepare internal normal array for software CPU skinning
  15307. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15308. */
  15309. setNormalsForCPUSkinning(): Float32Array;
  15310. /**
  15311. * Updates the vertex buffer by applying transformation from the bones
  15312. * @param skeleton defines the skeleton to apply to current mesh
  15313. * @returns the current mesh
  15314. */
  15315. applySkeleton(skeleton: Skeleton): Mesh;
  15316. /**
  15317. * 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
  15318. * @param meshes defines the list of meshes to scan
  15319. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15320. */
  15321. static MinMax(meshes: AbstractMesh[]): {
  15322. min: Vector3;
  15323. max: Vector3;
  15324. };
  15325. /**
  15326. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15327. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15328. * @returns a vector3
  15329. */
  15330. static Center(meshesOrMinMaxVector: {
  15331. min: Vector3;
  15332. max: Vector3;
  15333. } | AbstractMesh[]): Vector3;
  15334. /**
  15335. * Merge the array of meshes into a single mesh for performance reasons.
  15336. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15337. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15338. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15339. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15340. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15341. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15342. * @returns a new mesh
  15343. */
  15344. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15345. /** @hidden */
  15346. addInstance(instance: InstancedMesh): void;
  15347. /** @hidden */
  15348. removeInstance(instance: InstancedMesh): void;
  15349. }
  15350. }
  15351. declare module "babylonjs/Actions/action" {
  15352. import { Observable } from "babylonjs/Misc/observable";
  15353. import { Condition } from "babylonjs/Actions/condition";
  15354. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15355. import { ActionManager } from "babylonjs/Actions/actionManager";
  15356. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15357. /**
  15358. * Interface used to define Action
  15359. */
  15360. export interface IAction {
  15361. /**
  15362. * Trigger for the action
  15363. */
  15364. trigger: number;
  15365. /** Options of the trigger */
  15366. triggerOptions: any;
  15367. /**
  15368. * Gets the trigger parameters
  15369. * @returns the trigger parameters
  15370. */
  15371. getTriggerParameter(): any;
  15372. /**
  15373. * Internal only - executes current action event
  15374. * @hidden
  15375. */
  15376. _executeCurrent(evt?: ActionEvent): void;
  15377. /**
  15378. * Serialize placeholder for child classes
  15379. * @param parent of child
  15380. * @returns the serialized object
  15381. */
  15382. serialize(parent: any): any;
  15383. /**
  15384. * Internal only
  15385. * @hidden
  15386. */
  15387. _prepare(): void;
  15388. /**
  15389. * Internal only - manager for action
  15390. * @hidden
  15391. */
  15392. _actionManager: AbstractActionManager;
  15393. /**
  15394. * Adds action to chain of actions, may be a DoNothingAction
  15395. * @param action defines the next action to execute
  15396. * @returns The action passed in
  15397. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15398. */
  15399. then(action: IAction): IAction;
  15400. }
  15401. /**
  15402. * The action to be carried out following a trigger
  15403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15404. */
  15405. export class Action implements IAction {
  15406. /** the trigger, with or without parameters, for the action */
  15407. triggerOptions: any;
  15408. /**
  15409. * Trigger for the action
  15410. */
  15411. trigger: number;
  15412. /**
  15413. * Internal only - manager for action
  15414. * @hidden
  15415. */
  15416. _actionManager: ActionManager;
  15417. private _nextActiveAction;
  15418. private _child;
  15419. private _condition?;
  15420. private _triggerParameter;
  15421. /**
  15422. * An event triggered prior to action being executed.
  15423. */
  15424. onBeforeExecuteObservable: Observable<Action>;
  15425. /**
  15426. * Creates a new Action
  15427. * @param triggerOptions the trigger, with or without parameters, for the action
  15428. * @param condition an optional determinant of action
  15429. */
  15430. constructor(
  15431. /** the trigger, with or without parameters, for the action */
  15432. triggerOptions: any, condition?: Condition);
  15433. /**
  15434. * Internal only
  15435. * @hidden
  15436. */
  15437. _prepare(): void;
  15438. /**
  15439. * Gets the trigger parameters
  15440. * @returns the trigger parameters
  15441. */
  15442. getTriggerParameter(): any;
  15443. /**
  15444. * Internal only - executes current action event
  15445. * @hidden
  15446. */
  15447. _executeCurrent(evt?: ActionEvent): void;
  15448. /**
  15449. * Execute placeholder for child classes
  15450. * @param evt optional action event
  15451. */
  15452. execute(evt?: ActionEvent): void;
  15453. /**
  15454. * Skips to next active action
  15455. */
  15456. skipToNextActiveAction(): void;
  15457. /**
  15458. * Adds action to chain of actions, may be a DoNothingAction
  15459. * @param action defines the next action to execute
  15460. * @returns The action passed in
  15461. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15462. */
  15463. then(action: Action): Action;
  15464. /**
  15465. * Internal only
  15466. * @hidden
  15467. */
  15468. _getProperty(propertyPath: string): string;
  15469. /**
  15470. * Internal only
  15471. * @hidden
  15472. */
  15473. _getEffectiveTarget(target: any, propertyPath: string): any;
  15474. /**
  15475. * Serialize placeholder for child classes
  15476. * @param parent of child
  15477. * @returns the serialized object
  15478. */
  15479. serialize(parent: any): any;
  15480. /**
  15481. * Internal only called by serialize
  15482. * @hidden
  15483. */
  15484. protected _serialize(serializedAction: any, parent?: any): any;
  15485. /**
  15486. * Internal only
  15487. * @hidden
  15488. */
  15489. static _SerializeValueAsString: (value: any) => string;
  15490. /**
  15491. * Internal only
  15492. * @hidden
  15493. */
  15494. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15495. name: string;
  15496. targetType: string;
  15497. value: string;
  15498. };
  15499. }
  15500. }
  15501. declare module "babylonjs/Actions/condition" {
  15502. import { ActionManager } from "babylonjs/Actions/actionManager";
  15503. /**
  15504. * A Condition applied to an Action
  15505. */
  15506. export class Condition {
  15507. /**
  15508. * Internal only - manager for action
  15509. * @hidden
  15510. */
  15511. _actionManager: ActionManager;
  15512. /**
  15513. * Internal only
  15514. * @hidden
  15515. */
  15516. _evaluationId: number;
  15517. /**
  15518. * Internal only
  15519. * @hidden
  15520. */
  15521. _currentResult: boolean;
  15522. /**
  15523. * Creates a new Condition
  15524. * @param actionManager the manager of the action the condition is applied to
  15525. */
  15526. constructor(actionManager: ActionManager);
  15527. /**
  15528. * Check if the current condition is valid
  15529. * @returns a boolean
  15530. */
  15531. isValid(): boolean;
  15532. /**
  15533. * Internal only
  15534. * @hidden
  15535. */
  15536. _getProperty(propertyPath: string): string;
  15537. /**
  15538. * Internal only
  15539. * @hidden
  15540. */
  15541. _getEffectiveTarget(target: any, propertyPath: string): any;
  15542. /**
  15543. * Serialize placeholder for child classes
  15544. * @returns the serialized object
  15545. */
  15546. serialize(): any;
  15547. /**
  15548. * Internal only
  15549. * @hidden
  15550. */
  15551. protected _serialize(serializedCondition: any): any;
  15552. }
  15553. /**
  15554. * Defines specific conditional operators as extensions of Condition
  15555. */
  15556. export class ValueCondition extends Condition {
  15557. /** path to specify the property of the target the conditional operator uses */
  15558. propertyPath: string;
  15559. /** the value compared by the conditional operator against the current value of the property */
  15560. value: any;
  15561. /** the conditional operator, default ValueCondition.IsEqual */
  15562. operator: number;
  15563. /**
  15564. * Internal only
  15565. * @hidden
  15566. */
  15567. private static _IsEqual;
  15568. /**
  15569. * Internal only
  15570. * @hidden
  15571. */
  15572. private static _IsDifferent;
  15573. /**
  15574. * Internal only
  15575. * @hidden
  15576. */
  15577. private static _IsGreater;
  15578. /**
  15579. * Internal only
  15580. * @hidden
  15581. */
  15582. private static _IsLesser;
  15583. /**
  15584. * returns the number for IsEqual
  15585. */
  15586. static readonly IsEqual: number;
  15587. /**
  15588. * Returns the number for IsDifferent
  15589. */
  15590. static readonly IsDifferent: number;
  15591. /**
  15592. * Returns the number for IsGreater
  15593. */
  15594. static readonly IsGreater: number;
  15595. /**
  15596. * Returns the number for IsLesser
  15597. */
  15598. static readonly IsLesser: number;
  15599. /**
  15600. * Internal only The action manager for the condition
  15601. * @hidden
  15602. */
  15603. _actionManager: ActionManager;
  15604. /**
  15605. * Internal only
  15606. * @hidden
  15607. */
  15608. private _target;
  15609. /**
  15610. * Internal only
  15611. * @hidden
  15612. */
  15613. private _effectiveTarget;
  15614. /**
  15615. * Internal only
  15616. * @hidden
  15617. */
  15618. private _property;
  15619. /**
  15620. * Creates a new ValueCondition
  15621. * @param actionManager manager for the action the condition applies to
  15622. * @param target for the action
  15623. * @param propertyPath path to specify the property of the target the conditional operator uses
  15624. * @param value the value compared by the conditional operator against the current value of the property
  15625. * @param operator the conditional operator, default ValueCondition.IsEqual
  15626. */
  15627. constructor(actionManager: ActionManager, target: any,
  15628. /** path to specify the property of the target the conditional operator uses */
  15629. propertyPath: string,
  15630. /** the value compared by the conditional operator against the current value of the property */
  15631. value: any,
  15632. /** the conditional operator, default ValueCondition.IsEqual */
  15633. operator?: number);
  15634. /**
  15635. * Compares the given value with the property value for the specified conditional operator
  15636. * @returns the result of the comparison
  15637. */
  15638. isValid(): boolean;
  15639. /**
  15640. * Serialize the ValueCondition into a JSON compatible object
  15641. * @returns serialization object
  15642. */
  15643. serialize(): any;
  15644. /**
  15645. * Gets the name of the conditional operator for the ValueCondition
  15646. * @param operator the conditional operator
  15647. * @returns the name
  15648. */
  15649. static GetOperatorName(operator: number): string;
  15650. }
  15651. /**
  15652. * Defines a predicate condition as an extension of Condition
  15653. */
  15654. export class PredicateCondition extends Condition {
  15655. /** defines the predicate function used to validate the condition */
  15656. predicate: () => boolean;
  15657. /**
  15658. * Internal only - manager for action
  15659. * @hidden
  15660. */
  15661. _actionManager: ActionManager;
  15662. /**
  15663. * Creates a new PredicateCondition
  15664. * @param actionManager manager for the action the condition applies to
  15665. * @param predicate defines the predicate function used to validate the condition
  15666. */
  15667. constructor(actionManager: ActionManager,
  15668. /** defines the predicate function used to validate the condition */
  15669. predicate: () => boolean);
  15670. /**
  15671. * @returns the validity of the predicate condition
  15672. */
  15673. isValid(): boolean;
  15674. }
  15675. /**
  15676. * Defines a state condition as an extension of Condition
  15677. */
  15678. export class StateCondition extends Condition {
  15679. /** Value to compare with target state */
  15680. value: string;
  15681. /**
  15682. * Internal only - manager for action
  15683. * @hidden
  15684. */
  15685. _actionManager: ActionManager;
  15686. /**
  15687. * Internal only
  15688. * @hidden
  15689. */
  15690. private _target;
  15691. /**
  15692. * Creates a new StateCondition
  15693. * @param actionManager manager for the action the condition applies to
  15694. * @param target of the condition
  15695. * @param value to compare with target state
  15696. */
  15697. constructor(actionManager: ActionManager, target: any,
  15698. /** Value to compare with target state */
  15699. value: string);
  15700. /**
  15701. * Gets a boolean indicating if the current condition is met
  15702. * @returns the validity of the state
  15703. */
  15704. isValid(): boolean;
  15705. /**
  15706. * Serialize the StateCondition into a JSON compatible object
  15707. * @returns serialization object
  15708. */
  15709. serialize(): any;
  15710. }
  15711. }
  15712. declare module "babylonjs/Actions/directActions" {
  15713. import { Action } from "babylonjs/Actions/action";
  15714. import { Condition } from "babylonjs/Actions/condition";
  15715. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15716. /**
  15717. * This defines an action responsible to toggle a boolean once triggered.
  15718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15719. */
  15720. export class SwitchBooleanAction extends Action {
  15721. /**
  15722. * The path to the boolean property in the target object
  15723. */
  15724. propertyPath: string;
  15725. private _target;
  15726. private _effectiveTarget;
  15727. private _property;
  15728. /**
  15729. * Instantiate the action
  15730. * @param triggerOptions defines the trigger options
  15731. * @param target defines the object containing the boolean
  15732. * @param propertyPath defines the path to the boolean property in the target object
  15733. * @param condition defines the trigger related conditions
  15734. */
  15735. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15736. /** @hidden */
  15737. _prepare(): void;
  15738. /**
  15739. * Execute the action toggle the boolean value.
  15740. */
  15741. execute(): void;
  15742. /**
  15743. * Serializes the actions and its related information.
  15744. * @param parent defines the object to serialize in
  15745. * @returns the serialized object
  15746. */
  15747. serialize(parent: any): any;
  15748. }
  15749. /**
  15750. * This defines an action responsible to set a the state field of the target
  15751. * to a desired value once triggered.
  15752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15753. */
  15754. export class SetStateAction extends Action {
  15755. /**
  15756. * The value to store in the state field.
  15757. */
  15758. value: string;
  15759. private _target;
  15760. /**
  15761. * Instantiate the action
  15762. * @param triggerOptions defines the trigger options
  15763. * @param target defines the object containing the state property
  15764. * @param value defines the value to store in the state field
  15765. * @param condition defines the trigger related conditions
  15766. */
  15767. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15768. /**
  15769. * Execute the action and store the value on the target state property.
  15770. */
  15771. execute(): void;
  15772. /**
  15773. * Serializes the actions and its related information.
  15774. * @param parent defines the object to serialize in
  15775. * @returns the serialized object
  15776. */
  15777. serialize(parent: any): any;
  15778. }
  15779. /**
  15780. * This defines an action responsible to set a property of the target
  15781. * to a desired value once triggered.
  15782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15783. */
  15784. export class SetValueAction extends Action {
  15785. /**
  15786. * The path of the property to set in the target.
  15787. */
  15788. propertyPath: string;
  15789. /**
  15790. * The value to set in the property
  15791. */
  15792. value: any;
  15793. private _target;
  15794. private _effectiveTarget;
  15795. private _property;
  15796. /**
  15797. * Instantiate the action
  15798. * @param triggerOptions defines the trigger options
  15799. * @param target defines the object containing the property
  15800. * @param propertyPath defines the path of the property to set in the target
  15801. * @param value defines the value to set in the property
  15802. * @param condition defines the trigger related conditions
  15803. */
  15804. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15805. /** @hidden */
  15806. _prepare(): void;
  15807. /**
  15808. * Execute the action and set the targetted property to the desired value.
  15809. */
  15810. execute(): void;
  15811. /**
  15812. * Serializes the actions and its related information.
  15813. * @param parent defines the object to serialize in
  15814. * @returns the serialized object
  15815. */
  15816. serialize(parent: any): any;
  15817. }
  15818. /**
  15819. * This defines an action responsible to increment the target value
  15820. * to a desired value once triggered.
  15821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15822. */
  15823. export class IncrementValueAction extends Action {
  15824. /**
  15825. * The path of the property to increment in the target.
  15826. */
  15827. propertyPath: string;
  15828. /**
  15829. * The value we should increment the property by.
  15830. */
  15831. value: any;
  15832. private _target;
  15833. private _effectiveTarget;
  15834. private _property;
  15835. /**
  15836. * Instantiate the action
  15837. * @param triggerOptions defines the trigger options
  15838. * @param target defines the object containing the property
  15839. * @param propertyPath defines the path of the property to increment in the target
  15840. * @param value defines the value value we should increment the property by
  15841. * @param condition defines the trigger related conditions
  15842. */
  15843. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15844. /** @hidden */
  15845. _prepare(): void;
  15846. /**
  15847. * Execute the action and increment the target of the value amount.
  15848. */
  15849. execute(): void;
  15850. /**
  15851. * Serializes the actions and its related information.
  15852. * @param parent defines the object to serialize in
  15853. * @returns the serialized object
  15854. */
  15855. serialize(parent: any): any;
  15856. }
  15857. /**
  15858. * This defines an action responsible to start an animation once triggered.
  15859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15860. */
  15861. export class PlayAnimationAction extends Action {
  15862. /**
  15863. * Where the animation should start (animation frame)
  15864. */
  15865. from: number;
  15866. /**
  15867. * Where the animation should stop (animation frame)
  15868. */
  15869. to: number;
  15870. /**
  15871. * Define if the animation should loop or stop after the first play.
  15872. */
  15873. loop?: boolean;
  15874. private _target;
  15875. /**
  15876. * Instantiate the action
  15877. * @param triggerOptions defines the trigger options
  15878. * @param target defines the target animation or animation name
  15879. * @param from defines from where the animation should start (animation frame)
  15880. * @param end defines where the animation should stop (animation frame)
  15881. * @param loop defines if the animation should loop or stop after the first play
  15882. * @param condition defines the trigger related conditions
  15883. */
  15884. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15885. /** @hidden */
  15886. _prepare(): void;
  15887. /**
  15888. * Execute the action and play the animation.
  15889. */
  15890. execute(): void;
  15891. /**
  15892. * Serializes the actions and its related information.
  15893. * @param parent defines the object to serialize in
  15894. * @returns the serialized object
  15895. */
  15896. serialize(parent: any): any;
  15897. }
  15898. /**
  15899. * This defines an action responsible to stop an animation once triggered.
  15900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15901. */
  15902. export class StopAnimationAction extends Action {
  15903. private _target;
  15904. /**
  15905. * Instantiate the action
  15906. * @param triggerOptions defines the trigger options
  15907. * @param target defines the target animation or animation name
  15908. * @param condition defines the trigger related conditions
  15909. */
  15910. constructor(triggerOptions: any, target: any, condition?: Condition);
  15911. /** @hidden */
  15912. _prepare(): void;
  15913. /**
  15914. * Execute the action and stop the animation.
  15915. */
  15916. execute(): void;
  15917. /**
  15918. * Serializes the actions and its related information.
  15919. * @param parent defines the object to serialize in
  15920. * @returns the serialized object
  15921. */
  15922. serialize(parent: any): any;
  15923. }
  15924. /**
  15925. * This defines an action responsible that does nothing once triggered.
  15926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15927. */
  15928. export class DoNothingAction extends Action {
  15929. /**
  15930. * Instantiate the action
  15931. * @param triggerOptions defines the trigger options
  15932. * @param condition defines the trigger related conditions
  15933. */
  15934. constructor(triggerOptions?: any, condition?: Condition);
  15935. /**
  15936. * Execute the action and do nothing.
  15937. */
  15938. execute(): void;
  15939. /**
  15940. * Serializes the actions and its related information.
  15941. * @param parent defines the object to serialize in
  15942. * @returns the serialized object
  15943. */
  15944. serialize(parent: any): any;
  15945. }
  15946. /**
  15947. * This defines an action responsible to trigger several actions once triggered.
  15948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15949. */
  15950. export class CombineAction extends Action {
  15951. /**
  15952. * The list of aggregated animations to run.
  15953. */
  15954. children: Action[];
  15955. /**
  15956. * Instantiate the action
  15957. * @param triggerOptions defines the trigger options
  15958. * @param children defines the list of aggregated animations to run
  15959. * @param condition defines the trigger related conditions
  15960. */
  15961. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15962. /** @hidden */
  15963. _prepare(): void;
  15964. /**
  15965. * Execute the action and executes all the aggregated actions.
  15966. */
  15967. execute(evt: ActionEvent): void;
  15968. /**
  15969. * Serializes the actions and its related information.
  15970. * @param parent defines the object to serialize in
  15971. * @returns the serialized object
  15972. */
  15973. serialize(parent: any): any;
  15974. }
  15975. /**
  15976. * This defines an action responsible to run code (external event) once triggered.
  15977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15978. */
  15979. export class ExecuteCodeAction extends Action {
  15980. /**
  15981. * The callback function to run.
  15982. */
  15983. func: (evt: ActionEvent) => void;
  15984. /**
  15985. * Instantiate the action
  15986. * @param triggerOptions defines the trigger options
  15987. * @param func defines the callback function to run
  15988. * @param condition defines the trigger related conditions
  15989. */
  15990. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15991. /**
  15992. * Execute the action and run the attached code.
  15993. */
  15994. execute(evt: ActionEvent): void;
  15995. }
  15996. /**
  15997. * This defines an action responsible to set the parent property of the target once triggered.
  15998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15999. */
  16000. export class SetParentAction extends Action {
  16001. private _parent;
  16002. private _target;
  16003. /**
  16004. * Instantiate the action
  16005. * @param triggerOptions defines the trigger options
  16006. * @param target defines the target containing the parent property
  16007. * @param parent defines from where the animation should start (animation frame)
  16008. * @param condition defines the trigger related conditions
  16009. */
  16010. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16011. /** @hidden */
  16012. _prepare(): void;
  16013. /**
  16014. * Execute the action and set the parent property.
  16015. */
  16016. execute(): void;
  16017. /**
  16018. * Serializes the actions and its related information.
  16019. * @param parent defines the object to serialize in
  16020. * @returns the serialized object
  16021. */
  16022. serialize(parent: any): any;
  16023. }
  16024. }
  16025. declare module "babylonjs/Actions/actionManager" {
  16026. import { Nullable } from "babylonjs/types";
  16027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16028. import { Scene } from "babylonjs/scene";
  16029. import { IAction } from "babylonjs/Actions/action";
  16030. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16031. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16032. /**
  16033. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16034. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16036. */
  16037. export class ActionManager extends AbstractActionManager {
  16038. /**
  16039. * Nothing
  16040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16041. */
  16042. static readonly NothingTrigger: number;
  16043. /**
  16044. * On pick
  16045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16046. */
  16047. static readonly OnPickTrigger: number;
  16048. /**
  16049. * On left pick
  16050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16051. */
  16052. static readonly OnLeftPickTrigger: number;
  16053. /**
  16054. * On right pick
  16055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16056. */
  16057. static readonly OnRightPickTrigger: number;
  16058. /**
  16059. * On center pick
  16060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16061. */
  16062. static readonly OnCenterPickTrigger: number;
  16063. /**
  16064. * On pick down
  16065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16066. */
  16067. static readonly OnPickDownTrigger: number;
  16068. /**
  16069. * On double pick
  16070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16071. */
  16072. static readonly OnDoublePickTrigger: number;
  16073. /**
  16074. * On pick up
  16075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16076. */
  16077. static readonly OnPickUpTrigger: number;
  16078. /**
  16079. * On pick out.
  16080. * This trigger will only be raised if you also declared a OnPickDown
  16081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16082. */
  16083. static readonly OnPickOutTrigger: number;
  16084. /**
  16085. * On long press
  16086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16087. */
  16088. static readonly OnLongPressTrigger: number;
  16089. /**
  16090. * On pointer over
  16091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16092. */
  16093. static readonly OnPointerOverTrigger: number;
  16094. /**
  16095. * On pointer out
  16096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16097. */
  16098. static readonly OnPointerOutTrigger: number;
  16099. /**
  16100. * On every frame
  16101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16102. */
  16103. static readonly OnEveryFrameTrigger: number;
  16104. /**
  16105. * On intersection enter
  16106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16107. */
  16108. static readonly OnIntersectionEnterTrigger: number;
  16109. /**
  16110. * On intersection exit
  16111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16112. */
  16113. static readonly OnIntersectionExitTrigger: number;
  16114. /**
  16115. * On key down
  16116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16117. */
  16118. static readonly OnKeyDownTrigger: number;
  16119. /**
  16120. * On key up
  16121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16122. */
  16123. static readonly OnKeyUpTrigger: number;
  16124. private _scene;
  16125. /**
  16126. * Creates a new action manager
  16127. * @param scene defines the hosting scene
  16128. */
  16129. constructor(scene: Scene);
  16130. /**
  16131. * Releases all associated resources
  16132. */
  16133. dispose(): void;
  16134. /**
  16135. * Gets hosting scene
  16136. * @returns the hosting scene
  16137. */
  16138. getScene(): Scene;
  16139. /**
  16140. * Does this action manager handles actions of any of the given triggers
  16141. * @param triggers defines the triggers to be tested
  16142. * @return a boolean indicating whether one (or more) of the triggers is handled
  16143. */
  16144. hasSpecificTriggers(triggers: number[]): boolean;
  16145. /**
  16146. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16147. * speed.
  16148. * @param triggerA defines the trigger to be tested
  16149. * @param triggerB defines the trigger to be tested
  16150. * @return a boolean indicating whether one (or more) of the triggers is handled
  16151. */
  16152. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16153. /**
  16154. * Does this action manager handles actions of a given trigger
  16155. * @param trigger defines the trigger to be tested
  16156. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16157. * @return whether the trigger is handled
  16158. */
  16159. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16160. /**
  16161. * Does this action manager has pointer triggers
  16162. */
  16163. readonly hasPointerTriggers: boolean;
  16164. /**
  16165. * Does this action manager has pick triggers
  16166. */
  16167. readonly hasPickTriggers: boolean;
  16168. /**
  16169. * Registers an action to this action manager
  16170. * @param action defines the action to be registered
  16171. * @return the action amended (prepared) after registration
  16172. */
  16173. registerAction(action: IAction): Nullable<IAction>;
  16174. /**
  16175. * Unregisters an action to this action manager
  16176. * @param action defines the action to be unregistered
  16177. * @return a boolean indicating whether the action has been unregistered
  16178. */
  16179. unregisterAction(action: IAction): Boolean;
  16180. /**
  16181. * Process a specific trigger
  16182. * @param trigger defines the trigger to process
  16183. * @param evt defines the event details to be processed
  16184. */
  16185. processTrigger(trigger: number, evt?: IActionEvent): void;
  16186. /** @hidden */
  16187. _getEffectiveTarget(target: any, propertyPath: string): any;
  16188. /** @hidden */
  16189. _getProperty(propertyPath: string): string;
  16190. /**
  16191. * Serialize this manager to a JSON object
  16192. * @param name defines the property name to store this manager
  16193. * @returns a JSON representation of this manager
  16194. */
  16195. serialize(name: string): any;
  16196. /**
  16197. * Creates a new ActionManager from a JSON data
  16198. * @param parsedActions defines the JSON data to read from
  16199. * @param object defines the hosting mesh
  16200. * @param scene defines the hosting scene
  16201. */
  16202. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16203. /**
  16204. * Get a trigger name by index
  16205. * @param trigger defines the trigger index
  16206. * @returns a trigger name
  16207. */
  16208. static GetTriggerName(trigger: number): string;
  16209. }
  16210. }
  16211. declare module "babylonjs/Culling/ray" {
  16212. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16213. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16215. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16216. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16217. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16218. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16219. /**
  16220. * Class representing a ray with position and direction
  16221. */
  16222. export class Ray {
  16223. /** origin point */
  16224. origin: Vector3;
  16225. /** direction */
  16226. direction: Vector3;
  16227. /** length of the ray */
  16228. length: number;
  16229. private static readonly TmpVector3;
  16230. private _tmpRay;
  16231. /**
  16232. * Creates a new ray
  16233. * @param origin origin point
  16234. * @param direction direction
  16235. * @param length length of the ray
  16236. */
  16237. constructor(
  16238. /** origin point */
  16239. origin: Vector3,
  16240. /** direction */
  16241. direction: Vector3,
  16242. /** length of the ray */
  16243. length?: number);
  16244. /**
  16245. * Checks if the ray intersects a box
  16246. * @param minimum bound of the box
  16247. * @param maximum bound of the box
  16248. * @param intersectionTreshold extra extend to be added to the box in all direction
  16249. * @returns if the box was hit
  16250. */
  16251. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16252. /**
  16253. * Checks if the ray intersects a box
  16254. * @param box the bounding box to check
  16255. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16256. * @returns if the box was hit
  16257. */
  16258. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16259. /**
  16260. * If the ray hits a sphere
  16261. * @param sphere the bounding sphere to check
  16262. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16263. * @returns true if it hits the sphere
  16264. */
  16265. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16266. /**
  16267. * If the ray hits a triange
  16268. * @param vertex0 triangle vertex
  16269. * @param vertex1 triangle vertex
  16270. * @param vertex2 triangle vertex
  16271. * @returns intersection information if hit
  16272. */
  16273. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16274. /**
  16275. * Checks if ray intersects a plane
  16276. * @param plane the plane to check
  16277. * @returns the distance away it was hit
  16278. */
  16279. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16280. /**
  16281. * Checks if ray intersects a mesh
  16282. * @param mesh the mesh to check
  16283. * @param fastCheck if only the bounding box should checked
  16284. * @returns picking info of the intersecton
  16285. */
  16286. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16287. /**
  16288. * Checks if ray intersects a mesh
  16289. * @param meshes the meshes to check
  16290. * @param fastCheck if only the bounding box should checked
  16291. * @param results array to store result in
  16292. * @returns Array of picking infos
  16293. */
  16294. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16295. private _comparePickingInfo;
  16296. private static smallnum;
  16297. private static rayl;
  16298. /**
  16299. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16300. * @param sega the first point of the segment to test the intersection against
  16301. * @param segb the second point of the segment to test the intersection against
  16302. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16303. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16304. */
  16305. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16306. /**
  16307. * Update the ray from viewport position
  16308. * @param x position
  16309. * @param y y position
  16310. * @param viewportWidth viewport width
  16311. * @param viewportHeight viewport height
  16312. * @param world world matrix
  16313. * @param view view matrix
  16314. * @param projection projection matrix
  16315. * @returns this ray updated
  16316. */
  16317. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16318. /**
  16319. * Creates a ray with origin and direction of 0,0,0
  16320. * @returns the new ray
  16321. */
  16322. static Zero(): Ray;
  16323. /**
  16324. * Creates a new ray from screen space and viewport
  16325. * @param x position
  16326. * @param y y position
  16327. * @param viewportWidth viewport width
  16328. * @param viewportHeight viewport height
  16329. * @param world world matrix
  16330. * @param view view matrix
  16331. * @param projection projection matrix
  16332. * @returns new ray
  16333. */
  16334. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16335. /**
  16336. * 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
  16337. * transformed to the given world matrix.
  16338. * @param origin The origin point
  16339. * @param end The end point
  16340. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16341. * @returns the new ray
  16342. */
  16343. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16344. /**
  16345. * Transforms a ray by a matrix
  16346. * @param ray ray to transform
  16347. * @param matrix matrix to apply
  16348. * @returns the resulting new ray
  16349. */
  16350. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16351. /**
  16352. * Transforms a ray by a matrix
  16353. * @param ray ray to transform
  16354. * @param matrix matrix to apply
  16355. * @param result ray to store result in
  16356. */
  16357. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16358. /**
  16359. * Unproject a ray from screen space to object space
  16360. * @param sourceX defines the screen space x coordinate to use
  16361. * @param sourceY defines the screen space y coordinate to use
  16362. * @param viewportWidth defines the current width of the viewport
  16363. * @param viewportHeight defines the current height of the viewport
  16364. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16365. * @param view defines the view matrix to use
  16366. * @param projection defines the projection matrix to use
  16367. */
  16368. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16369. }
  16370. /**
  16371. * Type used to define predicate used to select faces when a mesh intersection is detected
  16372. */
  16373. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16374. module "babylonjs/scene" {
  16375. interface Scene {
  16376. /** @hidden */
  16377. _tempPickingRay: Nullable<Ray>;
  16378. /** @hidden */
  16379. _cachedRayForTransform: Ray;
  16380. /** @hidden */
  16381. _pickWithRayInverseMatrix: Matrix;
  16382. /** @hidden */
  16383. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16384. /** @hidden */
  16385. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16386. }
  16387. }
  16388. }
  16389. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16390. import { Nullable } from "babylonjs/types";
  16391. import { Observable } from "babylonjs/Misc/observable";
  16392. import { Scene } from "babylonjs/scene";
  16393. import { Sprite } from "babylonjs/Sprites/sprite";
  16394. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16395. import { Ray } from "babylonjs/Culling/ray";
  16396. import { Camera } from "babylonjs/Cameras/camera";
  16397. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16398. import { ISceneComponent } from "babylonjs/sceneComponent";
  16399. module "babylonjs/scene" {
  16400. interface Scene {
  16401. /** @hidden */
  16402. _pointerOverSprite: Nullable<Sprite>;
  16403. /** @hidden */
  16404. _pickedDownSprite: Nullable<Sprite>;
  16405. /** @hidden */
  16406. _tempSpritePickingRay: Nullable<Ray>;
  16407. /**
  16408. * All of the sprite managers added to this scene
  16409. * @see http://doc.babylonjs.com/babylon101/sprites
  16410. */
  16411. spriteManagers: Array<ISpriteManager>;
  16412. /**
  16413. * An event triggered when sprites rendering is about to start
  16414. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16415. */
  16416. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16417. /**
  16418. * An event triggered when sprites rendering is done
  16419. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16420. */
  16421. onAfterSpritesRenderingObservable: Observable<Scene>;
  16422. /** @hidden */
  16423. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16424. /** Launch a ray to try to pick a sprite in the scene
  16425. * @param x position on screen
  16426. * @param y position on screen
  16427. * @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
  16428. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16429. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16430. * @returns a PickingInfo
  16431. */
  16432. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16433. /** Use the given ray to pick a sprite in the scene
  16434. * @param ray The ray (in world space) to use to pick meshes
  16435. * @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
  16436. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16437. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16438. * @returns a PickingInfo
  16439. */
  16440. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16441. /**
  16442. * Force the sprite under the pointer
  16443. * @param sprite defines the sprite to use
  16444. */
  16445. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16446. /**
  16447. * Gets the sprite under the pointer
  16448. * @returns a Sprite or null if no sprite is under the pointer
  16449. */
  16450. getPointerOverSprite(): Nullable<Sprite>;
  16451. }
  16452. }
  16453. /**
  16454. * Defines the sprite scene component responsible to manage sprites
  16455. * in a given scene.
  16456. */
  16457. export class SpriteSceneComponent implements ISceneComponent {
  16458. /**
  16459. * The component name helpfull to identify the component in the list of scene components.
  16460. */
  16461. readonly name: string;
  16462. /**
  16463. * The scene the component belongs to.
  16464. */
  16465. scene: Scene;
  16466. /** @hidden */
  16467. private _spritePredicate;
  16468. /**
  16469. * Creates a new instance of the component for the given scene
  16470. * @param scene Defines the scene to register the component in
  16471. */
  16472. constructor(scene: Scene);
  16473. /**
  16474. * Registers the component in a given scene
  16475. */
  16476. register(): void;
  16477. /**
  16478. * Rebuilds the elements related to this component in case of
  16479. * context lost for instance.
  16480. */
  16481. rebuild(): void;
  16482. /**
  16483. * Disposes the component and the associated ressources.
  16484. */
  16485. dispose(): void;
  16486. private _pickSpriteButKeepRay;
  16487. private _pointerMove;
  16488. private _pointerDown;
  16489. private _pointerUp;
  16490. }
  16491. }
  16492. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16493. /** @hidden */
  16494. export var fogFragmentDeclaration: {
  16495. name: string;
  16496. shader: string;
  16497. };
  16498. }
  16499. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16500. /** @hidden */
  16501. export var fogFragment: {
  16502. name: string;
  16503. shader: string;
  16504. };
  16505. }
  16506. declare module "babylonjs/Shaders/sprites.fragment" {
  16507. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16508. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16509. /** @hidden */
  16510. export var spritesPixelShader: {
  16511. name: string;
  16512. shader: string;
  16513. };
  16514. }
  16515. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16516. /** @hidden */
  16517. export var fogVertexDeclaration: {
  16518. name: string;
  16519. shader: string;
  16520. };
  16521. }
  16522. declare module "babylonjs/Shaders/sprites.vertex" {
  16523. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16524. /** @hidden */
  16525. export var spritesVertexShader: {
  16526. name: string;
  16527. shader: string;
  16528. };
  16529. }
  16530. declare module "babylonjs/Sprites/spriteManager" {
  16531. import { IDisposable, Scene } from "babylonjs/scene";
  16532. import { Nullable } from "babylonjs/types";
  16533. import { Observable } from "babylonjs/Misc/observable";
  16534. import { Sprite } from "babylonjs/Sprites/sprite";
  16535. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16536. import { Camera } from "babylonjs/Cameras/camera";
  16537. import { Texture } from "babylonjs/Materials/Textures/texture";
  16538. import "babylonjs/Shaders/sprites.fragment";
  16539. import "babylonjs/Shaders/sprites.vertex";
  16540. import { Ray } from "babylonjs/Culling/ray";
  16541. /**
  16542. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16543. */
  16544. export interface ISpriteManager extends IDisposable {
  16545. /**
  16546. * Restricts the camera to viewing objects with the same layerMask.
  16547. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16548. */
  16549. layerMask: number;
  16550. /**
  16551. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16552. */
  16553. isPickable: boolean;
  16554. /**
  16555. * Specifies the rendering group id for this mesh (0 by default)
  16556. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16557. */
  16558. renderingGroupId: number;
  16559. /**
  16560. * Defines the list of sprites managed by the manager.
  16561. */
  16562. sprites: Array<Sprite>;
  16563. /**
  16564. * Tests the intersection of a sprite with a specific ray.
  16565. * @param ray The ray we are sending to test the collision
  16566. * @param camera The camera space we are sending rays in
  16567. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16568. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16569. * @returns picking info or null.
  16570. */
  16571. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16572. /**
  16573. * Renders the list of sprites on screen.
  16574. */
  16575. render(): void;
  16576. }
  16577. /**
  16578. * Class used to manage multiple sprites on the same spritesheet
  16579. * @see http://doc.babylonjs.com/babylon101/sprites
  16580. */
  16581. export class SpriteManager implements ISpriteManager {
  16582. /** defines the manager's name */
  16583. name: string;
  16584. /** Gets the list of sprites */
  16585. sprites: Sprite[];
  16586. /** Gets or sets the rendering group id (0 by default) */
  16587. renderingGroupId: number;
  16588. /** Gets or sets camera layer mask */
  16589. layerMask: number;
  16590. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16591. fogEnabled: boolean;
  16592. /** Gets or sets a boolean indicating if the sprites are pickable */
  16593. isPickable: boolean;
  16594. /** Defines the default width of a cell in the spritesheet */
  16595. cellWidth: number;
  16596. /** Defines the default height of a cell in the spritesheet */
  16597. cellHeight: number;
  16598. /**
  16599. * An event triggered when the manager is disposed.
  16600. */
  16601. onDisposeObservable: Observable<SpriteManager>;
  16602. private _onDisposeObserver;
  16603. /**
  16604. * Callback called when the manager is disposed
  16605. */
  16606. onDispose: () => void;
  16607. private _capacity;
  16608. private _spriteTexture;
  16609. private _epsilon;
  16610. private _scene;
  16611. private _vertexData;
  16612. private _buffer;
  16613. private _vertexBuffers;
  16614. private _indexBuffer;
  16615. private _effectBase;
  16616. private _effectFog;
  16617. /**
  16618. * Gets or sets the spritesheet texture
  16619. */
  16620. texture: Texture;
  16621. /**
  16622. * Creates a new sprite manager
  16623. * @param name defines the manager's name
  16624. * @param imgUrl defines the sprite sheet url
  16625. * @param capacity defines the maximum allowed number of sprites
  16626. * @param cellSize defines the size of a sprite cell
  16627. * @param scene defines the hosting scene
  16628. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16629. * @param samplingMode defines the smapling mode to use with spritesheet
  16630. */
  16631. constructor(
  16632. /** defines the manager's name */
  16633. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16634. private _appendSpriteVertex;
  16635. /**
  16636. * Intersects the sprites with a ray
  16637. * @param ray defines the ray to intersect with
  16638. * @param camera defines the current active camera
  16639. * @param predicate defines a predicate used to select candidate sprites
  16640. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16641. * @returns null if no hit or a PickingInfo
  16642. */
  16643. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16644. /**
  16645. * Render all child sprites
  16646. */
  16647. render(): void;
  16648. /**
  16649. * Release associated resources
  16650. */
  16651. dispose(): void;
  16652. }
  16653. }
  16654. declare module "babylonjs/Sprites/sprite" {
  16655. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16656. import { Nullable } from "babylonjs/types";
  16657. import { ActionManager } from "babylonjs/Actions/actionManager";
  16658. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16659. /**
  16660. * Class used to represent a sprite
  16661. * @see http://doc.babylonjs.com/babylon101/sprites
  16662. */
  16663. export class Sprite {
  16664. /** defines the name */
  16665. name: string;
  16666. /** Gets or sets the current world position */
  16667. position: Vector3;
  16668. /** Gets or sets the main color */
  16669. color: Color4;
  16670. /** Gets or sets the width */
  16671. width: number;
  16672. /** Gets or sets the height */
  16673. height: number;
  16674. /** Gets or sets rotation angle */
  16675. angle: number;
  16676. /** Gets or sets the cell index in the sprite sheet */
  16677. cellIndex: number;
  16678. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16679. invertU: number;
  16680. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16681. invertV: number;
  16682. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16683. disposeWhenFinishedAnimating: boolean;
  16684. /** Gets the list of attached animations */
  16685. animations: Animation[];
  16686. /** Gets or sets a boolean indicating if the sprite can be picked */
  16687. isPickable: boolean;
  16688. /**
  16689. * Gets or sets the associated action manager
  16690. */
  16691. actionManager: Nullable<ActionManager>;
  16692. private _animationStarted;
  16693. private _loopAnimation;
  16694. private _fromIndex;
  16695. private _toIndex;
  16696. private _delay;
  16697. private _direction;
  16698. private _manager;
  16699. private _time;
  16700. private _onAnimationEnd;
  16701. /**
  16702. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16703. */
  16704. isVisible: boolean;
  16705. /**
  16706. * Gets or sets the sprite size
  16707. */
  16708. size: number;
  16709. /**
  16710. * Creates a new Sprite
  16711. * @param name defines the name
  16712. * @param manager defines the manager
  16713. */
  16714. constructor(
  16715. /** defines the name */
  16716. name: string, manager: ISpriteManager);
  16717. /**
  16718. * Starts an animation
  16719. * @param from defines the initial key
  16720. * @param to defines the end key
  16721. * @param loop defines if the animation must loop
  16722. * @param delay defines the start delay (in ms)
  16723. * @param onAnimationEnd defines a callback to call when animation ends
  16724. */
  16725. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16726. /** Stops current animation (if any) */
  16727. stopAnimation(): void;
  16728. /** @hidden */
  16729. _animate(deltaTime: number): void;
  16730. /** Release associated resources */
  16731. dispose(): void;
  16732. }
  16733. }
  16734. declare module "babylonjs/Collisions/pickingInfo" {
  16735. import { Nullable } from "babylonjs/types";
  16736. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16738. import { Sprite } from "babylonjs/Sprites/sprite";
  16739. import { Ray } from "babylonjs/Culling/ray";
  16740. /**
  16741. * Information about the result of picking within a scene
  16742. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16743. */
  16744. export class PickingInfo {
  16745. /** @hidden */
  16746. _pickingUnavailable: boolean;
  16747. /**
  16748. * If the pick collided with an object
  16749. */
  16750. hit: boolean;
  16751. /**
  16752. * Distance away where the pick collided
  16753. */
  16754. distance: number;
  16755. /**
  16756. * The location of pick collision
  16757. */
  16758. pickedPoint: Nullable<Vector3>;
  16759. /**
  16760. * The mesh corresponding the the pick collision
  16761. */
  16762. pickedMesh: Nullable<AbstractMesh>;
  16763. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16764. bu: number;
  16765. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16766. bv: number;
  16767. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16768. faceId: number;
  16769. /** Id of the the submesh that was picked */
  16770. subMeshId: number;
  16771. /** If a sprite was picked, this will be the sprite the pick collided with */
  16772. pickedSprite: Nullable<Sprite>;
  16773. /**
  16774. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16775. */
  16776. originMesh: Nullable<AbstractMesh>;
  16777. /**
  16778. * The ray that was used to perform the picking.
  16779. */
  16780. ray: Nullable<Ray>;
  16781. /**
  16782. * Gets the normal correspodning to the face the pick collided with
  16783. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16784. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16785. * @returns The normal correspodning to the face the pick collided with
  16786. */
  16787. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16788. /**
  16789. * Gets the texture coordinates of where the pick occured
  16790. * @returns the vector containing the coordnates of the texture
  16791. */
  16792. getTextureCoordinates(): Nullable<Vector2>;
  16793. }
  16794. }
  16795. declare module "babylonjs/Events/pointerEvents" {
  16796. import { Nullable } from "babylonjs/types";
  16797. import { Vector2 } from "babylonjs/Maths/math";
  16798. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16799. import { Ray } from "babylonjs/Culling/ray";
  16800. /**
  16801. * Gather the list of pointer event types as constants.
  16802. */
  16803. export class PointerEventTypes {
  16804. /**
  16805. * 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.
  16806. */
  16807. static readonly POINTERDOWN: number;
  16808. /**
  16809. * The pointerup event is fired when a pointer is no longer active.
  16810. */
  16811. static readonly POINTERUP: number;
  16812. /**
  16813. * The pointermove event is fired when a pointer changes coordinates.
  16814. */
  16815. static readonly POINTERMOVE: number;
  16816. /**
  16817. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16818. */
  16819. static readonly POINTERWHEEL: number;
  16820. /**
  16821. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16822. */
  16823. static readonly POINTERPICK: number;
  16824. /**
  16825. * The pointertap event is fired when a the object has been touched and released without drag.
  16826. */
  16827. static readonly POINTERTAP: number;
  16828. /**
  16829. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16830. */
  16831. static readonly POINTERDOUBLETAP: number;
  16832. }
  16833. /**
  16834. * Base class of pointer info types.
  16835. */
  16836. export class PointerInfoBase {
  16837. /**
  16838. * Defines the type of event (PointerEventTypes)
  16839. */
  16840. type: number;
  16841. /**
  16842. * Defines the related dom event
  16843. */
  16844. event: PointerEvent | MouseWheelEvent;
  16845. /**
  16846. * Instantiates the base class of pointers info.
  16847. * @param type Defines the type of event (PointerEventTypes)
  16848. * @param event Defines the related dom event
  16849. */
  16850. constructor(
  16851. /**
  16852. * Defines the type of event (PointerEventTypes)
  16853. */
  16854. type: number,
  16855. /**
  16856. * Defines the related dom event
  16857. */
  16858. event: PointerEvent | MouseWheelEvent);
  16859. }
  16860. /**
  16861. * This class is used to store pointer related info for the onPrePointerObservable event.
  16862. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16863. */
  16864. export class PointerInfoPre extends PointerInfoBase {
  16865. /**
  16866. * Ray from a pointer if availible (eg. 6dof controller)
  16867. */
  16868. ray: Nullable<Ray>;
  16869. /**
  16870. * Defines the local position of the pointer on the canvas.
  16871. */
  16872. localPosition: Vector2;
  16873. /**
  16874. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16875. */
  16876. skipOnPointerObservable: boolean;
  16877. /**
  16878. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16879. * @param type Defines the type of event (PointerEventTypes)
  16880. * @param event Defines the related dom event
  16881. * @param localX Defines the local x coordinates of the pointer when the event occured
  16882. * @param localY Defines the local y coordinates of the pointer when the event occured
  16883. */
  16884. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16885. }
  16886. /**
  16887. * This type contains all the data related to a pointer event in Babylon.js.
  16888. * 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.
  16889. */
  16890. export class PointerInfo extends PointerInfoBase {
  16891. /**
  16892. * Defines the picking info associated to the info (if any)\
  16893. */
  16894. pickInfo: Nullable<PickingInfo>;
  16895. /**
  16896. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16897. * @param type Defines the type of event (PointerEventTypes)
  16898. * @param event Defines the related dom event
  16899. * @param pickInfo Defines the picking info associated to the info (if any)\
  16900. */
  16901. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16902. /**
  16903. * Defines the picking info associated to the info (if any)\
  16904. */
  16905. pickInfo: Nullable<PickingInfo>);
  16906. }
  16907. /**
  16908. * Data relating to a touch event on the screen.
  16909. */
  16910. export interface PointerTouch {
  16911. /**
  16912. * X coordinate of touch.
  16913. */
  16914. x: number;
  16915. /**
  16916. * Y coordinate of touch.
  16917. */
  16918. y: number;
  16919. /**
  16920. * Id of touch. Unique for each finger.
  16921. */
  16922. pointerId: number;
  16923. /**
  16924. * Event type passed from DOM.
  16925. */
  16926. type: any;
  16927. }
  16928. }
  16929. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16930. import { Observable } from "babylonjs/Misc/observable";
  16931. import { Nullable } from "babylonjs/types";
  16932. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16933. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16934. /**
  16935. * Manage the mouse inputs to control the movement of a free camera.
  16936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16937. */
  16938. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16939. /**
  16940. * Define if touch is enabled in the mouse input
  16941. */
  16942. touchEnabled: boolean;
  16943. /**
  16944. * Defines the camera the input is attached to.
  16945. */
  16946. camera: FreeCamera;
  16947. /**
  16948. * Defines the buttons associated with the input to handle camera move.
  16949. */
  16950. buttons: number[];
  16951. /**
  16952. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16953. */
  16954. angularSensibility: number;
  16955. private _pointerInput;
  16956. private _onMouseMove;
  16957. private _observer;
  16958. private previousPosition;
  16959. /**
  16960. * Observable for when a pointer move event occurs containing the move offset
  16961. */
  16962. onPointerMovedObservable: Observable<{
  16963. offsetX: number;
  16964. offsetY: number;
  16965. }>;
  16966. /**
  16967. * @hidden
  16968. * If the camera should be rotated automatically based on pointer movement
  16969. */
  16970. _allowCameraRotation: boolean;
  16971. /**
  16972. * Manage the mouse inputs to control the movement of a free camera.
  16973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16974. * @param touchEnabled Defines if touch is enabled or not
  16975. */
  16976. constructor(
  16977. /**
  16978. * Define if touch is enabled in the mouse input
  16979. */
  16980. touchEnabled?: boolean);
  16981. /**
  16982. * Attach the input controls to a specific dom element to get the input from.
  16983. * @param element Defines the element the controls should be listened from
  16984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16985. */
  16986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16987. /**
  16988. * Called on JS contextmenu event.
  16989. * Override this method to provide functionality.
  16990. */
  16991. protected onContextMenu(evt: PointerEvent): void;
  16992. /**
  16993. * Detach the current controls from the specified dom element.
  16994. * @param element Defines the element to stop listening the inputs from
  16995. */
  16996. detachControl(element: Nullable<HTMLElement>): void;
  16997. /**
  16998. * Gets the class name of the current intput.
  16999. * @returns the class name
  17000. */
  17001. getClassName(): string;
  17002. /**
  17003. * Get the friendly name associated with the input class.
  17004. * @returns the input friendly name
  17005. */
  17006. getSimpleName(): string;
  17007. }
  17008. }
  17009. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17010. import { Nullable } from "babylonjs/types";
  17011. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17012. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17013. /**
  17014. * Manage the touch inputs to control the movement of a free camera.
  17015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17016. */
  17017. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17018. /**
  17019. * Defines the camera the input is attached to.
  17020. */
  17021. camera: FreeCamera;
  17022. /**
  17023. * Defines the touch sensibility for rotation.
  17024. * The higher the faster.
  17025. */
  17026. touchAngularSensibility: number;
  17027. /**
  17028. * Defines the touch sensibility for move.
  17029. * The higher the faster.
  17030. */
  17031. touchMoveSensibility: number;
  17032. private _offsetX;
  17033. private _offsetY;
  17034. private _pointerPressed;
  17035. private _pointerInput;
  17036. private _observer;
  17037. private _onLostFocus;
  17038. /**
  17039. * Attach the input controls to a specific dom element to get the input from.
  17040. * @param element Defines the element the controls should be listened from
  17041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17042. */
  17043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17044. /**
  17045. * Detach the current controls from the specified dom element.
  17046. * @param element Defines the element to stop listening the inputs from
  17047. */
  17048. detachControl(element: Nullable<HTMLElement>): void;
  17049. /**
  17050. * Update the current camera state depending on the inputs that have been used this frame.
  17051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17052. */
  17053. checkInputs(): void;
  17054. /**
  17055. * Gets the class name of the current intput.
  17056. * @returns the class name
  17057. */
  17058. getClassName(): string;
  17059. /**
  17060. * Get the friendly name associated with the input class.
  17061. * @returns the input friendly name
  17062. */
  17063. getSimpleName(): string;
  17064. }
  17065. }
  17066. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17067. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17068. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17069. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17070. import { Nullable } from "babylonjs/types";
  17071. /**
  17072. * Default Inputs manager for the FreeCamera.
  17073. * It groups all the default supported inputs for ease of use.
  17074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17075. */
  17076. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17077. /**
  17078. * @hidden
  17079. */
  17080. _mouseInput: Nullable<FreeCameraMouseInput>;
  17081. /**
  17082. * Instantiates a new FreeCameraInputsManager.
  17083. * @param camera Defines the camera the inputs belong to
  17084. */
  17085. constructor(camera: FreeCamera);
  17086. /**
  17087. * Add keyboard input support to the input manager.
  17088. * @returns the current input manager
  17089. */
  17090. addKeyboard(): FreeCameraInputsManager;
  17091. /**
  17092. * Add mouse input support to the input manager.
  17093. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17094. * @returns the current input manager
  17095. */
  17096. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17097. /**
  17098. * Removes the mouse input support from the manager
  17099. * @returns the current input manager
  17100. */
  17101. removeMouse(): FreeCameraInputsManager;
  17102. /**
  17103. * Add touch input support to the input manager.
  17104. * @returns the current input manager
  17105. */
  17106. addTouch(): FreeCameraInputsManager;
  17107. /**
  17108. * Remove all attached input methods from a camera
  17109. */
  17110. clear(): void;
  17111. }
  17112. }
  17113. declare module "babylonjs/Cameras/freeCamera" {
  17114. import { Vector3 } from "babylonjs/Maths/math";
  17115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17116. import { Scene } from "babylonjs/scene";
  17117. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17118. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17119. /**
  17120. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17121. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17123. */
  17124. export class FreeCamera extends TargetCamera {
  17125. /**
  17126. * Define the collision ellipsoid of the camera.
  17127. * This is helpful to simulate a camera body like the player body around the camera
  17128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17129. */
  17130. ellipsoid: Vector3;
  17131. /**
  17132. * Define an offset for the position of the ellipsoid around the camera.
  17133. * This can be helpful to determine the center of the body near the gravity center of the body
  17134. * instead of its head.
  17135. */
  17136. ellipsoidOffset: Vector3;
  17137. /**
  17138. * Enable or disable collisions of the camera with the rest of the scene objects.
  17139. */
  17140. checkCollisions: boolean;
  17141. /**
  17142. * Enable or disable gravity on the camera.
  17143. */
  17144. applyGravity: boolean;
  17145. /**
  17146. * Define the input manager associated to the camera.
  17147. */
  17148. inputs: FreeCameraInputsManager;
  17149. /**
  17150. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17151. * Higher values reduce sensitivity.
  17152. */
  17153. /**
  17154. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17155. * Higher values reduce sensitivity.
  17156. */
  17157. angularSensibility: number;
  17158. /**
  17159. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17160. */
  17161. keysUp: number[];
  17162. /**
  17163. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17164. */
  17165. keysDown: number[];
  17166. /**
  17167. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17168. */
  17169. keysLeft: number[];
  17170. /**
  17171. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17172. */
  17173. keysRight: number[];
  17174. /**
  17175. * Event raised when the camera collide with a mesh in the scene.
  17176. */
  17177. onCollide: (collidedMesh: AbstractMesh) => void;
  17178. private _collider;
  17179. private _needMoveForGravity;
  17180. private _oldPosition;
  17181. private _diffPosition;
  17182. private _newPosition;
  17183. /** @hidden */
  17184. _localDirection: Vector3;
  17185. /** @hidden */
  17186. _transformedDirection: Vector3;
  17187. /**
  17188. * Instantiates a Free Camera.
  17189. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17190. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17191. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17192. * @param name Define the name of the camera in the scene
  17193. * @param position Define the start position of the camera in the scene
  17194. * @param scene Define the scene the camera belongs to
  17195. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17196. */
  17197. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17198. /**
  17199. * Attached controls to the current camera.
  17200. * @param element Defines the element the controls should be listened from
  17201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17202. */
  17203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17204. /**
  17205. * Detach the current controls from the camera.
  17206. * The camera will stop reacting to inputs.
  17207. * @param element Defines the element to stop listening the inputs from
  17208. */
  17209. detachControl(element: HTMLElement): void;
  17210. private _collisionMask;
  17211. /**
  17212. * Define a collision mask to limit the list of object the camera can collide with
  17213. */
  17214. collisionMask: number;
  17215. /** @hidden */
  17216. _collideWithWorld(displacement: Vector3): void;
  17217. private _onCollisionPositionChange;
  17218. /** @hidden */
  17219. _checkInputs(): void;
  17220. /** @hidden */
  17221. _decideIfNeedsToMove(): boolean;
  17222. /** @hidden */
  17223. _updatePosition(): void;
  17224. /**
  17225. * Destroy the camera and release the current resources hold by it.
  17226. */
  17227. dispose(): void;
  17228. /**
  17229. * Gets the current object class name.
  17230. * @return the class name
  17231. */
  17232. getClassName(): string;
  17233. }
  17234. }
  17235. declare module "babylonjs/Gamepads/gamepad" {
  17236. import { Observable } from "babylonjs/Misc/observable";
  17237. /**
  17238. * Represents a gamepad control stick position
  17239. */
  17240. export class StickValues {
  17241. /**
  17242. * The x component of the control stick
  17243. */
  17244. x: number;
  17245. /**
  17246. * The y component of the control stick
  17247. */
  17248. y: number;
  17249. /**
  17250. * Initializes the gamepad x and y control stick values
  17251. * @param x The x component of the gamepad control stick value
  17252. * @param y The y component of the gamepad control stick value
  17253. */
  17254. constructor(
  17255. /**
  17256. * The x component of the control stick
  17257. */
  17258. x: number,
  17259. /**
  17260. * The y component of the control stick
  17261. */
  17262. y: number);
  17263. }
  17264. /**
  17265. * An interface which manages callbacks for gamepad button changes
  17266. */
  17267. export interface GamepadButtonChanges {
  17268. /**
  17269. * Called when a gamepad has been changed
  17270. */
  17271. changed: boolean;
  17272. /**
  17273. * Called when a gamepad press event has been triggered
  17274. */
  17275. pressChanged: boolean;
  17276. /**
  17277. * Called when a touch event has been triggered
  17278. */
  17279. touchChanged: boolean;
  17280. /**
  17281. * Called when a value has changed
  17282. */
  17283. valueChanged: boolean;
  17284. }
  17285. /**
  17286. * Represents a gamepad
  17287. */
  17288. export class Gamepad {
  17289. /**
  17290. * The id of the gamepad
  17291. */
  17292. id: string;
  17293. /**
  17294. * The index of the gamepad
  17295. */
  17296. index: number;
  17297. /**
  17298. * The browser gamepad
  17299. */
  17300. browserGamepad: any;
  17301. /**
  17302. * Specifies what type of gamepad this represents
  17303. */
  17304. type: number;
  17305. private _leftStick;
  17306. private _rightStick;
  17307. /** @hidden */
  17308. _isConnected: boolean;
  17309. private _leftStickAxisX;
  17310. private _leftStickAxisY;
  17311. private _rightStickAxisX;
  17312. private _rightStickAxisY;
  17313. /**
  17314. * Triggered when the left control stick has been changed
  17315. */
  17316. private _onleftstickchanged;
  17317. /**
  17318. * Triggered when the right control stick has been changed
  17319. */
  17320. private _onrightstickchanged;
  17321. /**
  17322. * Represents a gamepad controller
  17323. */
  17324. static GAMEPAD: number;
  17325. /**
  17326. * Represents a generic controller
  17327. */
  17328. static GENERIC: number;
  17329. /**
  17330. * Represents an XBox controller
  17331. */
  17332. static XBOX: number;
  17333. /**
  17334. * Represents a pose-enabled controller
  17335. */
  17336. static POSE_ENABLED: number;
  17337. /**
  17338. * Specifies whether the left control stick should be Y-inverted
  17339. */
  17340. protected _invertLeftStickY: boolean;
  17341. /**
  17342. * Specifies if the gamepad has been connected
  17343. */
  17344. readonly isConnected: boolean;
  17345. /**
  17346. * Initializes the gamepad
  17347. * @param id The id of the gamepad
  17348. * @param index The index of the gamepad
  17349. * @param browserGamepad The browser gamepad
  17350. * @param leftStickX The x component of the left joystick
  17351. * @param leftStickY The y component of the left joystick
  17352. * @param rightStickX The x component of the right joystick
  17353. * @param rightStickY The y component of the right joystick
  17354. */
  17355. constructor(
  17356. /**
  17357. * The id of the gamepad
  17358. */
  17359. id: string,
  17360. /**
  17361. * The index of the gamepad
  17362. */
  17363. index: number,
  17364. /**
  17365. * The browser gamepad
  17366. */
  17367. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17368. /**
  17369. * Callback triggered when the left joystick has changed
  17370. * @param callback
  17371. */
  17372. onleftstickchanged(callback: (values: StickValues) => void): void;
  17373. /**
  17374. * Callback triggered when the right joystick has changed
  17375. * @param callback
  17376. */
  17377. onrightstickchanged(callback: (values: StickValues) => void): void;
  17378. /**
  17379. * Gets the left joystick
  17380. */
  17381. /**
  17382. * Sets the left joystick values
  17383. */
  17384. leftStick: StickValues;
  17385. /**
  17386. * Gets the right joystick
  17387. */
  17388. /**
  17389. * Sets the right joystick value
  17390. */
  17391. rightStick: StickValues;
  17392. /**
  17393. * Updates the gamepad joystick positions
  17394. */
  17395. update(): void;
  17396. /**
  17397. * Disposes the gamepad
  17398. */
  17399. dispose(): void;
  17400. }
  17401. /**
  17402. * Represents a generic gamepad
  17403. */
  17404. export class GenericPad extends Gamepad {
  17405. private _buttons;
  17406. private _onbuttondown;
  17407. private _onbuttonup;
  17408. /**
  17409. * Observable triggered when a button has been pressed
  17410. */
  17411. onButtonDownObservable: Observable<number>;
  17412. /**
  17413. * Observable triggered when a button has been released
  17414. */
  17415. onButtonUpObservable: Observable<number>;
  17416. /**
  17417. * Callback triggered when a button has been pressed
  17418. * @param callback Called when a button has been pressed
  17419. */
  17420. onbuttondown(callback: (buttonPressed: number) => void): void;
  17421. /**
  17422. * Callback triggered when a button has been released
  17423. * @param callback Called when a button has been released
  17424. */
  17425. onbuttonup(callback: (buttonReleased: number) => void): void;
  17426. /**
  17427. * Initializes the generic gamepad
  17428. * @param id The id of the generic gamepad
  17429. * @param index The index of the generic gamepad
  17430. * @param browserGamepad The browser gamepad
  17431. */
  17432. constructor(id: string, index: number, browserGamepad: any);
  17433. private _setButtonValue;
  17434. /**
  17435. * Updates the generic gamepad
  17436. */
  17437. update(): void;
  17438. /**
  17439. * Disposes the generic gamepad
  17440. */
  17441. dispose(): void;
  17442. }
  17443. }
  17444. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17445. import { Observable } from "babylonjs/Misc/observable";
  17446. import { Nullable } from "babylonjs/types";
  17447. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17450. import { Ray } from "babylonjs/Culling/ray";
  17451. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17452. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17453. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17454. /**
  17455. * Defines the types of pose enabled controllers that are supported
  17456. */
  17457. export enum PoseEnabledControllerType {
  17458. /**
  17459. * HTC Vive
  17460. */
  17461. VIVE = 0,
  17462. /**
  17463. * Oculus Rift
  17464. */
  17465. OCULUS = 1,
  17466. /**
  17467. * Windows mixed reality
  17468. */
  17469. WINDOWS = 2,
  17470. /**
  17471. * Samsung gear VR
  17472. */
  17473. GEAR_VR = 3,
  17474. /**
  17475. * Google Daydream
  17476. */
  17477. DAYDREAM = 4,
  17478. /**
  17479. * Generic
  17480. */
  17481. GENERIC = 5
  17482. }
  17483. /**
  17484. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17485. */
  17486. export interface MutableGamepadButton {
  17487. /**
  17488. * Value of the button/trigger
  17489. */
  17490. value: number;
  17491. /**
  17492. * If the button/trigger is currently touched
  17493. */
  17494. touched: boolean;
  17495. /**
  17496. * If the button/trigger is currently pressed
  17497. */
  17498. pressed: boolean;
  17499. }
  17500. /**
  17501. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17502. * @hidden
  17503. */
  17504. export interface ExtendedGamepadButton extends GamepadButton {
  17505. /**
  17506. * If the button/trigger is currently pressed
  17507. */
  17508. readonly pressed: boolean;
  17509. /**
  17510. * If the button/trigger is currently touched
  17511. */
  17512. readonly touched: boolean;
  17513. /**
  17514. * Value of the button/trigger
  17515. */
  17516. readonly value: number;
  17517. }
  17518. /** @hidden */
  17519. export interface _GamePadFactory {
  17520. /**
  17521. * Returns wether or not the current gamepad can be created for this type of controller.
  17522. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17523. * @returns true if it can be created, otherwise false
  17524. */
  17525. canCreate(gamepadInfo: any): boolean;
  17526. /**
  17527. * Creates a new instance of the Gamepad.
  17528. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17529. * @returns the new gamepad instance
  17530. */
  17531. create(gamepadInfo: any): Gamepad;
  17532. }
  17533. /**
  17534. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17535. */
  17536. export class PoseEnabledControllerHelper {
  17537. /** @hidden */
  17538. static _ControllerFactories: _GamePadFactory[];
  17539. /** @hidden */
  17540. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17541. /**
  17542. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17543. * @param vrGamepad the gamepad to initialized
  17544. * @returns a vr controller of the type the gamepad identified as
  17545. */
  17546. static InitiateController(vrGamepad: any): Gamepad;
  17547. }
  17548. /**
  17549. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17550. */
  17551. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17552. private _deviceRoomPosition;
  17553. private _deviceRoomRotationQuaternion;
  17554. /**
  17555. * The device position in babylon space
  17556. */
  17557. devicePosition: Vector3;
  17558. /**
  17559. * The device rotation in babylon space
  17560. */
  17561. deviceRotationQuaternion: Quaternion;
  17562. /**
  17563. * The scale factor of the device in babylon space
  17564. */
  17565. deviceScaleFactor: number;
  17566. /**
  17567. * (Likely devicePosition should be used instead) The device position in its room space
  17568. */
  17569. position: Vector3;
  17570. /**
  17571. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17572. */
  17573. rotationQuaternion: Quaternion;
  17574. /**
  17575. * The type of controller (Eg. Windows mixed reality)
  17576. */
  17577. controllerType: PoseEnabledControllerType;
  17578. protected _calculatedPosition: Vector3;
  17579. private _calculatedRotation;
  17580. /**
  17581. * The raw pose from the device
  17582. */
  17583. rawPose: DevicePose;
  17584. private _trackPosition;
  17585. private _maxRotationDistFromHeadset;
  17586. private _draggedRoomRotation;
  17587. /**
  17588. * @hidden
  17589. */
  17590. _disableTrackPosition(fixedPosition: Vector3): void;
  17591. /**
  17592. * Internal, the mesh attached to the controller
  17593. * @hidden
  17594. */
  17595. _mesh: Nullable<AbstractMesh>;
  17596. private _poseControlledCamera;
  17597. private _leftHandSystemQuaternion;
  17598. /**
  17599. * Internal, matrix used to convert room space to babylon space
  17600. * @hidden
  17601. */
  17602. _deviceToWorld: Matrix;
  17603. /**
  17604. * Node to be used when casting a ray from the controller
  17605. * @hidden
  17606. */
  17607. _pointingPoseNode: Nullable<TransformNode>;
  17608. /**
  17609. * Name of the child mesh that can be used to cast a ray from the controller
  17610. */
  17611. static readonly POINTING_POSE: string;
  17612. /**
  17613. * Creates a new PoseEnabledController from a gamepad
  17614. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17615. */
  17616. constructor(browserGamepad: any);
  17617. private _workingMatrix;
  17618. /**
  17619. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17620. */
  17621. update(): void;
  17622. /**
  17623. * Updates only the pose device and mesh without doing any button event checking
  17624. */
  17625. protected _updatePoseAndMesh(): void;
  17626. /**
  17627. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17628. * @param poseData raw pose fromthe device
  17629. */
  17630. updateFromDevice(poseData: DevicePose): void;
  17631. /**
  17632. * @hidden
  17633. */
  17634. _meshAttachedObservable: Observable<AbstractMesh>;
  17635. /**
  17636. * Attaches a mesh to the controller
  17637. * @param mesh the mesh to be attached
  17638. */
  17639. attachToMesh(mesh: AbstractMesh): void;
  17640. /**
  17641. * Attaches the controllers mesh to a camera
  17642. * @param camera the camera the mesh should be attached to
  17643. */
  17644. attachToPoseControlledCamera(camera: TargetCamera): void;
  17645. /**
  17646. * Disposes of the controller
  17647. */
  17648. dispose(): void;
  17649. /**
  17650. * The mesh that is attached to the controller
  17651. */
  17652. readonly mesh: Nullable<AbstractMesh>;
  17653. /**
  17654. * Gets the ray of the controller in the direction the controller is pointing
  17655. * @param length the length the resulting ray should be
  17656. * @returns a ray in the direction the controller is pointing
  17657. */
  17658. getForwardRay(length?: number): Ray;
  17659. }
  17660. }
  17661. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17662. import { Observable } from "babylonjs/Misc/observable";
  17663. import { Scene } from "babylonjs/scene";
  17664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17665. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17666. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17667. /**
  17668. * Defines the WebVRController object that represents controllers tracked in 3D space
  17669. */
  17670. export abstract class WebVRController extends PoseEnabledController {
  17671. /**
  17672. * Internal, the default controller model for the controller
  17673. */
  17674. protected _defaultModel: AbstractMesh;
  17675. /**
  17676. * Fired when the trigger state has changed
  17677. */
  17678. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17679. /**
  17680. * Fired when the main button state has changed
  17681. */
  17682. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17683. /**
  17684. * Fired when the secondary button state has changed
  17685. */
  17686. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17687. /**
  17688. * Fired when the pad state has changed
  17689. */
  17690. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17691. /**
  17692. * Fired when controllers stick values have changed
  17693. */
  17694. onPadValuesChangedObservable: Observable<StickValues>;
  17695. /**
  17696. * Array of button availible on the controller
  17697. */
  17698. protected _buttons: Array<MutableGamepadButton>;
  17699. private _onButtonStateChange;
  17700. /**
  17701. * Fired when a controller button's state has changed
  17702. * @param callback the callback containing the button that was modified
  17703. */
  17704. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17705. /**
  17706. * X and Y axis corresponding to the controllers joystick
  17707. */
  17708. pad: StickValues;
  17709. /**
  17710. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17711. */
  17712. hand: string;
  17713. /**
  17714. * The default controller model for the controller
  17715. */
  17716. readonly defaultModel: AbstractMesh;
  17717. /**
  17718. * Creates a new WebVRController from a gamepad
  17719. * @param vrGamepad the gamepad that the WebVRController should be created from
  17720. */
  17721. constructor(vrGamepad: any);
  17722. /**
  17723. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17724. */
  17725. update(): void;
  17726. /**
  17727. * Function to be called when a button is modified
  17728. */
  17729. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17730. /**
  17731. * Loads a mesh and attaches it to the controller
  17732. * @param scene the scene the mesh should be added to
  17733. * @param meshLoaded callback for when the mesh has been loaded
  17734. */
  17735. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17736. private _setButtonValue;
  17737. private _changes;
  17738. private _checkChanges;
  17739. /**
  17740. * Disposes of th webVRCOntroller
  17741. */
  17742. dispose(): void;
  17743. }
  17744. }
  17745. declare module "babylonjs/Lights/hemisphericLight" {
  17746. import { Nullable } from "babylonjs/types";
  17747. import { Scene } from "babylonjs/scene";
  17748. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17749. import { Effect } from "babylonjs/Materials/effect";
  17750. import { Light } from "babylonjs/Lights/light";
  17751. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17752. /**
  17753. * The HemisphericLight simulates the ambient environment light,
  17754. * so the passed direction is the light reflection direction, not the incoming direction.
  17755. */
  17756. export class HemisphericLight extends Light {
  17757. /**
  17758. * The groundColor is the light in the opposite direction to the one specified during creation.
  17759. * 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.
  17760. */
  17761. groundColor: Color3;
  17762. /**
  17763. * The light reflection direction, not the incoming direction.
  17764. */
  17765. direction: Vector3;
  17766. /**
  17767. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17768. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17769. * The HemisphericLight can't cast shadows.
  17770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17771. * @param name The friendly name of the light
  17772. * @param direction The direction of the light reflection
  17773. * @param scene The scene the light belongs to
  17774. */
  17775. constructor(name: string, direction: Vector3, scene: Scene);
  17776. protected _buildUniformLayout(): void;
  17777. /**
  17778. * Returns the string "HemisphericLight".
  17779. * @return The class name
  17780. */
  17781. getClassName(): string;
  17782. /**
  17783. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17784. * Returns the updated direction.
  17785. * @param target The target the direction should point to
  17786. * @return The computed direction
  17787. */
  17788. setDirectionToTarget(target: Vector3): Vector3;
  17789. /**
  17790. * Returns the shadow generator associated to the light.
  17791. * @returns Always null for hemispheric lights because it does not support shadows.
  17792. */
  17793. getShadowGenerator(): Nullable<IShadowGenerator>;
  17794. /**
  17795. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17796. * @param effect The effect to update
  17797. * @param lightIndex The index of the light in the effect to update
  17798. * @returns The hemispheric light
  17799. */
  17800. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17801. /**
  17802. * Computes the world matrix of the node
  17803. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17804. * @param useWasUpdatedFlag defines a reserved property
  17805. * @returns the world matrix
  17806. */
  17807. computeWorldMatrix(): Matrix;
  17808. /**
  17809. * Returns the integer 3.
  17810. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17811. */
  17812. getTypeID(): number;
  17813. /**
  17814. * Prepares the list of defines specific to the light type.
  17815. * @param defines the list of defines
  17816. * @param lightIndex defines the index of the light for the effect
  17817. */
  17818. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17819. }
  17820. }
  17821. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17822. /** @hidden */
  17823. export var vrMultiviewToSingleviewPixelShader: {
  17824. name: string;
  17825. shader: string;
  17826. };
  17827. }
  17828. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17830. import { Scene } from "babylonjs/scene";
  17831. /**
  17832. * Renders to multiple views with a single draw call
  17833. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17834. */
  17835. export class MultiviewRenderTarget extends RenderTargetTexture {
  17836. /**
  17837. * Creates a multiview render target
  17838. * @param scene scene used with the render target
  17839. * @param size the size of the render target (used for each view)
  17840. */
  17841. constructor(scene: Scene, size?: number | {
  17842. width: number;
  17843. height: number;
  17844. } | {
  17845. ratio: number;
  17846. });
  17847. /**
  17848. * @hidden
  17849. * @param faceIndex the face index, if its a cube texture
  17850. */
  17851. _bindFrameBuffer(faceIndex?: number): void;
  17852. /**
  17853. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17854. * @returns the view count
  17855. */
  17856. getViewCount(): number;
  17857. }
  17858. }
  17859. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17860. import { Camera } from "babylonjs/Cameras/camera";
  17861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17862. import { Nullable } from "babylonjs/types";
  17863. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17864. import { Matrix } from "babylonjs/Maths/math";
  17865. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17866. module "babylonjs/Engines/engine" {
  17867. interface Engine {
  17868. /**
  17869. * Creates a new multiview render target
  17870. * @param width defines the width of the texture
  17871. * @param height defines the height of the texture
  17872. * @returns the created multiview texture
  17873. */
  17874. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17875. /**
  17876. * Binds a multiview framebuffer to be drawn to
  17877. * @param multiviewTexture texture to bind
  17878. */
  17879. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17880. }
  17881. }
  17882. module "babylonjs/Cameras/camera" {
  17883. interface Camera {
  17884. /**
  17885. * @hidden
  17886. * 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)
  17887. */
  17888. _useMultiviewToSingleView: boolean;
  17889. /**
  17890. * @hidden
  17891. * 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)
  17892. */
  17893. _multiviewTexture: Nullable<RenderTargetTexture>;
  17894. /**
  17895. * @hidden
  17896. * ensures the multiview texture of the camera exists and has the specified width/height
  17897. * @param width height to set on the multiview texture
  17898. * @param height width to set on the multiview texture
  17899. */
  17900. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17901. }
  17902. }
  17903. module "babylonjs/scene" {
  17904. interface Scene {
  17905. /** @hidden */
  17906. _transformMatrixR: Matrix;
  17907. /** @hidden */
  17908. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17909. /** @hidden */
  17910. _createMultiviewUbo(): void;
  17911. /** @hidden */
  17912. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17913. /** @hidden */
  17914. _renderMultiviewToSingleView(camera: Camera): void;
  17915. }
  17916. }
  17917. }
  17918. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17919. import { Camera } from "babylonjs/Cameras/camera";
  17920. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17921. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17922. import "babylonjs/Engines/Extensions/engine.multiview";
  17923. /**
  17924. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17925. * This will not be used for webXR as it supports displaying texture arrays directly
  17926. */
  17927. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17928. /**
  17929. * Initializes a VRMultiviewToSingleview
  17930. * @param name name of the post process
  17931. * @param camera camera to be applied to
  17932. * @param scaleFactor scaling factor to the size of the output texture
  17933. */
  17934. constructor(name: string, camera: Camera, scaleFactor: number);
  17935. }
  17936. }
  17937. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17938. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17939. import { Nullable } from "babylonjs/types";
  17940. import { Size } from "babylonjs/Maths/math";
  17941. import { Observable } from "babylonjs/Misc/observable";
  17942. module "babylonjs/Engines/engine" {
  17943. interface Engine {
  17944. /** @hidden */
  17945. _vrDisplay: any;
  17946. /** @hidden */
  17947. _vrSupported: boolean;
  17948. /** @hidden */
  17949. _oldSize: Size;
  17950. /** @hidden */
  17951. _oldHardwareScaleFactor: number;
  17952. /** @hidden */
  17953. _vrExclusivePointerMode: boolean;
  17954. /** @hidden */
  17955. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17956. /** @hidden */
  17957. _onVRDisplayPointerRestricted: () => void;
  17958. /** @hidden */
  17959. _onVRDisplayPointerUnrestricted: () => void;
  17960. /** @hidden */
  17961. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17962. /** @hidden */
  17963. _onVrDisplayDisconnect: Nullable<() => void>;
  17964. /** @hidden */
  17965. _onVrDisplayPresentChange: Nullable<() => void>;
  17966. /**
  17967. * Observable signaled when VR display mode changes
  17968. */
  17969. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17970. /**
  17971. * Observable signaled when VR request present is complete
  17972. */
  17973. onVRRequestPresentComplete: Observable<boolean>;
  17974. /**
  17975. * Observable signaled when VR request present starts
  17976. */
  17977. onVRRequestPresentStart: Observable<Engine>;
  17978. /**
  17979. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17980. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17981. */
  17982. isInVRExclusivePointerMode: boolean;
  17983. /**
  17984. * Gets a boolean indicating if a webVR device was detected
  17985. * @returns true if a webVR device was detected
  17986. */
  17987. isVRDevicePresent(): boolean;
  17988. /**
  17989. * Gets the current webVR device
  17990. * @returns the current webVR device (or null)
  17991. */
  17992. getVRDevice(): any;
  17993. /**
  17994. * Initializes a webVR display and starts listening to display change events
  17995. * The onVRDisplayChangedObservable will be notified upon these changes
  17996. * @returns A promise containing a VRDisplay and if vr is supported
  17997. */
  17998. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17999. /** @hidden */
  18000. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18001. /**
  18002. * Call this function to switch to webVR mode
  18003. * Will do nothing if webVR is not supported or if there is no webVR device
  18004. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18005. */
  18006. enableVR(): void;
  18007. /** @hidden */
  18008. _onVRFullScreenTriggered(): void;
  18009. }
  18010. }
  18011. }
  18012. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18013. import { Nullable } from "babylonjs/types";
  18014. import { Observable } from "babylonjs/Misc/observable";
  18015. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18016. import { Scene } from "babylonjs/scene";
  18017. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18018. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18019. import { Node } from "babylonjs/node";
  18020. import { Ray } from "babylonjs/Culling/ray";
  18021. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18022. import "babylonjs/Engines/Extensions/engine.webVR";
  18023. /**
  18024. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18025. * IMPORTANT!! The data is right-hand data.
  18026. * @export
  18027. * @interface DevicePose
  18028. */
  18029. export interface DevicePose {
  18030. /**
  18031. * The position of the device, values in array are [x,y,z].
  18032. */
  18033. readonly position: Nullable<Float32Array>;
  18034. /**
  18035. * The linearVelocity of the device, values in array are [x,y,z].
  18036. */
  18037. readonly linearVelocity: Nullable<Float32Array>;
  18038. /**
  18039. * The linearAcceleration of the device, values in array are [x,y,z].
  18040. */
  18041. readonly linearAcceleration: Nullable<Float32Array>;
  18042. /**
  18043. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18044. */
  18045. readonly orientation: Nullable<Float32Array>;
  18046. /**
  18047. * The angularVelocity of the device, values in array are [x,y,z].
  18048. */
  18049. readonly angularVelocity: Nullable<Float32Array>;
  18050. /**
  18051. * The angularAcceleration of the device, values in array are [x,y,z].
  18052. */
  18053. readonly angularAcceleration: Nullable<Float32Array>;
  18054. }
  18055. /**
  18056. * Interface representing a pose controlled object in Babylon.
  18057. * A pose controlled object has both regular pose values as well as pose values
  18058. * from an external device such as a VR head mounted display
  18059. */
  18060. export interface PoseControlled {
  18061. /**
  18062. * The position of the object in babylon space.
  18063. */
  18064. position: Vector3;
  18065. /**
  18066. * The rotation quaternion of the object in babylon space.
  18067. */
  18068. rotationQuaternion: Quaternion;
  18069. /**
  18070. * The position of the device in babylon space.
  18071. */
  18072. devicePosition?: Vector3;
  18073. /**
  18074. * The rotation quaternion of the device in babylon space.
  18075. */
  18076. deviceRotationQuaternion: Quaternion;
  18077. /**
  18078. * The raw pose coming from the device.
  18079. */
  18080. rawPose: Nullable<DevicePose>;
  18081. /**
  18082. * The scale of the device to be used when translating from device space to babylon space.
  18083. */
  18084. deviceScaleFactor: number;
  18085. /**
  18086. * Updates the poseControlled values based on the input device pose.
  18087. * @param poseData the pose data to update the object with
  18088. */
  18089. updateFromDevice(poseData: DevicePose): void;
  18090. }
  18091. /**
  18092. * Set of options to customize the webVRCamera
  18093. */
  18094. export interface WebVROptions {
  18095. /**
  18096. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18097. */
  18098. trackPosition?: boolean;
  18099. /**
  18100. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18101. */
  18102. positionScale?: number;
  18103. /**
  18104. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18105. */
  18106. displayName?: string;
  18107. /**
  18108. * Should the native controller meshes be initialized. (default: true)
  18109. */
  18110. controllerMeshes?: boolean;
  18111. /**
  18112. * Creating a default HemiLight only on controllers. (default: true)
  18113. */
  18114. defaultLightingOnControllers?: boolean;
  18115. /**
  18116. * If you don't want to use the default VR button of the helper. (default: false)
  18117. */
  18118. useCustomVRButton?: boolean;
  18119. /**
  18120. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18121. */
  18122. customVRButton?: HTMLButtonElement;
  18123. /**
  18124. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18125. */
  18126. rayLength?: number;
  18127. /**
  18128. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18129. */
  18130. defaultHeight?: number;
  18131. /**
  18132. * If multiview should be used if availible (default: false)
  18133. */
  18134. useMultiview?: boolean;
  18135. }
  18136. /**
  18137. * This represents a WebVR camera.
  18138. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18139. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18140. */
  18141. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18142. private webVROptions;
  18143. /**
  18144. * @hidden
  18145. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18146. */
  18147. _vrDevice: any;
  18148. /**
  18149. * The rawPose of the vrDevice.
  18150. */
  18151. rawPose: Nullable<DevicePose>;
  18152. private _onVREnabled;
  18153. private _specsVersion;
  18154. private _attached;
  18155. private _frameData;
  18156. protected _descendants: Array<Node>;
  18157. private _deviceRoomPosition;
  18158. /** @hidden */
  18159. _deviceRoomRotationQuaternion: Quaternion;
  18160. private _standingMatrix;
  18161. /**
  18162. * Represents device position in babylon space.
  18163. */
  18164. devicePosition: Vector3;
  18165. /**
  18166. * Represents device rotation in babylon space.
  18167. */
  18168. deviceRotationQuaternion: Quaternion;
  18169. /**
  18170. * The scale of the device to be used when translating from device space to babylon space.
  18171. */
  18172. deviceScaleFactor: number;
  18173. private _deviceToWorld;
  18174. private _worldToDevice;
  18175. /**
  18176. * References to the webVR controllers for the vrDevice.
  18177. */
  18178. controllers: Array<WebVRController>;
  18179. /**
  18180. * Emits an event when a controller is attached.
  18181. */
  18182. onControllersAttachedObservable: Observable<WebVRController[]>;
  18183. /**
  18184. * Emits an event when a controller's mesh has been loaded;
  18185. */
  18186. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18187. /**
  18188. * Emits an event when the HMD's pose has been updated.
  18189. */
  18190. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18191. private _poseSet;
  18192. /**
  18193. * If the rig cameras be used as parent instead of this camera.
  18194. */
  18195. rigParenting: boolean;
  18196. private _lightOnControllers;
  18197. private _defaultHeight?;
  18198. /**
  18199. * Instantiates a WebVRFreeCamera.
  18200. * @param name The name of the WebVRFreeCamera
  18201. * @param position The starting anchor position for the camera
  18202. * @param scene The scene the camera belongs to
  18203. * @param webVROptions a set of customizable options for the webVRCamera
  18204. */
  18205. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18206. /**
  18207. * Gets the device distance from the ground in meters.
  18208. * @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.
  18209. */
  18210. deviceDistanceToRoomGround(): number;
  18211. /**
  18212. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18213. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18214. */
  18215. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18216. /**
  18217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18218. * @returns A promise with a boolean set to if the standing matrix is supported.
  18219. */
  18220. useStandingMatrixAsync(): Promise<boolean>;
  18221. /**
  18222. * Disposes the camera
  18223. */
  18224. dispose(): void;
  18225. /**
  18226. * Gets a vrController by name.
  18227. * @param name The name of the controller to retreive
  18228. * @returns the controller matching the name specified or null if not found
  18229. */
  18230. getControllerByName(name: string): Nullable<WebVRController>;
  18231. private _leftController;
  18232. /**
  18233. * The controller corresponding to the users left hand.
  18234. */
  18235. readonly leftController: Nullable<WebVRController>;
  18236. private _rightController;
  18237. /**
  18238. * The controller corresponding to the users right hand.
  18239. */
  18240. readonly rightController: Nullable<WebVRController>;
  18241. /**
  18242. * Casts a ray forward from the vrCamera's gaze.
  18243. * @param length Length of the ray (default: 100)
  18244. * @returns the ray corresponding to the gaze
  18245. */
  18246. getForwardRay(length?: number): Ray;
  18247. /**
  18248. * @hidden
  18249. * Updates the camera based on device's frame data
  18250. */
  18251. _checkInputs(): void;
  18252. /**
  18253. * Updates the poseControlled values based on the input device pose.
  18254. * @param poseData Pose coming from the device
  18255. */
  18256. updateFromDevice(poseData: DevicePose): void;
  18257. private _htmlElementAttached;
  18258. private _detachIfAttached;
  18259. /**
  18260. * WebVR's attach control will start broadcasting frames to the device.
  18261. * Note that in certain browsers (chrome for example) this function must be called
  18262. * within a user-interaction callback. Example:
  18263. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18264. *
  18265. * @param element html element to attach the vrDevice to
  18266. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18267. */
  18268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18269. /**
  18270. * Detaches the camera from the html element and disables VR
  18271. *
  18272. * @param element html element to detach from
  18273. */
  18274. detachControl(element: HTMLElement): void;
  18275. /**
  18276. * @returns the name of this class
  18277. */
  18278. getClassName(): string;
  18279. /**
  18280. * Calls resetPose on the vrDisplay
  18281. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18282. */
  18283. resetToCurrentRotation(): void;
  18284. /**
  18285. * @hidden
  18286. * Updates the rig cameras (left and right eye)
  18287. */
  18288. _updateRigCameras(): void;
  18289. private _workingVector;
  18290. private _oneVector;
  18291. private _workingMatrix;
  18292. private updateCacheCalled;
  18293. private _correctPositionIfNotTrackPosition;
  18294. /**
  18295. * @hidden
  18296. * Updates the cached values of the camera
  18297. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18298. */
  18299. _updateCache(ignoreParentClass?: boolean): void;
  18300. /**
  18301. * @hidden
  18302. * Get current device position in babylon world
  18303. */
  18304. _computeDevicePosition(): void;
  18305. /**
  18306. * Updates the current device position and rotation in the babylon world
  18307. */
  18308. update(): void;
  18309. /**
  18310. * @hidden
  18311. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18312. * @returns an identity matrix
  18313. */
  18314. _getViewMatrix(): Matrix;
  18315. private _tmpMatrix;
  18316. /**
  18317. * This function is called by the two RIG cameras.
  18318. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18319. * @hidden
  18320. */
  18321. _getWebVRViewMatrix(): Matrix;
  18322. /** @hidden */
  18323. _getWebVRProjectionMatrix(): Matrix;
  18324. private _onGamepadConnectedObserver;
  18325. private _onGamepadDisconnectedObserver;
  18326. private _updateCacheWhenTrackingDisabledObserver;
  18327. /**
  18328. * Initializes the controllers and their meshes
  18329. */
  18330. initControllers(): void;
  18331. }
  18332. }
  18333. declare module "babylonjs/PostProcesses/postProcess" {
  18334. import { Nullable } from "babylonjs/types";
  18335. import { SmartArray } from "babylonjs/Misc/smartArray";
  18336. import { Observable } from "babylonjs/Misc/observable";
  18337. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18338. import { Camera } from "babylonjs/Cameras/camera";
  18339. import { Effect } from "babylonjs/Materials/effect";
  18340. import "babylonjs/Shaders/postprocess.vertex";
  18341. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18343. import { Engine } from "babylonjs/Engines/engine";
  18344. /**
  18345. * Size options for a post process
  18346. */
  18347. export type PostProcessOptions = {
  18348. width: number;
  18349. height: number;
  18350. };
  18351. /**
  18352. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18353. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18354. */
  18355. export class PostProcess {
  18356. /** Name of the PostProcess. */
  18357. name: string;
  18358. /**
  18359. * Gets or sets the unique id of the post process
  18360. */
  18361. uniqueId: number;
  18362. /**
  18363. * Width of the texture to apply the post process on
  18364. */
  18365. width: number;
  18366. /**
  18367. * Height of the texture to apply the post process on
  18368. */
  18369. height: number;
  18370. /**
  18371. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18372. * @hidden
  18373. */
  18374. _outputTexture: Nullable<InternalTexture>;
  18375. /**
  18376. * Sampling mode used by the shader
  18377. * See https://doc.babylonjs.com/classes/3.1/texture
  18378. */
  18379. renderTargetSamplingMode: number;
  18380. /**
  18381. * Clear color to use when screen clearing
  18382. */
  18383. clearColor: Color4;
  18384. /**
  18385. * If the buffer needs to be cleared before applying the post process. (default: true)
  18386. * Should be set to false if shader will overwrite all previous pixels.
  18387. */
  18388. autoClear: boolean;
  18389. /**
  18390. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18391. */
  18392. alphaMode: number;
  18393. /**
  18394. * Sets the setAlphaBlendConstants of the babylon engine
  18395. */
  18396. alphaConstants: Color4;
  18397. /**
  18398. * Animations to be used for the post processing
  18399. */
  18400. animations: import("babylonjs/Animations/animation").Animation[];
  18401. /**
  18402. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18403. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18404. */
  18405. enablePixelPerfectMode: boolean;
  18406. /**
  18407. * Force the postprocess to be applied without taking in account viewport
  18408. */
  18409. forceFullscreenViewport: boolean;
  18410. /**
  18411. * List of inspectable custom properties (used by the Inspector)
  18412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18413. */
  18414. inspectableCustomProperties: IInspectable[];
  18415. /**
  18416. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18417. *
  18418. * | Value | Type | Description |
  18419. * | ----- | ----------------------------------- | ----------- |
  18420. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18421. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18422. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18423. *
  18424. */
  18425. scaleMode: number;
  18426. /**
  18427. * Force textures to be a power of two (default: false)
  18428. */
  18429. alwaysForcePOT: boolean;
  18430. private _samples;
  18431. /**
  18432. * Number of sample textures (default: 1)
  18433. */
  18434. samples: number;
  18435. /**
  18436. * Modify the scale of the post process to be the same as the viewport (default: false)
  18437. */
  18438. adaptScaleToCurrentViewport: boolean;
  18439. private _camera;
  18440. private _scene;
  18441. private _engine;
  18442. private _options;
  18443. private _reusable;
  18444. private _textureType;
  18445. /**
  18446. * Smart array of input and output textures for the post process.
  18447. * @hidden
  18448. */
  18449. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18450. /**
  18451. * The index in _textures that corresponds to the output texture.
  18452. * @hidden
  18453. */
  18454. _currentRenderTextureInd: number;
  18455. private _effect;
  18456. private _samplers;
  18457. private _fragmentUrl;
  18458. private _vertexUrl;
  18459. private _parameters;
  18460. private _scaleRatio;
  18461. protected _indexParameters: any;
  18462. private _shareOutputWithPostProcess;
  18463. private _texelSize;
  18464. private _forcedOutputTexture;
  18465. /**
  18466. * Returns the fragment url or shader name used in the post process.
  18467. * @returns the fragment url or name in the shader store.
  18468. */
  18469. getEffectName(): string;
  18470. /**
  18471. * An event triggered when the postprocess is activated.
  18472. */
  18473. onActivateObservable: Observable<Camera>;
  18474. private _onActivateObserver;
  18475. /**
  18476. * A function that is added to the onActivateObservable
  18477. */
  18478. onActivate: Nullable<(camera: Camera) => void>;
  18479. /**
  18480. * An event triggered when the postprocess changes its size.
  18481. */
  18482. onSizeChangedObservable: Observable<PostProcess>;
  18483. private _onSizeChangedObserver;
  18484. /**
  18485. * A function that is added to the onSizeChangedObservable
  18486. */
  18487. onSizeChanged: (postProcess: PostProcess) => void;
  18488. /**
  18489. * An event triggered when the postprocess applies its effect.
  18490. */
  18491. onApplyObservable: Observable<Effect>;
  18492. private _onApplyObserver;
  18493. /**
  18494. * A function that is added to the onApplyObservable
  18495. */
  18496. onApply: (effect: Effect) => void;
  18497. /**
  18498. * An event triggered before rendering the postprocess
  18499. */
  18500. onBeforeRenderObservable: Observable<Effect>;
  18501. private _onBeforeRenderObserver;
  18502. /**
  18503. * A function that is added to the onBeforeRenderObservable
  18504. */
  18505. onBeforeRender: (effect: Effect) => void;
  18506. /**
  18507. * An event triggered after rendering the postprocess
  18508. */
  18509. onAfterRenderObservable: Observable<Effect>;
  18510. private _onAfterRenderObserver;
  18511. /**
  18512. * A function that is added to the onAfterRenderObservable
  18513. */
  18514. onAfterRender: (efect: Effect) => void;
  18515. /**
  18516. * 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
  18517. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18518. */
  18519. inputTexture: InternalTexture;
  18520. /**
  18521. * Gets the camera which post process is applied to.
  18522. * @returns The camera the post process is applied to.
  18523. */
  18524. getCamera(): Camera;
  18525. /**
  18526. * Gets the texel size of the postprocess.
  18527. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18528. */
  18529. readonly texelSize: Vector2;
  18530. /**
  18531. * Creates a new instance PostProcess
  18532. * @param name The name of the PostProcess.
  18533. * @param fragmentUrl The url of the fragment shader to be used.
  18534. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18535. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18536. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18537. * @param camera The camera to apply the render pass to.
  18538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18539. * @param engine The engine which the post process will be applied. (default: current engine)
  18540. * @param reusable If the post process can be reused on the same frame. (default: false)
  18541. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18542. * @param textureType Type of textures used when performing the post process. (default: 0)
  18543. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18544. * @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
  18545. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18546. */
  18547. constructor(
  18548. /** Name of the PostProcess. */
  18549. 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);
  18550. /**
  18551. * Gets a string idenfifying the name of the class
  18552. * @returns "PostProcess" string
  18553. */
  18554. getClassName(): string;
  18555. /**
  18556. * Gets the engine which this post process belongs to.
  18557. * @returns The engine the post process was enabled with.
  18558. */
  18559. getEngine(): Engine;
  18560. /**
  18561. * The effect that is created when initializing the post process.
  18562. * @returns The created effect corresponding the the postprocess.
  18563. */
  18564. getEffect(): Effect;
  18565. /**
  18566. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18567. * @param postProcess The post process to share the output with.
  18568. * @returns This post process.
  18569. */
  18570. shareOutputWith(postProcess: PostProcess): PostProcess;
  18571. /**
  18572. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18573. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18574. */
  18575. useOwnOutput(): void;
  18576. /**
  18577. * Updates the effect with the current post process compile time values and recompiles the shader.
  18578. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18579. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18580. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18581. * @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
  18582. * @param onCompiled Called when the shader has been compiled.
  18583. * @param onError Called if there is an error when compiling a shader.
  18584. */
  18585. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18586. /**
  18587. * The post process is reusable if it can be used multiple times within one frame.
  18588. * @returns If the post process is reusable
  18589. */
  18590. isReusable(): boolean;
  18591. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18592. markTextureDirty(): void;
  18593. /**
  18594. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18595. * 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.
  18596. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18597. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18598. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18599. * @returns The target texture that was bound to be written to.
  18600. */
  18601. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18602. /**
  18603. * If the post process is supported.
  18604. */
  18605. readonly isSupported: boolean;
  18606. /**
  18607. * The aspect ratio of the output texture.
  18608. */
  18609. readonly aspectRatio: number;
  18610. /**
  18611. * Get a value indicating if the post-process is ready to be used
  18612. * @returns true if the post-process is ready (shader is compiled)
  18613. */
  18614. isReady(): boolean;
  18615. /**
  18616. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18617. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18618. */
  18619. apply(): Nullable<Effect>;
  18620. private _disposeTextures;
  18621. /**
  18622. * Disposes the post process.
  18623. * @param camera The camera to dispose the post process on.
  18624. */
  18625. dispose(camera?: Camera): void;
  18626. }
  18627. }
  18628. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18629. /** @hidden */
  18630. export var kernelBlurVaryingDeclaration: {
  18631. name: string;
  18632. shader: string;
  18633. };
  18634. }
  18635. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18636. /** @hidden */
  18637. export var kernelBlurFragment: {
  18638. name: string;
  18639. shader: string;
  18640. };
  18641. }
  18642. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18643. /** @hidden */
  18644. export var kernelBlurFragment2: {
  18645. name: string;
  18646. shader: string;
  18647. };
  18648. }
  18649. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18650. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18651. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18652. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18653. /** @hidden */
  18654. export var kernelBlurPixelShader: {
  18655. name: string;
  18656. shader: string;
  18657. };
  18658. }
  18659. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18660. /** @hidden */
  18661. export var kernelBlurVertex: {
  18662. name: string;
  18663. shader: string;
  18664. };
  18665. }
  18666. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18667. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18668. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18669. /** @hidden */
  18670. export var kernelBlurVertexShader: {
  18671. name: string;
  18672. shader: string;
  18673. };
  18674. }
  18675. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18676. import { Vector2 } from "babylonjs/Maths/math";
  18677. import { Nullable } from "babylonjs/types";
  18678. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18679. import { Camera } from "babylonjs/Cameras/camera";
  18680. import { Effect } from "babylonjs/Materials/effect";
  18681. import { Engine } from "babylonjs/Engines/engine";
  18682. import "babylonjs/Shaders/kernelBlur.fragment";
  18683. import "babylonjs/Shaders/kernelBlur.vertex";
  18684. /**
  18685. * The Blur Post Process which blurs an image based on a kernel and direction.
  18686. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18687. */
  18688. export class BlurPostProcess extends PostProcess {
  18689. /** The direction in which to blur the image. */
  18690. direction: Vector2;
  18691. private blockCompilation;
  18692. protected _kernel: number;
  18693. protected _idealKernel: number;
  18694. protected _packedFloat: boolean;
  18695. private _staticDefines;
  18696. /**
  18697. * Sets the length in pixels of the blur sample region
  18698. */
  18699. /**
  18700. * Gets the length in pixels of the blur sample region
  18701. */
  18702. kernel: number;
  18703. /**
  18704. * Sets wether or not the blur needs to unpack/repack floats
  18705. */
  18706. /**
  18707. * Gets wether or not the blur is unpacking/repacking floats
  18708. */
  18709. packedFloat: boolean;
  18710. /**
  18711. * Creates a new instance BlurPostProcess
  18712. * @param name The name of the effect.
  18713. * @param direction The direction in which to blur the image.
  18714. * @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.
  18715. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18716. * @param camera The camera to apply the render pass to.
  18717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18718. * @param engine The engine which the post process will be applied. (default: current engine)
  18719. * @param reusable If the post process can be reused on the same frame. (default: false)
  18720. * @param textureType Type of textures used when performing the post process. (default: 0)
  18721. * @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)
  18722. */
  18723. constructor(name: string,
  18724. /** The direction in which to blur the image. */
  18725. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18726. /**
  18727. * Updates the effect with the current post process compile time values and recompiles the shader.
  18728. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18729. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18730. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18731. * @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
  18732. * @param onCompiled Called when the shader has been compiled.
  18733. * @param onError Called if there is an error when compiling a shader.
  18734. */
  18735. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18736. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18737. /**
  18738. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18739. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18740. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18741. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18742. * The gaps between physical kernels are compensated for in the weighting of the samples
  18743. * @param idealKernel Ideal blur kernel.
  18744. * @return Nearest best kernel.
  18745. */
  18746. protected _nearestBestKernel(idealKernel: number): number;
  18747. /**
  18748. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18749. * @param x The point on the Gaussian distribution to sample.
  18750. * @return the value of the Gaussian function at x.
  18751. */
  18752. protected _gaussianWeight(x: number): number;
  18753. /**
  18754. * Generates a string that can be used as a floating point number in GLSL.
  18755. * @param x Value to print.
  18756. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18757. * @return GLSL float string.
  18758. */
  18759. protected _glslFloat(x: number, decimalFigures?: number): string;
  18760. }
  18761. }
  18762. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18763. import { Scene } from "babylonjs/scene";
  18764. import { Plane } from "babylonjs/Maths/math";
  18765. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18766. /**
  18767. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18768. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18769. * You can then easily use it as a reflectionTexture on a flat surface.
  18770. * In case the surface is not a plane, please consider relying on reflection probes.
  18771. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18772. */
  18773. export class MirrorTexture extends RenderTargetTexture {
  18774. private scene;
  18775. /**
  18776. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18777. * 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.
  18778. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18779. */
  18780. mirrorPlane: Plane;
  18781. /**
  18782. * Define the blur ratio used to blur the reflection if needed.
  18783. */
  18784. blurRatio: number;
  18785. /**
  18786. * Define the adaptive blur kernel used to blur the reflection if needed.
  18787. * This will autocompute the closest best match for the `blurKernel`
  18788. */
  18789. adaptiveBlurKernel: number;
  18790. /**
  18791. * Define the blur kernel used to blur the reflection if needed.
  18792. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18793. */
  18794. blurKernel: number;
  18795. /**
  18796. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18797. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18798. */
  18799. blurKernelX: number;
  18800. /**
  18801. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18802. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18803. */
  18804. blurKernelY: number;
  18805. private _autoComputeBlurKernel;
  18806. protected _onRatioRescale(): void;
  18807. private _updateGammaSpace;
  18808. private _imageProcessingConfigChangeObserver;
  18809. private _transformMatrix;
  18810. private _mirrorMatrix;
  18811. private _savedViewMatrix;
  18812. private _blurX;
  18813. private _blurY;
  18814. private _adaptiveBlurKernel;
  18815. private _blurKernelX;
  18816. private _blurKernelY;
  18817. private _blurRatio;
  18818. /**
  18819. * Instantiates a Mirror Texture.
  18820. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18821. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18822. * You can then easily use it as a reflectionTexture on a flat surface.
  18823. * In case the surface is not a plane, please consider relying on reflection probes.
  18824. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18825. * @param name
  18826. * @param size
  18827. * @param scene
  18828. * @param generateMipMaps
  18829. * @param type
  18830. * @param samplingMode
  18831. * @param generateDepthBuffer
  18832. */
  18833. constructor(name: string, size: number | {
  18834. width: number;
  18835. height: number;
  18836. } | {
  18837. ratio: number;
  18838. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18839. private _preparePostProcesses;
  18840. /**
  18841. * Clone the mirror texture.
  18842. * @returns the cloned texture
  18843. */
  18844. clone(): MirrorTexture;
  18845. /**
  18846. * Serialize the texture to a JSON representation you could use in Parse later on
  18847. * @returns the serialized JSON representation
  18848. */
  18849. serialize(): any;
  18850. /**
  18851. * Dispose the texture and release its associated resources.
  18852. */
  18853. dispose(): void;
  18854. }
  18855. }
  18856. declare module "babylonjs/Materials/Textures/texture" {
  18857. import { Observable } from "babylonjs/Misc/observable";
  18858. import { Nullable } from "babylonjs/types";
  18859. import { Scene } from "babylonjs/scene";
  18860. import { Matrix } from "babylonjs/Maths/math";
  18861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18862. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18863. /**
  18864. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18865. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18866. */
  18867. export class Texture extends BaseTexture {
  18868. /** @hidden */
  18869. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18870. /** @hidden */
  18871. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18872. /** @hidden */
  18873. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18874. /** nearest is mag = nearest and min = nearest and mip = linear */
  18875. static readonly NEAREST_SAMPLINGMODE: number;
  18876. /** nearest is mag = nearest and min = nearest and mip = linear */
  18877. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18879. static readonly BILINEAR_SAMPLINGMODE: number;
  18880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18881. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18882. /** Trilinear is mag = linear and min = linear and mip = linear */
  18883. static readonly TRILINEAR_SAMPLINGMODE: number;
  18884. /** Trilinear is mag = linear and min = linear and mip = linear */
  18885. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18886. /** mag = nearest and min = nearest and mip = nearest */
  18887. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18888. /** mag = nearest and min = linear and mip = nearest */
  18889. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18890. /** mag = nearest and min = linear and mip = linear */
  18891. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18892. /** mag = nearest and min = linear and mip = none */
  18893. static readonly NEAREST_LINEAR: number;
  18894. /** mag = nearest and min = nearest and mip = none */
  18895. static readonly NEAREST_NEAREST: number;
  18896. /** mag = linear and min = nearest and mip = nearest */
  18897. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18898. /** mag = linear and min = nearest and mip = linear */
  18899. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18900. /** mag = linear and min = linear and mip = none */
  18901. static readonly LINEAR_LINEAR: number;
  18902. /** mag = linear and min = nearest and mip = none */
  18903. static readonly LINEAR_NEAREST: number;
  18904. /** Explicit coordinates mode */
  18905. static readonly EXPLICIT_MODE: number;
  18906. /** Spherical coordinates mode */
  18907. static readonly SPHERICAL_MODE: number;
  18908. /** Planar coordinates mode */
  18909. static readonly PLANAR_MODE: number;
  18910. /** Cubic coordinates mode */
  18911. static readonly CUBIC_MODE: number;
  18912. /** Projection coordinates mode */
  18913. static readonly PROJECTION_MODE: number;
  18914. /** Inverse Cubic coordinates mode */
  18915. static readonly SKYBOX_MODE: number;
  18916. /** Inverse Cubic coordinates mode */
  18917. static readonly INVCUBIC_MODE: number;
  18918. /** Equirectangular coordinates mode */
  18919. static readonly EQUIRECTANGULAR_MODE: number;
  18920. /** Equirectangular Fixed coordinates mode */
  18921. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18922. /** Equirectangular Fixed Mirrored coordinates mode */
  18923. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18924. /** Texture is not repeating outside of 0..1 UVs */
  18925. static readonly CLAMP_ADDRESSMODE: number;
  18926. /** Texture is repeating outside of 0..1 UVs */
  18927. static readonly WRAP_ADDRESSMODE: number;
  18928. /** Texture is repeating and mirrored */
  18929. static readonly MIRROR_ADDRESSMODE: number;
  18930. /**
  18931. * 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
  18932. */
  18933. static UseSerializedUrlIfAny: boolean;
  18934. /**
  18935. * Define the url of the texture.
  18936. */
  18937. url: Nullable<string>;
  18938. /**
  18939. * Define an offset on the texture to offset the u coordinates of the UVs
  18940. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18941. */
  18942. uOffset: number;
  18943. /**
  18944. * Define an offset on the texture to offset the v coordinates of the UVs
  18945. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18946. */
  18947. vOffset: number;
  18948. /**
  18949. * Define an offset on the texture to scale the u coordinates of the UVs
  18950. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18951. */
  18952. uScale: number;
  18953. /**
  18954. * Define an offset on the texture to scale the v coordinates of the UVs
  18955. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18956. */
  18957. vScale: number;
  18958. /**
  18959. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18960. * @see http://doc.babylonjs.com/how_to/more_materials
  18961. */
  18962. uAng: number;
  18963. /**
  18964. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18965. * @see http://doc.babylonjs.com/how_to/more_materials
  18966. */
  18967. vAng: number;
  18968. /**
  18969. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18970. * @see http://doc.babylonjs.com/how_to/more_materials
  18971. */
  18972. wAng: number;
  18973. /**
  18974. * Defines the center of rotation (U)
  18975. */
  18976. uRotationCenter: number;
  18977. /**
  18978. * Defines the center of rotation (V)
  18979. */
  18980. vRotationCenter: number;
  18981. /**
  18982. * Defines the center of rotation (W)
  18983. */
  18984. wRotationCenter: number;
  18985. /**
  18986. * Are mip maps generated for this texture or not.
  18987. */
  18988. readonly noMipmap: boolean;
  18989. /**
  18990. * List of inspectable custom properties (used by the Inspector)
  18991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18992. */
  18993. inspectableCustomProperties: Nullable<IInspectable[]>;
  18994. private _noMipmap;
  18995. /** @hidden */
  18996. _invertY: boolean;
  18997. private _rowGenerationMatrix;
  18998. private _cachedTextureMatrix;
  18999. private _projectionModeMatrix;
  19000. private _t0;
  19001. private _t1;
  19002. private _t2;
  19003. private _cachedUOffset;
  19004. private _cachedVOffset;
  19005. private _cachedUScale;
  19006. private _cachedVScale;
  19007. private _cachedUAng;
  19008. private _cachedVAng;
  19009. private _cachedWAng;
  19010. private _cachedProjectionMatrixId;
  19011. private _cachedCoordinatesMode;
  19012. /** @hidden */
  19013. protected _initialSamplingMode: number;
  19014. /** @hidden */
  19015. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19016. private _deleteBuffer;
  19017. protected _format: Nullable<number>;
  19018. private _delayedOnLoad;
  19019. private _delayedOnError;
  19020. /**
  19021. * Observable triggered once the texture has been loaded.
  19022. */
  19023. onLoadObservable: Observable<Texture>;
  19024. protected _isBlocking: boolean;
  19025. /**
  19026. * Is the texture preventing material to render while loading.
  19027. * If false, a default texture will be used instead of the loading one during the preparation step.
  19028. */
  19029. isBlocking: boolean;
  19030. /**
  19031. * Get the current sampling mode associated with the texture.
  19032. */
  19033. readonly samplingMode: number;
  19034. /**
  19035. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19036. */
  19037. readonly invertY: boolean;
  19038. /**
  19039. * Instantiates a new texture.
  19040. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19041. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19042. * @param url define the url of the picture to load as a texture
  19043. * @param scene define the scene the texture will belong to
  19044. * @param noMipmap define if the texture will require mip maps or not
  19045. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19046. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19047. * @param onLoad define a callback triggered when the texture has been loaded
  19048. * @param onError define a callback triggered when an error occurred during the loading session
  19049. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19050. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19051. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19052. */
  19053. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  19054. /**
  19055. * Update the url (and optional buffer) of this texture if url was null during construction.
  19056. * @param url the url of the texture
  19057. * @param buffer the buffer of the texture (defaults to null)
  19058. * @param onLoad callback called when the texture is loaded (defaults to null)
  19059. */
  19060. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19061. /**
  19062. * Finish the loading sequence of a texture flagged as delayed load.
  19063. * @hidden
  19064. */
  19065. delayLoad(): void;
  19066. private _prepareRowForTextureGeneration;
  19067. /**
  19068. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19069. * @returns the transform matrix of the texture.
  19070. */
  19071. getTextureMatrix(): Matrix;
  19072. /**
  19073. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19074. * @returns The reflection texture transform
  19075. */
  19076. getReflectionTextureMatrix(): Matrix;
  19077. /**
  19078. * Clones the texture.
  19079. * @returns the cloned texture
  19080. */
  19081. clone(): Texture;
  19082. /**
  19083. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19084. * @returns The JSON representation of the texture
  19085. */
  19086. serialize(): any;
  19087. /**
  19088. * Get the current class name of the texture useful for serialization or dynamic coding.
  19089. * @returns "Texture"
  19090. */
  19091. getClassName(): string;
  19092. /**
  19093. * Dispose the texture and release its associated resources.
  19094. */
  19095. dispose(): void;
  19096. /**
  19097. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19098. * @param parsedTexture Define the JSON representation of the texture
  19099. * @param scene Define the scene the parsed texture should be instantiated in
  19100. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19101. * @returns The parsed texture if successful
  19102. */
  19103. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19104. /**
  19105. * Creates a texture from its base 64 representation.
  19106. * @param data Define the base64 payload without the data: prefix
  19107. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19108. * @param scene Define the scene the texture should belong to
  19109. * @param noMipmap Forces the texture to not create mip map information if true
  19110. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19111. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19112. * @param onLoad define a callback triggered when the texture has been loaded
  19113. * @param onError define a callback triggered when an error occurred during the loading session
  19114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19115. * @returns the created texture
  19116. */
  19117. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19118. /**
  19119. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19120. * @param data Define the base64 payload without the data: prefix
  19121. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19122. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19123. * @param scene Define the scene the texture should belong to
  19124. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19125. * @param noMipmap Forces the texture to not create mip map information if true
  19126. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19127. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19128. * @param onLoad define a callback triggered when the texture has been loaded
  19129. * @param onError define a callback triggered when an error occurred during the loading session
  19130. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19131. * @returns the created texture
  19132. */
  19133. 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;
  19134. }
  19135. }
  19136. declare module "babylonjs/PostProcesses/postProcessManager" {
  19137. import { Nullable } from "babylonjs/types";
  19138. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19139. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19140. import { Scene } from "babylonjs/scene";
  19141. /**
  19142. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19143. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19144. */
  19145. export class PostProcessManager {
  19146. private _scene;
  19147. private _indexBuffer;
  19148. private _vertexBuffers;
  19149. /**
  19150. * Creates a new instance PostProcess
  19151. * @param scene The scene that the post process is associated with.
  19152. */
  19153. constructor(scene: Scene);
  19154. private _prepareBuffers;
  19155. private _buildIndexBuffer;
  19156. /**
  19157. * Rebuilds the vertex buffers of the manager.
  19158. * @hidden
  19159. */
  19160. _rebuild(): void;
  19161. /**
  19162. * Prepares a frame to be run through a post process.
  19163. * @param sourceTexture The input texture to the post procesess. (default: null)
  19164. * @param postProcesses An array of post processes to be run. (default: null)
  19165. * @returns True if the post processes were able to be run.
  19166. * @hidden
  19167. */
  19168. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19169. /**
  19170. * Manually render a set of post processes to a texture.
  19171. * @param postProcesses An array of post processes to be run.
  19172. * @param targetTexture The target texture to render to.
  19173. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19174. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19175. * @param lodLevel defines which lod of the texture to render to
  19176. */
  19177. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19178. /**
  19179. * Finalize the result of the output of the postprocesses.
  19180. * @param doNotPresent If true the result will not be displayed to the screen.
  19181. * @param targetTexture The target texture to render to.
  19182. * @param faceIndex The index of the face to bind the target texture to.
  19183. * @param postProcesses The array of post processes to render.
  19184. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19185. * @hidden
  19186. */
  19187. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19188. /**
  19189. * Disposes of the post process manager.
  19190. */
  19191. dispose(): void;
  19192. }
  19193. }
  19194. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19195. import { Scene } from "babylonjs/scene";
  19196. import { ISceneComponent } from "babylonjs/sceneComponent";
  19197. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19198. module "babylonjs/abstractScene" {
  19199. interface AbstractScene {
  19200. /**
  19201. * The list of procedural textures added to the scene
  19202. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19203. */
  19204. proceduralTextures: Array<ProceduralTexture>;
  19205. }
  19206. }
  19207. /**
  19208. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19209. * in a given scene.
  19210. */
  19211. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19212. /**
  19213. * The component name helpfull to identify the component in the list of scene components.
  19214. */
  19215. readonly name: string;
  19216. /**
  19217. * The scene the component belongs to.
  19218. */
  19219. scene: Scene;
  19220. /**
  19221. * Creates a new instance of the component for the given scene
  19222. * @param scene Defines the scene to register the component in
  19223. */
  19224. constructor(scene: Scene);
  19225. /**
  19226. * Registers the component in a given scene
  19227. */
  19228. register(): void;
  19229. /**
  19230. * Rebuilds the elements related to this component in case of
  19231. * context lost for instance.
  19232. */
  19233. rebuild(): void;
  19234. /**
  19235. * Disposes the component and the associated ressources.
  19236. */
  19237. dispose(): void;
  19238. private _beforeClear;
  19239. }
  19240. }
  19241. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19243. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19244. module "babylonjs/Engines/engine" {
  19245. interface Engine {
  19246. /**
  19247. * Creates a new render target cube texture
  19248. * @param size defines the size of the texture
  19249. * @param options defines the options used to create the texture
  19250. * @returns a new render target cube texture stored in an InternalTexture
  19251. */
  19252. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19253. }
  19254. }
  19255. }
  19256. declare module "babylonjs/Shaders/procedural.vertex" {
  19257. /** @hidden */
  19258. export var proceduralVertexShader: {
  19259. name: string;
  19260. shader: string;
  19261. };
  19262. }
  19263. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19264. import { Observable } from "babylonjs/Misc/observable";
  19265. import { Nullable } from "babylonjs/types";
  19266. import { Scene } from "babylonjs/scene";
  19267. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19268. import { Effect } from "babylonjs/Materials/effect";
  19269. import { Texture } from "babylonjs/Materials/Textures/texture";
  19270. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19271. import "babylonjs/Shaders/procedural.vertex";
  19272. /**
  19273. * 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.
  19274. * This is the base class of any Procedural texture and contains most of the shareable code.
  19275. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19276. */
  19277. export class ProceduralTexture extends Texture {
  19278. isCube: boolean;
  19279. /**
  19280. * Define if the texture is enabled or not (disabled texture will not render)
  19281. */
  19282. isEnabled: boolean;
  19283. /**
  19284. * Define if the texture must be cleared before rendering (default is true)
  19285. */
  19286. autoClear: boolean;
  19287. /**
  19288. * Callback called when the texture is generated
  19289. */
  19290. onGenerated: () => void;
  19291. /**
  19292. * Event raised when the texture is generated
  19293. */
  19294. onGeneratedObservable: Observable<ProceduralTexture>;
  19295. /** @hidden */
  19296. _generateMipMaps: boolean;
  19297. /** @hidden **/
  19298. _effect: Effect;
  19299. /** @hidden */
  19300. _textures: {
  19301. [key: string]: Texture;
  19302. };
  19303. private _size;
  19304. private _currentRefreshId;
  19305. private _refreshRate;
  19306. private _vertexBuffers;
  19307. private _indexBuffer;
  19308. private _uniforms;
  19309. private _samplers;
  19310. private _fragment;
  19311. private _floats;
  19312. private _ints;
  19313. private _floatsArrays;
  19314. private _colors3;
  19315. private _colors4;
  19316. private _vectors2;
  19317. private _vectors3;
  19318. private _matrices;
  19319. private _fallbackTexture;
  19320. private _fallbackTextureUsed;
  19321. private _engine;
  19322. private _cachedDefines;
  19323. private _contentUpdateId;
  19324. private _contentData;
  19325. /**
  19326. * Instantiates a new procedural texture.
  19327. * 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.
  19328. * This is the base class of any Procedural texture and contains most of the shareable code.
  19329. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19330. * @param name Define the name of the texture
  19331. * @param size Define the size of the texture to create
  19332. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19333. * @param scene Define the scene the texture belongs to
  19334. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19335. * @param generateMipMaps Define if the texture should creates mip maps or not
  19336. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19337. */
  19338. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19339. /**
  19340. * The effect that is created when initializing the post process.
  19341. * @returns The created effect corresponding the the postprocess.
  19342. */
  19343. getEffect(): Effect;
  19344. /**
  19345. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19346. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19347. */
  19348. getContent(): Nullable<ArrayBufferView>;
  19349. private _createIndexBuffer;
  19350. /** @hidden */
  19351. _rebuild(): void;
  19352. /**
  19353. * Resets the texture in order to recreate its associated resources.
  19354. * This can be called in case of context loss
  19355. */
  19356. reset(): void;
  19357. protected _getDefines(): string;
  19358. /**
  19359. * Is the texture ready to be used ? (rendered at least once)
  19360. * @returns true if ready, otherwise, false.
  19361. */
  19362. isReady(): boolean;
  19363. /**
  19364. * Resets the refresh counter of the texture and start bak from scratch.
  19365. * Could be useful to regenerate the texture if it is setup to render only once.
  19366. */
  19367. resetRefreshCounter(): void;
  19368. /**
  19369. * Set the fragment shader to use in order to render the texture.
  19370. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19371. */
  19372. setFragment(fragment: any): void;
  19373. /**
  19374. * Define the refresh rate of the texture or the rendering frequency.
  19375. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19376. */
  19377. refreshRate: number;
  19378. /** @hidden */
  19379. _shouldRender(): boolean;
  19380. /**
  19381. * Get the size the texture is rendering at.
  19382. * @returns the size (texture is always squared)
  19383. */
  19384. getRenderSize(): number;
  19385. /**
  19386. * Resize the texture to new value.
  19387. * @param size Define the new size the texture should have
  19388. * @param generateMipMaps Define whether the new texture should create mip maps
  19389. */
  19390. resize(size: number, generateMipMaps: boolean): void;
  19391. private _checkUniform;
  19392. /**
  19393. * Set a texture in the shader program used to render.
  19394. * @param name Define the name of the uniform samplers as defined in the shader
  19395. * @param texture Define the texture to bind to this sampler
  19396. * @return the texture itself allowing "fluent" like uniform updates
  19397. */
  19398. setTexture(name: string, texture: Texture): ProceduralTexture;
  19399. /**
  19400. * Set a float in the shader.
  19401. * @param name Define the name of the uniform as defined in the shader
  19402. * @param value Define the value to give to the uniform
  19403. * @return the texture itself allowing "fluent" like uniform updates
  19404. */
  19405. setFloat(name: string, value: number): ProceduralTexture;
  19406. /**
  19407. * Set a int in the shader.
  19408. * @param name Define the name of the uniform as defined in the shader
  19409. * @param value Define the value to give to the uniform
  19410. * @return the texture itself allowing "fluent" like uniform updates
  19411. */
  19412. setInt(name: string, value: number): ProceduralTexture;
  19413. /**
  19414. * Set an array of floats in the shader.
  19415. * @param name Define the name of the uniform as defined in the shader
  19416. * @param value Define the value to give to the uniform
  19417. * @return the texture itself allowing "fluent" like uniform updates
  19418. */
  19419. setFloats(name: string, value: number[]): ProceduralTexture;
  19420. /**
  19421. * Set a vec3 in the shader from a Color3.
  19422. * @param name Define the name of the uniform as defined in the shader
  19423. * @param value Define the value to give to the uniform
  19424. * @return the texture itself allowing "fluent" like uniform updates
  19425. */
  19426. setColor3(name: string, value: Color3): ProceduralTexture;
  19427. /**
  19428. * Set a vec4 in the shader from a Color4.
  19429. * @param name Define the name of the uniform as defined in the shader
  19430. * @param value Define the value to give to the uniform
  19431. * @return the texture itself allowing "fluent" like uniform updates
  19432. */
  19433. setColor4(name: string, value: Color4): ProceduralTexture;
  19434. /**
  19435. * Set a vec2 in the shader from a Vector2.
  19436. * @param name Define the name of the uniform as defined in the shader
  19437. * @param value Define the value to give to the uniform
  19438. * @return the texture itself allowing "fluent" like uniform updates
  19439. */
  19440. setVector2(name: string, value: Vector2): ProceduralTexture;
  19441. /**
  19442. * Set a vec3 in the shader from a Vector3.
  19443. * @param name Define the name of the uniform as defined in the shader
  19444. * @param value Define the value to give to the uniform
  19445. * @return the texture itself allowing "fluent" like uniform updates
  19446. */
  19447. setVector3(name: string, value: Vector3): ProceduralTexture;
  19448. /**
  19449. * Set a mat4 in the shader from a MAtrix.
  19450. * @param name Define the name of the uniform as defined in the shader
  19451. * @param value Define the value to give to the uniform
  19452. * @return the texture itself allowing "fluent" like uniform updates
  19453. */
  19454. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19455. /**
  19456. * Render the texture to its associated render target.
  19457. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19458. */
  19459. render(useCameraPostProcess?: boolean): void;
  19460. /**
  19461. * Clone the texture.
  19462. * @returns the cloned texture
  19463. */
  19464. clone(): ProceduralTexture;
  19465. /**
  19466. * Dispose the texture and release its asoociated resources.
  19467. */
  19468. dispose(): void;
  19469. }
  19470. }
  19471. declare module "babylonjs/Particles/baseParticleSystem" {
  19472. import { Nullable } from "babylonjs/types";
  19473. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19475. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19476. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19477. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19478. import { Scene } from "babylonjs/scene";
  19479. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19480. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19481. import { Texture } from "babylonjs/Materials/Textures/texture";
  19482. import { Animation } from "babylonjs/Animations/animation";
  19483. /**
  19484. * This represents the base class for particle system in Babylon.
  19485. * 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.
  19486. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19487. * @example https://doc.babylonjs.com/babylon101/particles
  19488. */
  19489. export class BaseParticleSystem {
  19490. /**
  19491. * Source color is added to the destination color without alpha affecting the result
  19492. */
  19493. static BLENDMODE_ONEONE: number;
  19494. /**
  19495. * Blend current color and particle color using particle’s alpha
  19496. */
  19497. static BLENDMODE_STANDARD: number;
  19498. /**
  19499. * Add current color and particle color multiplied by particle’s alpha
  19500. */
  19501. static BLENDMODE_ADD: number;
  19502. /**
  19503. * Multiply current color with particle color
  19504. */
  19505. static BLENDMODE_MULTIPLY: number;
  19506. /**
  19507. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19508. */
  19509. static BLENDMODE_MULTIPLYADD: number;
  19510. /**
  19511. * List of animations used by the particle system.
  19512. */
  19513. animations: Animation[];
  19514. /**
  19515. * The id of the Particle system.
  19516. */
  19517. id: string;
  19518. /**
  19519. * The friendly name of the Particle system.
  19520. */
  19521. name: string;
  19522. /**
  19523. * The rendering group used by the Particle system to chose when to render.
  19524. */
  19525. renderingGroupId: number;
  19526. /**
  19527. * The emitter represents the Mesh or position we are attaching the particle system to.
  19528. */
  19529. emitter: Nullable<AbstractMesh | Vector3>;
  19530. /**
  19531. * The maximum number of particles to emit per frame
  19532. */
  19533. emitRate: number;
  19534. /**
  19535. * If you want to launch only a few particles at once, that can be done, as well.
  19536. */
  19537. manualEmitCount: number;
  19538. /**
  19539. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19540. */
  19541. updateSpeed: number;
  19542. /**
  19543. * The amount of time the particle system is running (depends of the overall update speed).
  19544. */
  19545. targetStopDuration: number;
  19546. /**
  19547. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19548. */
  19549. disposeOnStop: boolean;
  19550. /**
  19551. * Minimum power of emitting particles.
  19552. */
  19553. minEmitPower: number;
  19554. /**
  19555. * Maximum power of emitting particles.
  19556. */
  19557. maxEmitPower: number;
  19558. /**
  19559. * Minimum life time of emitting particles.
  19560. */
  19561. minLifeTime: number;
  19562. /**
  19563. * Maximum life time of emitting particles.
  19564. */
  19565. maxLifeTime: number;
  19566. /**
  19567. * Minimum Size of emitting particles.
  19568. */
  19569. minSize: number;
  19570. /**
  19571. * Maximum Size of emitting particles.
  19572. */
  19573. maxSize: number;
  19574. /**
  19575. * Minimum scale of emitting particles on X axis.
  19576. */
  19577. minScaleX: number;
  19578. /**
  19579. * Maximum scale of emitting particles on X axis.
  19580. */
  19581. maxScaleX: number;
  19582. /**
  19583. * Minimum scale of emitting particles on Y axis.
  19584. */
  19585. minScaleY: number;
  19586. /**
  19587. * Maximum scale of emitting particles on Y axis.
  19588. */
  19589. maxScaleY: number;
  19590. /**
  19591. * Gets or sets the minimal initial rotation in radians.
  19592. */
  19593. minInitialRotation: number;
  19594. /**
  19595. * Gets or sets the maximal initial rotation in radians.
  19596. */
  19597. maxInitialRotation: number;
  19598. /**
  19599. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19600. */
  19601. minAngularSpeed: number;
  19602. /**
  19603. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19604. */
  19605. maxAngularSpeed: number;
  19606. /**
  19607. * The texture used to render each particle. (this can be a spritesheet)
  19608. */
  19609. particleTexture: Nullable<Texture>;
  19610. /**
  19611. * The layer mask we are rendering the particles through.
  19612. */
  19613. layerMask: number;
  19614. /**
  19615. * This can help using your own shader to render the particle system.
  19616. * The according effect will be created
  19617. */
  19618. customShader: any;
  19619. /**
  19620. * By default particle system starts as soon as they are created. This prevents the
  19621. * automatic start to happen and let you decide when to start emitting particles.
  19622. */
  19623. preventAutoStart: boolean;
  19624. private _noiseTexture;
  19625. /**
  19626. * Gets or sets a texture used to add random noise to particle positions
  19627. */
  19628. noiseTexture: Nullable<ProceduralTexture>;
  19629. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19630. noiseStrength: Vector3;
  19631. /**
  19632. * Callback triggered when the particle animation is ending.
  19633. */
  19634. onAnimationEnd: Nullable<() => void>;
  19635. /**
  19636. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19637. */
  19638. blendMode: number;
  19639. /**
  19640. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19641. * to override the particles.
  19642. */
  19643. forceDepthWrite: boolean;
  19644. /** 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 */
  19645. preWarmCycles: number;
  19646. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19647. preWarmStepOffset: number;
  19648. /**
  19649. * 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)
  19650. */
  19651. spriteCellChangeSpeed: number;
  19652. /**
  19653. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19654. */
  19655. startSpriteCellID: number;
  19656. /**
  19657. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19658. */
  19659. endSpriteCellID: number;
  19660. /**
  19661. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19662. */
  19663. spriteCellWidth: number;
  19664. /**
  19665. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19666. */
  19667. spriteCellHeight: number;
  19668. /**
  19669. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19670. */
  19671. spriteRandomStartCell: boolean;
  19672. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19673. translationPivot: Vector2;
  19674. /** @hidden */
  19675. protected _isAnimationSheetEnabled: boolean;
  19676. /**
  19677. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19678. */
  19679. beginAnimationOnStart: boolean;
  19680. /**
  19681. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19682. */
  19683. beginAnimationFrom: number;
  19684. /**
  19685. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19686. */
  19687. beginAnimationTo: number;
  19688. /**
  19689. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19690. */
  19691. beginAnimationLoop: boolean;
  19692. /**
  19693. * Gets or sets a world offset applied to all particles
  19694. */
  19695. worldOffset: Vector3;
  19696. /**
  19697. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19698. */
  19699. isAnimationSheetEnabled: boolean;
  19700. /**
  19701. * Get hosting scene
  19702. * @returns the scene
  19703. */
  19704. getScene(): Scene;
  19705. /**
  19706. * You can use gravity if you want to give an orientation to your particles.
  19707. */
  19708. gravity: Vector3;
  19709. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19710. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19711. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19712. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19713. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19714. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19715. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19716. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19717. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19718. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19719. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19720. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19721. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19722. /**
  19723. * Defines the delay in milliseconds before starting the system (0 by default)
  19724. */
  19725. startDelay: number;
  19726. /**
  19727. * Gets the current list of drag gradients.
  19728. * You must use addDragGradient and removeDragGradient to udpate this list
  19729. * @returns the list of drag gradients
  19730. */
  19731. getDragGradients(): Nullable<Array<FactorGradient>>;
  19732. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19733. limitVelocityDamping: number;
  19734. /**
  19735. * Gets the current list of limit velocity gradients.
  19736. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19737. * @returns the list of limit velocity gradients
  19738. */
  19739. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19740. /**
  19741. * Gets the current list of color gradients.
  19742. * You must use addColorGradient and removeColorGradient to udpate this list
  19743. * @returns the list of color gradients
  19744. */
  19745. getColorGradients(): Nullable<Array<ColorGradient>>;
  19746. /**
  19747. * Gets the current list of size gradients.
  19748. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19749. * @returns the list of size gradients
  19750. */
  19751. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19752. /**
  19753. * Gets the current list of color remap gradients.
  19754. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19755. * @returns the list of color remap gradients
  19756. */
  19757. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19758. /**
  19759. * Gets the current list of alpha remap gradients.
  19760. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19761. * @returns the list of alpha remap gradients
  19762. */
  19763. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19764. /**
  19765. * Gets the current list of life time gradients.
  19766. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19767. * @returns the list of life time gradients
  19768. */
  19769. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19770. /**
  19771. * Gets the current list of angular speed gradients.
  19772. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19773. * @returns the list of angular speed gradients
  19774. */
  19775. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19776. /**
  19777. * Gets the current list of velocity gradients.
  19778. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19779. * @returns the list of velocity gradients
  19780. */
  19781. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19782. /**
  19783. * Gets the current list of start size gradients.
  19784. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19785. * @returns the list of start size gradients
  19786. */
  19787. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19788. /**
  19789. * Gets the current list of emit rate gradients.
  19790. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19791. * @returns the list of emit rate gradients
  19792. */
  19793. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19794. /**
  19795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19796. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19797. */
  19798. direction1: Vector3;
  19799. /**
  19800. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19801. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19802. */
  19803. direction2: Vector3;
  19804. /**
  19805. * 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.
  19806. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19807. */
  19808. minEmitBox: Vector3;
  19809. /**
  19810. * 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.
  19811. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19812. */
  19813. maxEmitBox: Vector3;
  19814. /**
  19815. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19816. */
  19817. color1: Color4;
  19818. /**
  19819. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19820. */
  19821. color2: Color4;
  19822. /**
  19823. * Color the particle will have at the end of its lifetime
  19824. */
  19825. colorDead: Color4;
  19826. /**
  19827. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19828. */
  19829. textureMask: Color4;
  19830. /**
  19831. * The particle emitter type defines the emitter used by the particle system.
  19832. * It can be for example box, sphere, or cone...
  19833. */
  19834. particleEmitterType: IParticleEmitterType;
  19835. /** @hidden */
  19836. _isSubEmitter: boolean;
  19837. /**
  19838. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19839. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19840. */
  19841. billboardMode: number;
  19842. protected _isBillboardBased: boolean;
  19843. /**
  19844. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19845. */
  19846. isBillboardBased: boolean;
  19847. /**
  19848. * The scene the particle system belongs to.
  19849. */
  19850. protected _scene: Scene;
  19851. /**
  19852. * Local cache of defines for image processing.
  19853. */
  19854. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19855. /**
  19856. * Default configuration related to image processing available in the standard Material.
  19857. */
  19858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19859. /**
  19860. * Gets the image processing configuration used either in this material.
  19861. */
  19862. /**
  19863. * Sets the Default image processing configuration used either in the this material.
  19864. *
  19865. * If sets to null, the scene one is in use.
  19866. */
  19867. imageProcessingConfiguration: ImageProcessingConfiguration;
  19868. /**
  19869. * Attaches a new image processing configuration to the Standard Material.
  19870. * @param configuration
  19871. */
  19872. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19873. /** @hidden */
  19874. protected _reset(): void;
  19875. /** @hidden */
  19876. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19877. /**
  19878. * Instantiates a particle system.
  19879. * 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.
  19880. * @param name The name of the particle system
  19881. */
  19882. constructor(name: string);
  19883. /**
  19884. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19885. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19886. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19887. * @returns the emitter
  19888. */
  19889. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19890. /**
  19891. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19892. * @param radius The radius of the hemisphere to emit from
  19893. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19894. * @returns the emitter
  19895. */
  19896. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19897. /**
  19898. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19899. * @param radius The radius of the sphere to emit from
  19900. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19901. * @returns the emitter
  19902. */
  19903. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19904. /**
  19905. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19906. * @param radius The radius of the sphere to emit from
  19907. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19908. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19909. * @returns the emitter
  19910. */
  19911. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19912. /**
  19913. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19914. * @param radius The radius of the emission cylinder
  19915. * @param height The height of the emission cylinder
  19916. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19917. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19918. * @returns the emitter
  19919. */
  19920. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19921. /**
  19922. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19923. * @param radius The radius of the cylinder to emit from
  19924. * @param height The height of the emission cylinder
  19925. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19926. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19927. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19928. * @returns the emitter
  19929. */
  19930. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19931. /**
  19932. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19933. * @param radius The radius of the cone to emit from
  19934. * @param angle The base angle of the cone
  19935. * @returns the emitter
  19936. */
  19937. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19938. /**
  19939. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19942. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19943. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19944. * @returns the emitter
  19945. */
  19946. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19947. }
  19948. }
  19949. declare module "babylonjs/Particles/subEmitter" {
  19950. import { Scene } from "babylonjs/scene";
  19951. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19952. /**
  19953. * Type of sub emitter
  19954. */
  19955. export enum SubEmitterType {
  19956. /**
  19957. * Attached to the particle over it's lifetime
  19958. */
  19959. ATTACHED = 0,
  19960. /**
  19961. * Created when the particle dies
  19962. */
  19963. END = 1
  19964. }
  19965. /**
  19966. * Sub emitter class used to emit particles from an existing particle
  19967. */
  19968. export class SubEmitter {
  19969. /**
  19970. * the particle system to be used by the sub emitter
  19971. */
  19972. particleSystem: ParticleSystem;
  19973. /**
  19974. * Type of the submitter (Default: END)
  19975. */
  19976. type: SubEmitterType;
  19977. /**
  19978. * 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)
  19979. * Note: This only is supported when using an emitter of type Mesh
  19980. */
  19981. inheritDirection: boolean;
  19982. /**
  19983. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19984. */
  19985. inheritedVelocityAmount: number;
  19986. /**
  19987. * Creates a sub emitter
  19988. * @param particleSystem the particle system to be used by the sub emitter
  19989. */
  19990. constructor(
  19991. /**
  19992. * the particle system to be used by the sub emitter
  19993. */
  19994. particleSystem: ParticleSystem);
  19995. /**
  19996. * Clones the sub emitter
  19997. * @returns the cloned sub emitter
  19998. */
  19999. clone(): SubEmitter;
  20000. /**
  20001. * Serialize current object to a JSON object
  20002. * @returns the serialized object
  20003. */
  20004. serialize(): any;
  20005. /** @hidden */
  20006. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20007. /**
  20008. * Creates a new SubEmitter from a serialized JSON version
  20009. * @param serializationObject defines the JSON object to read from
  20010. * @param scene defines the hosting scene
  20011. * @param rootUrl defines the rootUrl for data loading
  20012. * @returns a new SubEmitter
  20013. */
  20014. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20015. /** Release associated resources */
  20016. dispose(): void;
  20017. }
  20018. }
  20019. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20020. /** @hidden */
  20021. export var imageProcessingDeclaration: {
  20022. name: string;
  20023. shader: string;
  20024. };
  20025. }
  20026. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20027. /** @hidden */
  20028. export var imageProcessingFunctions: {
  20029. name: string;
  20030. shader: string;
  20031. };
  20032. }
  20033. declare module "babylonjs/Shaders/particles.fragment" {
  20034. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20035. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20036. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20037. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20038. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20039. /** @hidden */
  20040. export var particlesPixelShader: {
  20041. name: string;
  20042. shader: string;
  20043. };
  20044. }
  20045. declare module "babylonjs/Shaders/particles.vertex" {
  20046. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20047. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20048. /** @hidden */
  20049. export var particlesVertexShader: {
  20050. name: string;
  20051. shader: string;
  20052. };
  20053. }
  20054. declare module "babylonjs/Particles/particleSystem" {
  20055. import { Nullable } from "babylonjs/types";
  20056. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20057. import { Observable } from "babylonjs/Misc/observable";
  20058. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20059. import { Effect } from "babylonjs/Materials/effect";
  20060. import { Scene, IDisposable } from "babylonjs/scene";
  20061. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20062. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20063. import { Particle } from "babylonjs/Particles/particle";
  20064. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20065. import "babylonjs/Shaders/particles.fragment";
  20066. import "babylonjs/Shaders/particles.vertex";
  20067. /**
  20068. * This represents a particle system in Babylon.
  20069. * 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.
  20070. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20071. * @example https://doc.babylonjs.com/babylon101/particles
  20072. */
  20073. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20074. /**
  20075. * Billboard mode will only apply to Y axis
  20076. */
  20077. static readonly BILLBOARDMODE_Y: number;
  20078. /**
  20079. * Billboard mode will apply to all axes
  20080. */
  20081. static readonly BILLBOARDMODE_ALL: number;
  20082. /**
  20083. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20084. */
  20085. static readonly BILLBOARDMODE_STRETCHED: number;
  20086. /**
  20087. * This function can be defined to provide custom update for active particles.
  20088. * This function will be called instead of regular update (age, position, color, etc.).
  20089. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20090. */
  20091. updateFunction: (particles: Particle[]) => void;
  20092. private _emitterWorldMatrix;
  20093. /**
  20094. * This function can be defined to specify initial direction for every new particle.
  20095. * It by default use the emitterType defined function
  20096. */
  20097. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20098. /**
  20099. * This function can be defined to specify initial position for every new particle.
  20100. * It by default use the emitterType defined function
  20101. */
  20102. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20103. /**
  20104. * @hidden
  20105. */
  20106. _inheritedVelocityOffset: Vector3;
  20107. /**
  20108. * An event triggered when the system is disposed
  20109. */
  20110. onDisposeObservable: Observable<ParticleSystem>;
  20111. private _onDisposeObserver;
  20112. /**
  20113. * Sets a callback that will be triggered when the system is disposed
  20114. */
  20115. onDispose: () => void;
  20116. private _particles;
  20117. private _epsilon;
  20118. private _capacity;
  20119. private _stockParticles;
  20120. private _newPartsExcess;
  20121. private _vertexData;
  20122. private _vertexBuffer;
  20123. private _vertexBuffers;
  20124. private _spriteBuffer;
  20125. private _indexBuffer;
  20126. private _effect;
  20127. private _customEffect;
  20128. private _cachedDefines;
  20129. private _scaledColorStep;
  20130. private _colorDiff;
  20131. private _scaledDirection;
  20132. private _scaledGravity;
  20133. private _currentRenderId;
  20134. private _alive;
  20135. private _useInstancing;
  20136. private _started;
  20137. private _stopped;
  20138. private _actualFrame;
  20139. private _scaledUpdateSpeed;
  20140. private _vertexBufferSize;
  20141. /** @hidden */
  20142. _currentEmitRateGradient: Nullable<FactorGradient>;
  20143. /** @hidden */
  20144. _currentEmitRate1: number;
  20145. /** @hidden */
  20146. _currentEmitRate2: number;
  20147. /** @hidden */
  20148. _currentStartSizeGradient: Nullable<FactorGradient>;
  20149. /** @hidden */
  20150. _currentStartSize1: number;
  20151. /** @hidden */
  20152. _currentStartSize2: number;
  20153. private readonly _rawTextureWidth;
  20154. private _rampGradientsTexture;
  20155. private _useRampGradients;
  20156. /** Gets or sets a boolean indicating that ramp gradients must be used
  20157. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20158. */
  20159. useRampGradients: boolean;
  20160. /**
  20161. * 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.
  20162. * 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: [])
  20163. */
  20164. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20165. private _subEmitters;
  20166. /**
  20167. * @hidden
  20168. * If the particle systems emitter should be disposed when the particle system is disposed
  20169. */
  20170. _disposeEmitterOnDispose: boolean;
  20171. /**
  20172. * The current active Sub-systems, this property is used by the root particle system only.
  20173. */
  20174. activeSubSystems: Array<ParticleSystem>;
  20175. private _rootParticleSystem;
  20176. /**
  20177. * Gets the current list of active particles
  20178. */
  20179. readonly particles: Particle[];
  20180. /**
  20181. * Returns the string "ParticleSystem"
  20182. * @returns a string containing the class name
  20183. */
  20184. getClassName(): string;
  20185. /**
  20186. * Instantiates a particle system.
  20187. * 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.
  20188. * @param name The name of the particle system
  20189. * @param capacity The max number of particles alive at the same time
  20190. * @param scene The scene the particle system belongs to
  20191. * @param customEffect a custom effect used to change the way particles are rendered by default
  20192. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20193. * @param epsilon Offset used to render the particles
  20194. */
  20195. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20196. private _addFactorGradient;
  20197. private _removeFactorGradient;
  20198. /**
  20199. * Adds a new life time gradient
  20200. * @param gradient defines the gradient to use (between 0 and 1)
  20201. * @param factor defines the life time factor to affect to the specified gradient
  20202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20203. * @returns the current particle system
  20204. */
  20205. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20206. /**
  20207. * Remove a specific life time gradient
  20208. * @param gradient defines the gradient to remove
  20209. * @returns the current particle system
  20210. */
  20211. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20212. /**
  20213. * Adds a new size gradient
  20214. * @param gradient defines the gradient to use (between 0 and 1)
  20215. * @param factor defines the size factor to affect to the specified gradient
  20216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20217. * @returns the current particle system
  20218. */
  20219. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20220. /**
  20221. * Remove a specific size gradient
  20222. * @param gradient defines the gradient to remove
  20223. * @returns the current particle system
  20224. */
  20225. removeSizeGradient(gradient: number): IParticleSystem;
  20226. /**
  20227. * Adds a new color remap gradient
  20228. * @param gradient defines the gradient to use (between 0 and 1)
  20229. * @param min defines the color remap minimal range
  20230. * @param max defines the color remap maximal range
  20231. * @returns the current particle system
  20232. */
  20233. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20234. /**
  20235. * Remove a specific color remap gradient
  20236. * @param gradient defines the gradient to remove
  20237. * @returns the current particle system
  20238. */
  20239. removeColorRemapGradient(gradient: number): IParticleSystem;
  20240. /**
  20241. * Adds a new alpha remap gradient
  20242. * @param gradient defines the gradient to use (between 0 and 1)
  20243. * @param min defines the alpha remap minimal range
  20244. * @param max defines the alpha remap maximal range
  20245. * @returns the current particle system
  20246. */
  20247. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20248. /**
  20249. * Remove a specific alpha remap gradient
  20250. * @param gradient defines the gradient to remove
  20251. * @returns the current particle system
  20252. */
  20253. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20254. /**
  20255. * Adds a new angular speed gradient
  20256. * @param gradient defines the gradient to use (between 0 and 1)
  20257. * @param factor defines the angular speed to affect to the specified gradient
  20258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20259. * @returns the current particle system
  20260. */
  20261. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20262. /**
  20263. * Remove a specific angular speed gradient
  20264. * @param gradient defines the gradient to remove
  20265. * @returns the current particle system
  20266. */
  20267. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20268. /**
  20269. * Adds a new velocity gradient
  20270. * @param gradient defines the gradient to use (between 0 and 1)
  20271. * @param factor defines the velocity to affect to the specified gradient
  20272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20273. * @returns the current particle system
  20274. */
  20275. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20276. /**
  20277. * Remove a specific velocity gradient
  20278. * @param gradient defines the gradient to remove
  20279. * @returns the current particle system
  20280. */
  20281. removeVelocityGradient(gradient: number): IParticleSystem;
  20282. /**
  20283. * Adds a new limit velocity gradient
  20284. * @param gradient defines the gradient to use (between 0 and 1)
  20285. * @param factor defines the limit velocity value to affect to the specified gradient
  20286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20287. * @returns the current particle system
  20288. */
  20289. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20290. /**
  20291. * Remove a specific limit velocity gradient
  20292. * @param gradient defines the gradient to remove
  20293. * @returns the current particle system
  20294. */
  20295. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20296. /**
  20297. * Adds a new drag gradient
  20298. * @param gradient defines the gradient to use (between 0 and 1)
  20299. * @param factor defines the drag value to affect to the specified gradient
  20300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20301. * @returns the current particle system
  20302. */
  20303. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20304. /**
  20305. * Remove a specific drag gradient
  20306. * @param gradient defines the gradient to remove
  20307. * @returns the current particle system
  20308. */
  20309. removeDragGradient(gradient: number): IParticleSystem;
  20310. /**
  20311. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20312. * @param gradient defines the gradient to use (between 0 and 1)
  20313. * @param factor defines the emit rate value to affect to the specified gradient
  20314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20315. * @returns the current particle system
  20316. */
  20317. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20318. /**
  20319. * Remove a specific emit rate gradient
  20320. * @param gradient defines the gradient to remove
  20321. * @returns the current particle system
  20322. */
  20323. removeEmitRateGradient(gradient: number): IParticleSystem;
  20324. /**
  20325. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20326. * @param gradient defines the gradient to use (between 0 and 1)
  20327. * @param factor defines the start size value to affect to the specified gradient
  20328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20329. * @returns the current particle system
  20330. */
  20331. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20332. /**
  20333. * Remove a specific start size gradient
  20334. * @param gradient defines the gradient to remove
  20335. * @returns the current particle system
  20336. */
  20337. removeStartSizeGradient(gradient: number): IParticleSystem;
  20338. private _createRampGradientTexture;
  20339. /**
  20340. * Gets the current list of ramp gradients.
  20341. * You must use addRampGradient and removeRampGradient to udpate this list
  20342. * @returns the list of ramp gradients
  20343. */
  20344. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20345. /**
  20346. * Adds a new ramp gradient used to remap particle colors
  20347. * @param gradient defines the gradient to use (between 0 and 1)
  20348. * @param color defines the color to affect to the specified gradient
  20349. * @returns the current particle system
  20350. */
  20351. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20352. /**
  20353. * Remove a specific ramp gradient
  20354. * @param gradient defines the gradient to remove
  20355. * @returns the current particle system
  20356. */
  20357. removeRampGradient(gradient: number): ParticleSystem;
  20358. /**
  20359. * Adds a new color gradient
  20360. * @param gradient defines the gradient to use (between 0 and 1)
  20361. * @param color1 defines the color to affect to the specified gradient
  20362. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20363. * @returns this particle system
  20364. */
  20365. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20366. /**
  20367. * Remove a specific color gradient
  20368. * @param gradient defines the gradient to remove
  20369. * @returns this particle system
  20370. */
  20371. removeColorGradient(gradient: number): IParticleSystem;
  20372. private _fetchR;
  20373. protected _reset(): void;
  20374. private _resetEffect;
  20375. private _createVertexBuffers;
  20376. private _createIndexBuffer;
  20377. /**
  20378. * Gets the maximum number of particles active at the same time.
  20379. * @returns The max number of active particles.
  20380. */
  20381. getCapacity(): number;
  20382. /**
  20383. * Gets whether there are still active particles in the system.
  20384. * @returns True if it is alive, otherwise false.
  20385. */
  20386. isAlive(): boolean;
  20387. /**
  20388. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20389. * @returns True if it has been started, otherwise false.
  20390. */
  20391. isStarted(): boolean;
  20392. private _prepareSubEmitterInternalArray;
  20393. /**
  20394. * Starts the particle system and begins to emit
  20395. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20396. */
  20397. start(delay?: number): void;
  20398. /**
  20399. * Stops the particle system.
  20400. * @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.
  20401. */
  20402. stop(stopSubEmitters?: boolean): void;
  20403. /**
  20404. * Remove all active particles
  20405. */
  20406. reset(): void;
  20407. /**
  20408. * @hidden (for internal use only)
  20409. */
  20410. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20411. /**
  20412. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20413. * Its lifetime will start back at 0.
  20414. */
  20415. recycleParticle: (particle: Particle) => void;
  20416. private _stopSubEmitters;
  20417. private _createParticle;
  20418. private _removeFromRoot;
  20419. private _emitFromParticle;
  20420. private _update;
  20421. /** @hidden */
  20422. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20423. /** @hidden */
  20424. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20425. /** @hidden */
  20426. private _getEffect;
  20427. /**
  20428. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20429. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20430. */
  20431. animate(preWarmOnly?: boolean): void;
  20432. private _appendParticleVertices;
  20433. /**
  20434. * Rebuilds the particle system.
  20435. */
  20436. rebuild(): void;
  20437. /**
  20438. * Is this system ready to be used/rendered
  20439. * @return true if the system is ready
  20440. */
  20441. isReady(): boolean;
  20442. private _render;
  20443. /**
  20444. * Renders the particle system in its current state.
  20445. * @returns the current number of particles
  20446. */
  20447. render(): number;
  20448. /**
  20449. * Disposes the particle system and free the associated resources
  20450. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20451. */
  20452. dispose(disposeTexture?: boolean): void;
  20453. /**
  20454. * Clones the particle system.
  20455. * @param name The name of the cloned object
  20456. * @param newEmitter The new emitter to use
  20457. * @returns the cloned particle system
  20458. */
  20459. clone(name: string, newEmitter: any): ParticleSystem;
  20460. /**
  20461. * Serializes the particle system to a JSON object.
  20462. * @returns the JSON object
  20463. */
  20464. serialize(): any;
  20465. /** @hidden */
  20466. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20467. /** @hidden */
  20468. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20469. /**
  20470. * Parses a JSON object to create a particle system.
  20471. * @param parsedParticleSystem The JSON object to parse
  20472. * @param scene The scene to create the particle system in
  20473. * @param rootUrl The root url to use to load external dependencies like texture
  20474. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20475. * @returns the Parsed particle system
  20476. */
  20477. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20478. }
  20479. }
  20480. declare module "babylonjs/Particles/particle" {
  20481. import { Nullable } from "babylonjs/types";
  20482. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20483. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20484. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20485. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20486. /**
  20487. * A particle represents one of the element emitted by a particle system.
  20488. * This is mainly define by its coordinates, direction, velocity and age.
  20489. */
  20490. export class Particle {
  20491. /**
  20492. * The particle system the particle belongs to.
  20493. */
  20494. particleSystem: ParticleSystem;
  20495. private static _Count;
  20496. /**
  20497. * Unique ID of the particle
  20498. */
  20499. id: number;
  20500. /**
  20501. * The world position of the particle in the scene.
  20502. */
  20503. position: Vector3;
  20504. /**
  20505. * The world direction of the particle in the scene.
  20506. */
  20507. direction: Vector3;
  20508. /**
  20509. * The color of the particle.
  20510. */
  20511. color: Color4;
  20512. /**
  20513. * The color change of the particle per step.
  20514. */
  20515. colorStep: Color4;
  20516. /**
  20517. * Defines how long will the life of the particle be.
  20518. */
  20519. lifeTime: number;
  20520. /**
  20521. * The current age of the particle.
  20522. */
  20523. age: number;
  20524. /**
  20525. * The current size of the particle.
  20526. */
  20527. size: number;
  20528. /**
  20529. * The current scale of the particle.
  20530. */
  20531. scale: Vector2;
  20532. /**
  20533. * The current angle of the particle.
  20534. */
  20535. angle: number;
  20536. /**
  20537. * Defines how fast is the angle changing.
  20538. */
  20539. angularSpeed: number;
  20540. /**
  20541. * Defines the cell index used by the particle to be rendered from a sprite.
  20542. */
  20543. cellIndex: number;
  20544. /**
  20545. * The information required to support color remapping
  20546. */
  20547. remapData: Vector4;
  20548. /** @hidden */
  20549. _randomCellOffset?: number;
  20550. /** @hidden */
  20551. _initialDirection: Nullable<Vector3>;
  20552. /** @hidden */
  20553. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20554. /** @hidden */
  20555. _initialStartSpriteCellID: number;
  20556. /** @hidden */
  20557. _initialEndSpriteCellID: number;
  20558. /** @hidden */
  20559. _currentColorGradient: Nullable<ColorGradient>;
  20560. /** @hidden */
  20561. _currentColor1: Color4;
  20562. /** @hidden */
  20563. _currentColor2: Color4;
  20564. /** @hidden */
  20565. _currentSizeGradient: Nullable<FactorGradient>;
  20566. /** @hidden */
  20567. _currentSize1: number;
  20568. /** @hidden */
  20569. _currentSize2: number;
  20570. /** @hidden */
  20571. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20572. /** @hidden */
  20573. _currentAngularSpeed1: number;
  20574. /** @hidden */
  20575. _currentAngularSpeed2: number;
  20576. /** @hidden */
  20577. _currentVelocityGradient: Nullable<FactorGradient>;
  20578. /** @hidden */
  20579. _currentVelocity1: number;
  20580. /** @hidden */
  20581. _currentVelocity2: number;
  20582. /** @hidden */
  20583. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20584. /** @hidden */
  20585. _currentLimitVelocity1: number;
  20586. /** @hidden */
  20587. _currentLimitVelocity2: number;
  20588. /** @hidden */
  20589. _currentDragGradient: Nullable<FactorGradient>;
  20590. /** @hidden */
  20591. _currentDrag1: number;
  20592. /** @hidden */
  20593. _currentDrag2: number;
  20594. /** @hidden */
  20595. _randomNoiseCoordinates1: Vector3;
  20596. /** @hidden */
  20597. _randomNoiseCoordinates2: Vector3;
  20598. /**
  20599. * Creates a new instance Particle
  20600. * @param particleSystem the particle system the particle belongs to
  20601. */
  20602. constructor(
  20603. /**
  20604. * The particle system the particle belongs to.
  20605. */
  20606. particleSystem: ParticleSystem);
  20607. private updateCellInfoFromSystem;
  20608. /**
  20609. * Defines how the sprite cell index is updated for the particle
  20610. */
  20611. updateCellIndex(): void;
  20612. /** @hidden */
  20613. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20614. /** @hidden */
  20615. _inheritParticleInfoToSubEmitters(): void;
  20616. /** @hidden */
  20617. _reset(): void;
  20618. /**
  20619. * Copy the properties of particle to another one.
  20620. * @param other the particle to copy the information to.
  20621. */
  20622. copyTo(other: Particle): void;
  20623. }
  20624. }
  20625. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20626. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20627. import { Effect } from "babylonjs/Materials/effect";
  20628. import { Particle } from "babylonjs/Particles/particle";
  20629. /**
  20630. * Particle emitter represents a volume emitting particles.
  20631. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20632. */
  20633. export interface IParticleEmitterType {
  20634. /**
  20635. * Called by the particle System when the direction is computed for the created particle.
  20636. * @param worldMatrix is the world matrix of the particle system
  20637. * @param directionToUpdate is the direction vector to update with the result
  20638. * @param particle is the particle we are computed the direction for
  20639. */
  20640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20641. /**
  20642. * Called by the particle System when the position is computed for the created particle.
  20643. * @param worldMatrix is the world matrix of the particle system
  20644. * @param positionToUpdate is the position vector to update with the result
  20645. * @param particle is the particle we are computed the position for
  20646. */
  20647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20648. /**
  20649. * Clones the current emitter and returns a copy of it
  20650. * @returns the new emitter
  20651. */
  20652. clone(): IParticleEmitterType;
  20653. /**
  20654. * Called by the GPUParticleSystem to setup the update shader
  20655. * @param effect defines the update shader
  20656. */
  20657. applyToShader(effect: Effect): void;
  20658. /**
  20659. * Returns a string to use to update the GPU particles update shader
  20660. * @returns the effect defines string
  20661. */
  20662. getEffectDefines(): string;
  20663. /**
  20664. * Returns a string representing the class name
  20665. * @returns a string containing the class name
  20666. */
  20667. getClassName(): string;
  20668. /**
  20669. * Serializes the particle system to a JSON object.
  20670. * @returns the JSON object
  20671. */
  20672. serialize(): any;
  20673. /**
  20674. * Parse properties from a JSON object
  20675. * @param serializationObject defines the JSON object
  20676. */
  20677. parse(serializationObject: any): void;
  20678. }
  20679. }
  20680. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20681. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20682. import { Effect } from "babylonjs/Materials/effect";
  20683. import { Particle } from "babylonjs/Particles/particle";
  20684. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20685. /**
  20686. * Particle emitter emitting particles from the inside of a box.
  20687. * It emits the particles randomly between 2 given directions.
  20688. */
  20689. export class BoxParticleEmitter implements IParticleEmitterType {
  20690. /**
  20691. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20692. */
  20693. direction1: Vector3;
  20694. /**
  20695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20696. */
  20697. direction2: Vector3;
  20698. /**
  20699. * 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.
  20700. */
  20701. minEmitBox: Vector3;
  20702. /**
  20703. * 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.
  20704. */
  20705. maxEmitBox: Vector3;
  20706. /**
  20707. * Creates a new instance BoxParticleEmitter
  20708. */
  20709. constructor();
  20710. /**
  20711. * Called by the particle System when the direction is computed for the created particle.
  20712. * @param worldMatrix is the world matrix of the particle system
  20713. * @param directionToUpdate is the direction vector to update with the result
  20714. * @param particle is the particle we are computed the direction for
  20715. */
  20716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20717. /**
  20718. * Called by the particle System when the position is computed for the created particle.
  20719. * @param worldMatrix is the world matrix of the particle system
  20720. * @param positionToUpdate is the position vector to update with the result
  20721. * @param particle is the particle we are computed the position for
  20722. */
  20723. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20724. /**
  20725. * Clones the current emitter and returns a copy of it
  20726. * @returns the new emitter
  20727. */
  20728. clone(): BoxParticleEmitter;
  20729. /**
  20730. * Called by the GPUParticleSystem to setup the update shader
  20731. * @param effect defines the update shader
  20732. */
  20733. applyToShader(effect: Effect): void;
  20734. /**
  20735. * Returns a string to use to update the GPU particles update shader
  20736. * @returns a string containng the defines string
  20737. */
  20738. getEffectDefines(): string;
  20739. /**
  20740. * Returns the string "BoxParticleEmitter"
  20741. * @returns a string containing the class name
  20742. */
  20743. getClassName(): string;
  20744. /**
  20745. * Serializes the particle system to a JSON object.
  20746. * @returns the JSON object
  20747. */
  20748. serialize(): any;
  20749. /**
  20750. * Parse properties from a JSON object
  20751. * @param serializationObject defines the JSON object
  20752. */
  20753. parse(serializationObject: any): void;
  20754. }
  20755. }
  20756. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20757. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20758. import { Effect } from "babylonjs/Materials/effect";
  20759. import { Particle } from "babylonjs/Particles/particle";
  20760. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20761. /**
  20762. * Particle emitter emitting particles from the inside of a cone.
  20763. * It emits the particles alongside the cone volume from the base to the particle.
  20764. * The emission direction might be randomized.
  20765. */
  20766. export class ConeParticleEmitter implements IParticleEmitterType {
  20767. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20768. directionRandomizer: number;
  20769. private _radius;
  20770. private _angle;
  20771. private _height;
  20772. /**
  20773. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20774. */
  20775. radiusRange: number;
  20776. /**
  20777. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20778. */
  20779. heightRange: number;
  20780. /**
  20781. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20782. */
  20783. emitFromSpawnPointOnly: boolean;
  20784. /**
  20785. * Gets or sets the radius of the emission cone
  20786. */
  20787. radius: number;
  20788. /**
  20789. * Gets or sets the angle of the emission cone
  20790. */
  20791. angle: number;
  20792. private _buildHeight;
  20793. /**
  20794. * Creates a new instance ConeParticleEmitter
  20795. * @param radius the radius of the emission cone (1 by default)
  20796. * @param angle the cone base angle (PI by default)
  20797. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20798. */
  20799. constructor(radius?: number, angle?: number,
  20800. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20801. directionRandomizer?: number);
  20802. /**
  20803. * Called by the particle System when the direction is computed for the created particle.
  20804. * @param worldMatrix is the world matrix of the particle system
  20805. * @param directionToUpdate is the direction vector to update with the result
  20806. * @param particle is the particle we are computed the direction for
  20807. */
  20808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20809. /**
  20810. * Called by the particle System when the position is computed for the created particle.
  20811. * @param worldMatrix is the world matrix of the particle system
  20812. * @param positionToUpdate is the position vector to update with the result
  20813. * @param particle is the particle we are computed the position for
  20814. */
  20815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20816. /**
  20817. * Clones the current emitter and returns a copy of it
  20818. * @returns the new emitter
  20819. */
  20820. clone(): ConeParticleEmitter;
  20821. /**
  20822. * Called by the GPUParticleSystem to setup the update shader
  20823. * @param effect defines the update shader
  20824. */
  20825. applyToShader(effect: Effect): void;
  20826. /**
  20827. * Returns a string to use to update the GPU particles update shader
  20828. * @returns a string containng the defines string
  20829. */
  20830. getEffectDefines(): string;
  20831. /**
  20832. * Returns the string "ConeParticleEmitter"
  20833. * @returns a string containing the class name
  20834. */
  20835. getClassName(): string;
  20836. /**
  20837. * Serializes the particle system to a JSON object.
  20838. * @returns the JSON object
  20839. */
  20840. serialize(): any;
  20841. /**
  20842. * Parse properties from a JSON object
  20843. * @param serializationObject defines the JSON object
  20844. */
  20845. parse(serializationObject: any): void;
  20846. }
  20847. }
  20848. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20849. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20850. import { Effect } from "babylonjs/Materials/effect";
  20851. import { Particle } from "babylonjs/Particles/particle";
  20852. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20853. /**
  20854. * Particle emitter emitting particles from the inside of a cylinder.
  20855. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20856. */
  20857. export class CylinderParticleEmitter implements IParticleEmitterType {
  20858. /**
  20859. * The radius of the emission cylinder.
  20860. */
  20861. radius: number;
  20862. /**
  20863. * The height of the emission cylinder.
  20864. */
  20865. height: number;
  20866. /**
  20867. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20868. */
  20869. radiusRange: number;
  20870. /**
  20871. * How much to randomize the particle direction [0-1].
  20872. */
  20873. directionRandomizer: number;
  20874. /**
  20875. * Creates a new instance CylinderParticleEmitter
  20876. * @param radius the radius of the emission cylinder (1 by default)
  20877. * @param height the height of the emission cylinder (1 by default)
  20878. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20879. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20880. */
  20881. constructor(
  20882. /**
  20883. * The radius of the emission cylinder.
  20884. */
  20885. radius?: number,
  20886. /**
  20887. * The height of the emission cylinder.
  20888. */
  20889. height?: number,
  20890. /**
  20891. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20892. */
  20893. radiusRange?: number,
  20894. /**
  20895. * How much to randomize the particle direction [0-1].
  20896. */
  20897. directionRandomizer?: number);
  20898. /**
  20899. * Called by the particle System when the direction is computed for the created particle.
  20900. * @param worldMatrix is the world matrix of the particle system
  20901. * @param directionToUpdate is the direction vector to update with the result
  20902. * @param particle is the particle we are computed the direction for
  20903. */
  20904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20905. /**
  20906. * Called by the particle System when the position is computed for the created particle.
  20907. * @param worldMatrix is the world matrix of the particle system
  20908. * @param positionToUpdate is the position vector to update with the result
  20909. * @param particle is the particle we are computed the position for
  20910. */
  20911. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20912. /**
  20913. * Clones the current emitter and returns a copy of it
  20914. * @returns the new emitter
  20915. */
  20916. clone(): CylinderParticleEmitter;
  20917. /**
  20918. * Called by the GPUParticleSystem to setup the update shader
  20919. * @param effect defines the update shader
  20920. */
  20921. applyToShader(effect: Effect): void;
  20922. /**
  20923. * Returns a string to use to update the GPU particles update shader
  20924. * @returns a string containng the defines string
  20925. */
  20926. getEffectDefines(): string;
  20927. /**
  20928. * Returns the string "CylinderParticleEmitter"
  20929. * @returns a string containing the class name
  20930. */
  20931. getClassName(): string;
  20932. /**
  20933. * Serializes the particle system to a JSON object.
  20934. * @returns the JSON object
  20935. */
  20936. serialize(): any;
  20937. /**
  20938. * Parse properties from a JSON object
  20939. * @param serializationObject defines the JSON object
  20940. */
  20941. parse(serializationObject: any): void;
  20942. }
  20943. /**
  20944. * Particle emitter emitting particles from the inside of a cylinder.
  20945. * It emits the particles randomly between two vectors.
  20946. */
  20947. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20948. /**
  20949. * The min limit of the emission direction.
  20950. */
  20951. direction1: Vector3;
  20952. /**
  20953. * The max limit of the emission direction.
  20954. */
  20955. direction2: Vector3;
  20956. /**
  20957. * Creates a new instance CylinderDirectedParticleEmitter
  20958. * @param radius the radius of the emission cylinder (1 by default)
  20959. * @param height the height of the emission cylinder (1 by default)
  20960. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20961. * @param direction1 the min limit of the emission direction (up vector by default)
  20962. * @param direction2 the max limit of the emission direction (up vector by default)
  20963. */
  20964. constructor(radius?: number, height?: number, radiusRange?: number,
  20965. /**
  20966. * The min limit of the emission direction.
  20967. */
  20968. direction1?: Vector3,
  20969. /**
  20970. * The max limit of the emission direction.
  20971. */
  20972. direction2?: Vector3);
  20973. /**
  20974. * Called by the particle System when the direction is computed for the created particle.
  20975. * @param worldMatrix is the world matrix of the particle system
  20976. * @param directionToUpdate is the direction vector to update with the result
  20977. * @param particle is the particle we are computed the direction for
  20978. */
  20979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20980. /**
  20981. * Clones the current emitter and returns a copy of it
  20982. * @returns the new emitter
  20983. */
  20984. clone(): CylinderDirectedParticleEmitter;
  20985. /**
  20986. * Called by the GPUParticleSystem to setup the update shader
  20987. * @param effect defines the update shader
  20988. */
  20989. applyToShader(effect: Effect): void;
  20990. /**
  20991. * Returns a string to use to update the GPU particles update shader
  20992. * @returns a string containng the defines string
  20993. */
  20994. getEffectDefines(): string;
  20995. /**
  20996. * Returns the string "CylinderDirectedParticleEmitter"
  20997. * @returns a string containing the class name
  20998. */
  20999. getClassName(): string;
  21000. /**
  21001. * Serializes the particle system to a JSON object.
  21002. * @returns the JSON object
  21003. */
  21004. serialize(): any;
  21005. /**
  21006. * Parse properties from a JSON object
  21007. * @param serializationObject defines the JSON object
  21008. */
  21009. parse(serializationObject: any): void;
  21010. }
  21011. }
  21012. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21013. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21014. import { Effect } from "babylonjs/Materials/effect";
  21015. import { Particle } from "babylonjs/Particles/particle";
  21016. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21017. /**
  21018. * Particle emitter emitting particles from the inside of a hemisphere.
  21019. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21020. */
  21021. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21022. /**
  21023. * The radius of the emission hemisphere.
  21024. */
  21025. radius: number;
  21026. /**
  21027. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21028. */
  21029. radiusRange: number;
  21030. /**
  21031. * How much to randomize the particle direction [0-1].
  21032. */
  21033. directionRandomizer: number;
  21034. /**
  21035. * Creates a new instance HemisphericParticleEmitter
  21036. * @param radius the radius of the emission hemisphere (1 by default)
  21037. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21038. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21039. */
  21040. constructor(
  21041. /**
  21042. * The radius of the emission hemisphere.
  21043. */
  21044. radius?: number,
  21045. /**
  21046. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21047. */
  21048. radiusRange?: number,
  21049. /**
  21050. * How much to randomize the particle direction [0-1].
  21051. */
  21052. directionRandomizer?: number);
  21053. /**
  21054. * Called by the particle System when the direction is computed for the created particle.
  21055. * @param worldMatrix is the world matrix of the particle system
  21056. * @param directionToUpdate is the direction vector to update with the result
  21057. * @param particle is the particle we are computed the direction for
  21058. */
  21059. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21060. /**
  21061. * Called by the particle System when the position is computed for the created particle.
  21062. * @param worldMatrix is the world matrix of the particle system
  21063. * @param positionToUpdate is the position vector to update with the result
  21064. * @param particle is the particle we are computed the position for
  21065. */
  21066. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21067. /**
  21068. * Clones the current emitter and returns a copy of it
  21069. * @returns the new emitter
  21070. */
  21071. clone(): HemisphericParticleEmitter;
  21072. /**
  21073. * Called by the GPUParticleSystem to setup the update shader
  21074. * @param effect defines the update shader
  21075. */
  21076. applyToShader(effect: Effect): void;
  21077. /**
  21078. * Returns a string to use to update the GPU particles update shader
  21079. * @returns a string containng the defines string
  21080. */
  21081. getEffectDefines(): string;
  21082. /**
  21083. * Returns the string "HemisphericParticleEmitter"
  21084. * @returns a string containing the class name
  21085. */
  21086. getClassName(): string;
  21087. /**
  21088. * Serializes the particle system to a JSON object.
  21089. * @returns the JSON object
  21090. */
  21091. serialize(): any;
  21092. /**
  21093. * Parse properties from a JSON object
  21094. * @param serializationObject defines the JSON object
  21095. */
  21096. parse(serializationObject: any): void;
  21097. }
  21098. }
  21099. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21100. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21101. import { Effect } from "babylonjs/Materials/effect";
  21102. import { Particle } from "babylonjs/Particles/particle";
  21103. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21104. /**
  21105. * Particle emitter emitting particles from a point.
  21106. * It emits the particles randomly between 2 given directions.
  21107. */
  21108. export class PointParticleEmitter implements IParticleEmitterType {
  21109. /**
  21110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21111. */
  21112. direction1: Vector3;
  21113. /**
  21114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21115. */
  21116. direction2: Vector3;
  21117. /**
  21118. * Creates a new instance PointParticleEmitter
  21119. */
  21120. constructor();
  21121. /**
  21122. * Called by the particle System when the direction is computed for the created particle.
  21123. * @param worldMatrix is the world matrix of the particle system
  21124. * @param directionToUpdate is the direction vector to update with the result
  21125. * @param particle is the particle we are computed the direction for
  21126. */
  21127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21128. /**
  21129. * Called by the particle System when the position is computed for the created particle.
  21130. * @param worldMatrix is the world matrix of the particle system
  21131. * @param positionToUpdate is the position vector to update with the result
  21132. * @param particle is the particle we are computed the position for
  21133. */
  21134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21135. /**
  21136. * Clones the current emitter and returns a copy of it
  21137. * @returns the new emitter
  21138. */
  21139. clone(): PointParticleEmitter;
  21140. /**
  21141. * Called by the GPUParticleSystem to setup the update shader
  21142. * @param effect defines the update shader
  21143. */
  21144. applyToShader(effect: Effect): void;
  21145. /**
  21146. * Returns a string to use to update the GPU particles update shader
  21147. * @returns a string containng the defines string
  21148. */
  21149. getEffectDefines(): string;
  21150. /**
  21151. * Returns the string "PointParticleEmitter"
  21152. * @returns a string containing the class name
  21153. */
  21154. getClassName(): string;
  21155. /**
  21156. * Serializes the particle system to a JSON object.
  21157. * @returns the JSON object
  21158. */
  21159. serialize(): any;
  21160. /**
  21161. * Parse properties from a JSON object
  21162. * @param serializationObject defines the JSON object
  21163. */
  21164. parse(serializationObject: any): void;
  21165. }
  21166. }
  21167. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21168. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21169. import { Effect } from "babylonjs/Materials/effect";
  21170. import { Particle } from "babylonjs/Particles/particle";
  21171. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21172. /**
  21173. * Particle emitter emitting particles from the inside of a sphere.
  21174. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21175. */
  21176. export class SphereParticleEmitter implements IParticleEmitterType {
  21177. /**
  21178. * The radius of the emission sphere.
  21179. */
  21180. radius: number;
  21181. /**
  21182. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21183. */
  21184. radiusRange: number;
  21185. /**
  21186. * How much to randomize the particle direction [0-1].
  21187. */
  21188. directionRandomizer: number;
  21189. /**
  21190. * Creates a new instance SphereParticleEmitter
  21191. * @param radius the radius of the emission sphere (1 by default)
  21192. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21193. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21194. */
  21195. constructor(
  21196. /**
  21197. * The radius of the emission sphere.
  21198. */
  21199. radius?: number,
  21200. /**
  21201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21202. */
  21203. radiusRange?: number,
  21204. /**
  21205. * How much to randomize the particle direction [0-1].
  21206. */
  21207. directionRandomizer?: number);
  21208. /**
  21209. * Called by the particle System when the direction is computed for the created particle.
  21210. * @param worldMatrix is the world matrix of the particle system
  21211. * @param directionToUpdate is the direction vector to update with the result
  21212. * @param particle is the particle we are computed the direction for
  21213. */
  21214. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21215. /**
  21216. * Called by the particle System when the position is computed for the created particle.
  21217. * @param worldMatrix is the world matrix of the particle system
  21218. * @param positionToUpdate is the position vector to update with the result
  21219. * @param particle is the particle we are computed the position for
  21220. */
  21221. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21222. /**
  21223. * Clones the current emitter and returns a copy of it
  21224. * @returns the new emitter
  21225. */
  21226. clone(): SphereParticleEmitter;
  21227. /**
  21228. * Called by the GPUParticleSystem to setup the update shader
  21229. * @param effect defines the update shader
  21230. */
  21231. applyToShader(effect: Effect): void;
  21232. /**
  21233. * Returns a string to use to update the GPU particles update shader
  21234. * @returns a string containng the defines string
  21235. */
  21236. getEffectDefines(): string;
  21237. /**
  21238. * Returns the string "SphereParticleEmitter"
  21239. * @returns a string containing the class name
  21240. */
  21241. getClassName(): string;
  21242. /**
  21243. * Serializes the particle system to a JSON object.
  21244. * @returns the JSON object
  21245. */
  21246. serialize(): any;
  21247. /**
  21248. * Parse properties from a JSON object
  21249. * @param serializationObject defines the JSON object
  21250. */
  21251. parse(serializationObject: any): void;
  21252. }
  21253. /**
  21254. * Particle emitter emitting particles from the inside of a sphere.
  21255. * It emits the particles randomly between two vectors.
  21256. */
  21257. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21258. /**
  21259. * The min limit of the emission direction.
  21260. */
  21261. direction1: Vector3;
  21262. /**
  21263. * The max limit of the emission direction.
  21264. */
  21265. direction2: Vector3;
  21266. /**
  21267. * Creates a new instance SphereDirectedParticleEmitter
  21268. * @param radius the radius of the emission sphere (1 by default)
  21269. * @param direction1 the min limit of the emission direction (up vector by default)
  21270. * @param direction2 the max limit of the emission direction (up vector by default)
  21271. */
  21272. constructor(radius?: number,
  21273. /**
  21274. * The min limit of the emission direction.
  21275. */
  21276. direction1?: Vector3,
  21277. /**
  21278. * The max limit of the emission direction.
  21279. */
  21280. direction2?: Vector3);
  21281. /**
  21282. * Called by the particle System when the direction is computed for the created particle.
  21283. * @param worldMatrix is the world matrix of the particle system
  21284. * @param directionToUpdate is the direction vector to update with the result
  21285. * @param particle is the particle we are computed the direction for
  21286. */
  21287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21288. /**
  21289. * Clones the current emitter and returns a copy of it
  21290. * @returns the new emitter
  21291. */
  21292. clone(): SphereDirectedParticleEmitter;
  21293. /**
  21294. * Called by the GPUParticleSystem to setup the update shader
  21295. * @param effect defines the update shader
  21296. */
  21297. applyToShader(effect: Effect): void;
  21298. /**
  21299. * Returns a string to use to update the GPU particles update shader
  21300. * @returns a string containng the defines string
  21301. */
  21302. getEffectDefines(): string;
  21303. /**
  21304. * Returns the string "SphereDirectedParticleEmitter"
  21305. * @returns a string containing the class name
  21306. */
  21307. getClassName(): string;
  21308. /**
  21309. * Serializes the particle system to a JSON object.
  21310. * @returns the JSON object
  21311. */
  21312. serialize(): any;
  21313. /**
  21314. * Parse properties from a JSON object
  21315. * @param serializationObject defines the JSON object
  21316. */
  21317. parse(serializationObject: any): void;
  21318. }
  21319. }
  21320. declare module "babylonjs/Particles/EmitterTypes/index" {
  21321. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21322. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21323. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21324. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21325. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21326. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21327. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21328. }
  21329. declare module "babylonjs/Particles/IParticleSystem" {
  21330. import { Nullable } from "babylonjs/types";
  21331. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21334. import { Texture } from "babylonjs/Materials/Textures/texture";
  21335. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21336. import { Scene } from "babylonjs/scene";
  21337. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21338. import { Animation } from "babylonjs/Animations/animation";
  21339. /**
  21340. * Interface representing a particle system in Babylon.js.
  21341. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21342. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21343. */
  21344. export interface IParticleSystem {
  21345. /**
  21346. * List of animations used by the particle system.
  21347. */
  21348. animations: Animation[];
  21349. /**
  21350. * The id of the Particle system.
  21351. */
  21352. id: string;
  21353. /**
  21354. * The name of the Particle system.
  21355. */
  21356. name: string;
  21357. /**
  21358. * The emitter represents the Mesh or position we are attaching the particle system to.
  21359. */
  21360. emitter: Nullable<AbstractMesh | Vector3>;
  21361. /**
  21362. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21363. */
  21364. isBillboardBased: boolean;
  21365. /**
  21366. * The rendering group used by the Particle system to chose when to render.
  21367. */
  21368. renderingGroupId: number;
  21369. /**
  21370. * The layer mask we are rendering the particles through.
  21371. */
  21372. layerMask: number;
  21373. /**
  21374. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21375. */
  21376. updateSpeed: number;
  21377. /**
  21378. * The amount of time the particle system is running (depends of the overall update speed).
  21379. */
  21380. targetStopDuration: number;
  21381. /**
  21382. * The texture used to render each particle. (this can be a spritesheet)
  21383. */
  21384. particleTexture: Nullable<Texture>;
  21385. /**
  21386. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21387. */
  21388. blendMode: number;
  21389. /**
  21390. * Minimum life time of emitting particles.
  21391. */
  21392. minLifeTime: number;
  21393. /**
  21394. * Maximum life time of emitting particles.
  21395. */
  21396. maxLifeTime: number;
  21397. /**
  21398. * Minimum Size of emitting particles.
  21399. */
  21400. minSize: number;
  21401. /**
  21402. * Maximum Size of emitting particles.
  21403. */
  21404. maxSize: number;
  21405. /**
  21406. * Minimum scale of emitting particles on X axis.
  21407. */
  21408. minScaleX: number;
  21409. /**
  21410. * Maximum scale of emitting particles on X axis.
  21411. */
  21412. maxScaleX: number;
  21413. /**
  21414. * Minimum scale of emitting particles on Y axis.
  21415. */
  21416. minScaleY: number;
  21417. /**
  21418. * Maximum scale of emitting particles on Y axis.
  21419. */
  21420. maxScaleY: number;
  21421. /**
  21422. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21423. */
  21424. color1: Color4;
  21425. /**
  21426. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21427. */
  21428. color2: Color4;
  21429. /**
  21430. * Color the particle will have at the end of its lifetime.
  21431. */
  21432. colorDead: Color4;
  21433. /**
  21434. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21435. */
  21436. emitRate: number;
  21437. /**
  21438. * You can use gravity if you want to give an orientation to your particles.
  21439. */
  21440. gravity: Vector3;
  21441. /**
  21442. * Minimum power of emitting particles.
  21443. */
  21444. minEmitPower: number;
  21445. /**
  21446. * Maximum power of emitting particles.
  21447. */
  21448. maxEmitPower: number;
  21449. /**
  21450. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21451. */
  21452. minAngularSpeed: number;
  21453. /**
  21454. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21455. */
  21456. maxAngularSpeed: number;
  21457. /**
  21458. * Gets or sets the minimal initial rotation in radians.
  21459. */
  21460. minInitialRotation: number;
  21461. /**
  21462. * Gets or sets the maximal initial rotation in radians.
  21463. */
  21464. maxInitialRotation: number;
  21465. /**
  21466. * The particle emitter type defines the emitter used by the particle system.
  21467. * It can be for example box, sphere, or cone...
  21468. */
  21469. particleEmitterType: Nullable<IParticleEmitterType>;
  21470. /**
  21471. * Defines the delay in milliseconds before starting the system (0 by default)
  21472. */
  21473. startDelay: number;
  21474. /**
  21475. * 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
  21476. */
  21477. preWarmCycles: number;
  21478. /**
  21479. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21480. */
  21481. preWarmStepOffset: number;
  21482. /**
  21483. * 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)
  21484. */
  21485. spriteCellChangeSpeed: number;
  21486. /**
  21487. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21488. */
  21489. startSpriteCellID: number;
  21490. /**
  21491. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21492. */
  21493. endSpriteCellID: number;
  21494. /**
  21495. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21496. */
  21497. spriteCellWidth: number;
  21498. /**
  21499. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21500. */
  21501. spriteCellHeight: number;
  21502. /**
  21503. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21504. */
  21505. spriteRandomStartCell: boolean;
  21506. /**
  21507. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21508. */
  21509. isAnimationSheetEnabled: boolean;
  21510. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21511. translationPivot: Vector2;
  21512. /**
  21513. * Gets or sets a texture used to add random noise to particle positions
  21514. */
  21515. noiseTexture: Nullable<BaseTexture>;
  21516. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21517. noiseStrength: Vector3;
  21518. /**
  21519. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21520. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21521. */
  21522. billboardMode: number;
  21523. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21524. limitVelocityDamping: number;
  21525. /**
  21526. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21527. */
  21528. beginAnimationOnStart: boolean;
  21529. /**
  21530. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21531. */
  21532. beginAnimationFrom: number;
  21533. /**
  21534. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21535. */
  21536. beginAnimationTo: number;
  21537. /**
  21538. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21539. */
  21540. beginAnimationLoop: boolean;
  21541. /**
  21542. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21543. */
  21544. disposeOnStop: boolean;
  21545. /**
  21546. * Gets the maximum number of particles active at the same time.
  21547. * @returns The max number of active particles.
  21548. */
  21549. getCapacity(): number;
  21550. /**
  21551. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21552. * @returns True if it has been started, otherwise false.
  21553. */
  21554. isStarted(): boolean;
  21555. /**
  21556. * Animates the particle system for this frame.
  21557. */
  21558. animate(): void;
  21559. /**
  21560. * Renders the particle system in its current state.
  21561. * @returns the current number of particles
  21562. */
  21563. render(): number;
  21564. /**
  21565. * Dispose the particle system and frees its associated resources.
  21566. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21567. */
  21568. dispose(disposeTexture?: boolean): void;
  21569. /**
  21570. * Clones the particle system.
  21571. * @param name The name of the cloned object
  21572. * @param newEmitter The new emitter to use
  21573. * @returns the cloned particle system
  21574. */
  21575. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21576. /**
  21577. * Serializes the particle system to a JSON object.
  21578. * @returns the JSON object
  21579. */
  21580. serialize(): any;
  21581. /**
  21582. * Rebuild the particle system
  21583. */
  21584. rebuild(): void;
  21585. /**
  21586. * Starts the particle system and begins to emit
  21587. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21588. */
  21589. start(delay?: number): void;
  21590. /**
  21591. * Stops the particle system.
  21592. */
  21593. stop(): void;
  21594. /**
  21595. * Remove all active particles
  21596. */
  21597. reset(): void;
  21598. /**
  21599. * Is this system ready to be used/rendered
  21600. * @return true if the system is ready
  21601. */
  21602. isReady(): boolean;
  21603. /**
  21604. * Adds a new color gradient
  21605. * @param gradient defines the gradient to use (between 0 and 1)
  21606. * @param color1 defines the color to affect to the specified gradient
  21607. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21608. * @returns the current particle system
  21609. */
  21610. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21611. /**
  21612. * Remove a specific color gradient
  21613. * @param gradient defines the gradient to remove
  21614. * @returns the current particle system
  21615. */
  21616. removeColorGradient(gradient: number): IParticleSystem;
  21617. /**
  21618. * Adds a new size gradient
  21619. * @param gradient defines the gradient to use (between 0 and 1)
  21620. * @param factor defines the size factor to affect to the specified gradient
  21621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21622. * @returns the current particle system
  21623. */
  21624. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21625. /**
  21626. * Remove a specific size gradient
  21627. * @param gradient defines the gradient to remove
  21628. * @returns the current particle system
  21629. */
  21630. removeSizeGradient(gradient: number): IParticleSystem;
  21631. /**
  21632. * Gets the current list of color gradients.
  21633. * You must use addColorGradient and removeColorGradient to udpate this list
  21634. * @returns the list of color gradients
  21635. */
  21636. getColorGradients(): Nullable<Array<ColorGradient>>;
  21637. /**
  21638. * Gets the current list of size gradients.
  21639. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21640. * @returns the list of size gradients
  21641. */
  21642. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21643. /**
  21644. * Gets the current list of angular speed gradients.
  21645. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21646. * @returns the list of angular speed gradients
  21647. */
  21648. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21649. /**
  21650. * Adds a new angular speed gradient
  21651. * @param gradient defines the gradient to use (between 0 and 1)
  21652. * @param factor defines the angular speed to affect to the specified gradient
  21653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21654. * @returns the current particle system
  21655. */
  21656. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21657. /**
  21658. * Remove a specific angular speed gradient
  21659. * @param gradient defines the gradient to remove
  21660. * @returns the current particle system
  21661. */
  21662. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21663. /**
  21664. * Gets the current list of velocity gradients.
  21665. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21666. * @returns the list of velocity gradients
  21667. */
  21668. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21669. /**
  21670. * Adds a new velocity gradient
  21671. * @param gradient defines the gradient to use (between 0 and 1)
  21672. * @param factor defines the velocity to affect to the specified gradient
  21673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21674. * @returns the current particle system
  21675. */
  21676. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21677. /**
  21678. * Remove a specific velocity gradient
  21679. * @param gradient defines the gradient to remove
  21680. * @returns the current particle system
  21681. */
  21682. removeVelocityGradient(gradient: number): IParticleSystem;
  21683. /**
  21684. * Gets the current list of limit velocity gradients.
  21685. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21686. * @returns the list of limit velocity gradients
  21687. */
  21688. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21689. /**
  21690. * Adds a new limit velocity gradient
  21691. * @param gradient defines the gradient to use (between 0 and 1)
  21692. * @param factor defines the limit velocity to affect to the specified gradient
  21693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21694. * @returns the current particle system
  21695. */
  21696. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21697. /**
  21698. * Remove a specific limit velocity gradient
  21699. * @param gradient defines the gradient to remove
  21700. * @returns the current particle system
  21701. */
  21702. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21703. /**
  21704. * Adds a new drag gradient
  21705. * @param gradient defines the gradient to use (between 0 and 1)
  21706. * @param factor defines the drag to affect to the specified gradient
  21707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21708. * @returns the current particle system
  21709. */
  21710. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21711. /**
  21712. * Remove a specific drag gradient
  21713. * @param gradient defines the gradient to remove
  21714. * @returns the current particle system
  21715. */
  21716. removeDragGradient(gradient: number): IParticleSystem;
  21717. /**
  21718. * Gets the current list of drag gradients.
  21719. * You must use addDragGradient and removeDragGradient to udpate this list
  21720. * @returns the list of drag gradients
  21721. */
  21722. getDragGradients(): Nullable<Array<FactorGradient>>;
  21723. /**
  21724. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21725. * @param gradient defines the gradient to use (between 0 and 1)
  21726. * @param factor defines the emit rate to affect to the specified gradient
  21727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21728. * @returns the current particle system
  21729. */
  21730. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21731. /**
  21732. * Remove a specific emit rate gradient
  21733. * @param gradient defines the gradient to remove
  21734. * @returns the current particle system
  21735. */
  21736. removeEmitRateGradient(gradient: number): IParticleSystem;
  21737. /**
  21738. * Gets the current list of emit rate gradients.
  21739. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21740. * @returns the list of emit rate gradients
  21741. */
  21742. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21743. /**
  21744. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21745. * @param gradient defines the gradient to use (between 0 and 1)
  21746. * @param factor defines the start size to affect to the specified gradient
  21747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21748. * @returns the current particle system
  21749. */
  21750. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21751. /**
  21752. * Remove a specific start size gradient
  21753. * @param gradient defines the gradient to remove
  21754. * @returns the current particle system
  21755. */
  21756. removeStartSizeGradient(gradient: number): IParticleSystem;
  21757. /**
  21758. * Gets the current list of start size gradients.
  21759. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21760. * @returns the list of start size gradients
  21761. */
  21762. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21763. /**
  21764. * Adds a new life time gradient
  21765. * @param gradient defines the gradient to use (between 0 and 1)
  21766. * @param factor defines the life time factor to affect to the specified gradient
  21767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21768. * @returns the current particle system
  21769. */
  21770. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21771. /**
  21772. * Remove a specific life time gradient
  21773. * @param gradient defines the gradient to remove
  21774. * @returns the current particle system
  21775. */
  21776. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21777. /**
  21778. * Gets the current list of life time gradients.
  21779. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21780. * @returns the list of life time gradients
  21781. */
  21782. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21783. /**
  21784. * Gets the current list of color gradients.
  21785. * You must use addColorGradient and removeColorGradient to udpate this list
  21786. * @returns the list of color gradients
  21787. */
  21788. getColorGradients(): Nullable<Array<ColorGradient>>;
  21789. /**
  21790. * Adds a new ramp gradient used to remap particle colors
  21791. * @param gradient defines the gradient to use (between 0 and 1)
  21792. * @param color defines the color to affect to the specified gradient
  21793. * @returns the current particle system
  21794. */
  21795. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21796. /**
  21797. * Gets the current list of ramp gradients.
  21798. * You must use addRampGradient and removeRampGradient to udpate this list
  21799. * @returns the list of ramp gradients
  21800. */
  21801. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21802. /** Gets or sets a boolean indicating that ramp gradients must be used
  21803. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21804. */
  21805. useRampGradients: boolean;
  21806. /**
  21807. * Adds a new color remap gradient
  21808. * @param gradient defines the gradient to use (between 0 and 1)
  21809. * @param min defines the color remap minimal range
  21810. * @param max defines the color remap maximal range
  21811. * @returns the current particle system
  21812. */
  21813. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21814. /**
  21815. * Gets the current list of color remap gradients.
  21816. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21817. * @returns the list of color remap gradients
  21818. */
  21819. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21820. /**
  21821. * Adds a new alpha remap gradient
  21822. * @param gradient defines the gradient to use (between 0 and 1)
  21823. * @param min defines the alpha remap minimal range
  21824. * @param max defines the alpha remap maximal range
  21825. * @returns the current particle system
  21826. */
  21827. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21828. /**
  21829. * Gets the current list of alpha remap gradients.
  21830. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21831. * @returns the list of alpha remap gradients
  21832. */
  21833. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21834. /**
  21835. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21838. * @returns the emitter
  21839. */
  21840. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21841. /**
  21842. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21843. * @param radius The radius of the hemisphere to emit from
  21844. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21845. * @returns the emitter
  21846. */
  21847. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21848. /**
  21849. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21850. * @param radius The radius of the sphere to emit from
  21851. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21852. * @returns the emitter
  21853. */
  21854. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21855. /**
  21856. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21857. * @param radius The radius of the sphere to emit from
  21858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21860. * @returns the emitter
  21861. */
  21862. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21863. /**
  21864. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21865. * @param radius The radius of the emission cylinder
  21866. * @param height The height of the emission cylinder
  21867. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21868. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21869. * @returns the emitter
  21870. */
  21871. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21872. /**
  21873. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21874. * @param radius The radius of the cylinder to emit from
  21875. * @param height The height of the emission cylinder
  21876. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21879. * @returns the emitter
  21880. */
  21881. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21882. /**
  21883. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21884. * @param radius The radius of the cone to emit from
  21885. * @param angle The base angle of the cone
  21886. * @returns the emitter
  21887. */
  21888. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21889. /**
  21890. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21891. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21892. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21893. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21894. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21895. * @returns the emitter
  21896. */
  21897. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21898. /**
  21899. * Get hosting scene
  21900. * @returns the scene
  21901. */
  21902. getScene(): Scene;
  21903. }
  21904. }
  21905. declare module "babylonjs/Shaders/line.fragment" {
  21906. /** @hidden */
  21907. export var linePixelShader: {
  21908. name: string;
  21909. shader: string;
  21910. };
  21911. }
  21912. declare module "babylonjs/Shaders/line.vertex" {
  21913. /** @hidden */
  21914. export var lineVertexShader: {
  21915. name: string;
  21916. shader: string;
  21917. };
  21918. }
  21919. declare module "babylonjs/Rendering/edgesRenderer" {
  21920. import { Nullable } from "babylonjs/types";
  21921. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21923. import { Vector3 } from "babylonjs/Maths/math";
  21924. import { IDisposable } from "babylonjs/scene";
  21925. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21926. import "babylonjs/Shaders/line.fragment";
  21927. import "babylonjs/Shaders/line.vertex";
  21928. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21929. module "babylonjs/Meshes/abstractMesh" {
  21930. interface AbstractMesh {
  21931. /**
  21932. * Gets the edgesRenderer associated with the mesh
  21933. */
  21934. edgesRenderer: Nullable<EdgesRenderer>;
  21935. }
  21936. }
  21937. module "babylonjs/Meshes/linesMesh" {
  21938. interface LinesMesh {
  21939. /**
  21940. * Enables the edge rendering mode on the mesh.
  21941. * This mode makes the mesh edges visible
  21942. * @param epsilon defines the maximal distance between two angles to detect a face
  21943. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21944. * @returns the currentAbstractMesh
  21945. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21946. */
  21947. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21948. }
  21949. }
  21950. module "babylonjs/Meshes/linesMesh" {
  21951. interface InstancedLinesMesh {
  21952. /**
  21953. * Enables the edge rendering mode on the mesh.
  21954. * This mode makes the mesh edges visible
  21955. * @param epsilon defines the maximal distance between two angles to detect a face
  21956. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21957. * @returns the current InstancedLinesMesh
  21958. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21959. */
  21960. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21961. }
  21962. }
  21963. /**
  21964. * Defines the minimum contract an Edges renderer should follow.
  21965. */
  21966. export interface IEdgesRenderer extends IDisposable {
  21967. /**
  21968. * Gets or sets a boolean indicating if the edgesRenderer is active
  21969. */
  21970. isEnabled: boolean;
  21971. /**
  21972. * Renders the edges of the attached mesh,
  21973. */
  21974. render(): void;
  21975. /**
  21976. * Checks wether or not the edges renderer is ready to render.
  21977. * @return true if ready, otherwise false.
  21978. */
  21979. isReady(): boolean;
  21980. }
  21981. /**
  21982. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21983. */
  21984. export class EdgesRenderer implements IEdgesRenderer {
  21985. /**
  21986. * Define the size of the edges with an orthographic camera
  21987. */
  21988. edgesWidthScalerForOrthographic: number;
  21989. /**
  21990. * Define the size of the edges with a perspective camera
  21991. */
  21992. edgesWidthScalerForPerspective: number;
  21993. protected _source: AbstractMesh;
  21994. protected _linesPositions: number[];
  21995. protected _linesNormals: number[];
  21996. protected _linesIndices: number[];
  21997. protected _epsilon: number;
  21998. protected _indicesCount: number;
  21999. protected _lineShader: ShaderMaterial;
  22000. protected _ib: DataBuffer;
  22001. protected _buffers: {
  22002. [key: string]: Nullable<VertexBuffer>;
  22003. };
  22004. protected _checkVerticesInsteadOfIndices: boolean;
  22005. private _meshRebuildObserver;
  22006. private _meshDisposeObserver;
  22007. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22008. isEnabled: boolean;
  22009. /**
  22010. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22011. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22012. * @param source Mesh used to create edges
  22013. * @param epsilon sum of angles in adjacency to check for edge
  22014. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22015. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22016. */
  22017. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22018. protected _prepareRessources(): void;
  22019. /** @hidden */
  22020. _rebuild(): void;
  22021. /**
  22022. * Releases the required resources for the edges renderer
  22023. */
  22024. dispose(): void;
  22025. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22026. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22027. /**
  22028. * Checks if the pair of p0 and p1 is en edge
  22029. * @param faceIndex
  22030. * @param edge
  22031. * @param faceNormals
  22032. * @param p0
  22033. * @param p1
  22034. * @private
  22035. */
  22036. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22037. /**
  22038. * push line into the position, normal and index buffer
  22039. * @protected
  22040. */
  22041. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22042. /**
  22043. * Generates lines edges from adjacencjes
  22044. * @private
  22045. */
  22046. _generateEdgesLines(): void;
  22047. /**
  22048. * Checks wether or not the edges renderer is ready to render.
  22049. * @return true if ready, otherwise false.
  22050. */
  22051. isReady(): boolean;
  22052. /**
  22053. * Renders the edges of the attached mesh,
  22054. */
  22055. render(): void;
  22056. }
  22057. /**
  22058. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22059. */
  22060. export class LineEdgesRenderer extends EdgesRenderer {
  22061. /**
  22062. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22063. * @param source LineMesh used to generate edges
  22064. * @param epsilon not important (specified angle for edge detection)
  22065. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22066. */
  22067. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22068. /**
  22069. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22070. */
  22071. _generateEdgesLines(): void;
  22072. }
  22073. }
  22074. declare module "babylonjs/Rendering/renderingGroup" {
  22075. import { SmartArray } from "babylonjs/Misc/smartArray";
  22076. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22078. import { Nullable } from "babylonjs/types";
  22079. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22080. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22081. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22082. import { Material } from "babylonjs/Materials/material";
  22083. import { Scene } from "babylonjs/scene";
  22084. /**
  22085. * This represents the object necessary to create a rendering group.
  22086. * This is exclusively used and created by the rendering manager.
  22087. * To modify the behavior, you use the available helpers in your scene or meshes.
  22088. * @hidden
  22089. */
  22090. export class RenderingGroup {
  22091. index: number;
  22092. private static _zeroVector;
  22093. private _scene;
  22094. private _opaqueSubMeshes;
  22095. private _transparentSubMeshes;
  22096. private _alphaTestSubMeshes;
  22097. private _depthOnlySubMeshes;
  22098. private _particleSystems;
  22099. private _spriteManagers;
  22100. private _opaqueSortCompareFn;
  22101. private _alphaTestSortCompareFn;
  22102. private _transparentSortCompareFn;
  22103. private _renderOpaque;
  22104. private _renderAlphaTest;
  22105. private _renderTransparent;
  22106. /** @hidden */
  22107. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22108. onBeforeTransparentRendering: () => void;
  22109. /**
  22110. * Set the opaque sort comparison function.
  22111. * If null the sub meshes will be render in the order they were created
  22112. */
  22113. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22114. /**
  22115. * Set the alpha test sort comparison function.
  22116. * If null the sub meshes will be render in the order they were created
  22117. */
  22118. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22119. /**
  22120. * Set the transparent sort comparison function.
  22121. * If null the sub meshes will be render in the order they were created
  22122. */
  22123. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22124. /**
  22125. * Creates a new rendering group.
  22126. * @param index The rendering group index
  22127. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22128. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22129. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22130. */
  22131. 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>);
  22132. /**
  22133. * Render all the sub meshes contained in the group.
  22134. * @param customRenderFunction Used to override the default render behaviour of the group.
  22135. * @returns true if rendered some submeshes.
  22136. */
  22137. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22138. /**
  22139. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22140. * @param subMeshes The submeshes to render
  22141. */
  22142. private renderOpaqueSorted;
  22143. /**
  22144. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22145. * @param subMeshes The submeshes to render
  22146. */
  22147. private renderAlphaTestSorted;
  22148. /**
  22149. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22150. * @param subMeshes The submeshes to render
  22151. */
  22152. private renderTransparentSorted;
  22153. /**
  22154. * Renders the submeshes in a specified order.
  22155. * @param subMeshes The submeshes to sort before render
  22156. * @param sortCompareFn The comparison function use to sort
  22157. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22158. * @param transparent Specifies to activate blending if true
  22159. */
  22160. private static renderSorted;
  22161. /**
  22162. * Renders the submeshes in the order they were dispatched (no sort applied).
  22163. * @param subMeshes The submeshes to render
  22164. */
  22165. private static renderUnsorted;
  22166. /**
  22167. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22168. * are rendered back to front if in the same alpha index.
  22169. *
  22170. * @param a The first submesh
  22171. * @param b The second submesh
  22172. * @returns The result of the comparison
  22173. */
  22174. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22175. /**
  22176. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22177. * are rendered back to front.
  22178. *
  22179. * @param a The first submesh
  22180. * @param b The second submesh
  22181. * @returns The result of the comparison
  22182. */
  22183. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22184. /**
  22185. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22186. * are rendered front to back (prevent overdraw).
  22187. *
  22188. * @param a The first submesh
  22189. * @param b The second submesh
  22190. * @returns The result of the comparison
  22191. */
  22192. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22193. /**
  22194. * Resets the different lists of submeshes to prepare a new frame.
  22195. */
  22196. prepare(): void;
  22197. dispose(): void;
  22198. /**
  22199. * Inserts the submesh in its correct queue depending on its material.
  22200. * @param subMesh The submesh to dispatch
  22201. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22202. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22203. */
  22204. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22205. dispatchSprites(spriteManager: ISpriteManager): void;
  22206. dispatchParticles(particleSystem: IParticleSystem): void;
  22207. private _renderParticles;
  22208. private _renderSprites;
  22209. }
  22210. }
  22211. declare module "babylonjs/Rendering/renderingManager" {
  22212. import { Nullable } from "babylonjs/types";
  22213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22215. import { SmartArray } from "babylonjs/Misc/smartArray";
  22216. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22217. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22218. import { Material } from "babylonjs/Materials/material";
  22219. import { Scene } from "babylonjs/scene";
  22220. import { Camera } from "babylonjs/Cameras/camera";
  22221. /**
  22222. * Interface describing the different options available in the rendering manager
  22223. * regarding Auto Clear between groups.
  22224. */
  22225. export interface IRenderingManagerAutoClearSetup {
  22226. /**
  22227. * Defines whether or not autoclear is enable.
  22228. */
  22229. autoClear: boolean;
  22230. /**
  22231. * Defines whether or not to autoclear the depth buffer.
  22232. */
  22233. depth: boolean;
  22234. /**
  22235. * Defines whether or not to autoclear the stencil buffer.
  22236. */
  22237. stencil: boolean;
  22238. }
  22239. /**
  22240. * This class is used by the onRenderingGroupObservable
  22241. */
  22242. export class RenderingGroupInfo {
  22243. /**
  22244. * The Scene that being rendered
  22245. */
  22246. scene: Scene;
  22247. /**
  22248. * The camera currently used for the rendering pass
  22249. */
  22250. camera: Nullable<Camera>;
  22251. /**
  22252. * The ID of the renderingGroup being processed
  22253. */
  22254. renderingGroupId: number;
  22255. }
  22256. /**
  22257. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22258. * It is enable to manage the different groups as well as the different necessary sort functions.
  22259. * This should not be used directly aside of the few static configurations
  22260. */
  22261. export class RenderingManager {
  22262. /**
  22263. * The max id used for rendering groups (not included)
  22264. */
  22265. static MAX_RENDERINGGROUPS: number;
  22266. /**
  22267. * The min id used for rendering groups (included)
  22268. */
  22269. static MIN_RENDERINGGROUPS: number;
  22270. /**
  22271. * Used to globally prevent autoclearing scenes.
  22272. */
  22273. static AUTOCLEAR: boolean;
  22274. /**
  22275. * @hidden
  22276. */
  22277. _useSceneAutoClearSetup: boolean;
  22278. private _scene;
  22279. private _renderingGroups;
  22280. private _depthStencilBufferAlreadyCleaned;
  22281. private _autoClearDepthStencil;
  22282. private _customOpaqueSortCompareFn;
  22283. private _customAlphaTestSortCompareFn;
  22284. private _customTransparentSortCompareFn;
  22285. private _renderingGroupInfo;
  22286. /**
  22287. * Instantiates a new rendering group for a particular scene
  22288. * @param scene Defines the scene the groups belongs to
  22289. */
  22290. constructor(scene: Scene);
  22291. private _clearDepthStencilBuffer;
  22292. /**
  22293. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22294. * @hidden
  22295. */
  22296. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22297. /**
  22298. * Resets the different information of the group to prepare a new frame
  22299. * @hidden
  22300. */
  22301. reset(): void;
  22302. /**
  22303. * Dispose and release the group and its associated resources.
  22304. * @hidden
  22305. */
  22306. dispose(): void;
  22307. /**
  22308. * Clear the info related to rendering groups preventing retention points during dispose.
  22309. */
  22310. freeRenderingGroups(): void;
  22311. private _prepareRenderingGroup;
  22312. /**
  22313. * Add a sprite manager to the rendering manager in order to render it this frame.
  22314. * @param spriteManager Define the sprite manager to render
  22315. */
  22316. dispatchSprites(spriteManager: ISpriteManager): void;
  22317. /**
  22318. * Add a particle system to the rendering manager in order to render it this frame.
  22319. * @param particleSystem Define the particle system to render
  22320. */
  22321. dispatchParticles(particleSystem: IParticleSystem): void;
  22322. /**
  22323. * Add a submesh to the manager in order to render it this frame
  22324. * @param subMesh The submesh to dispatch
  22325. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22326. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22327. */
  22328. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22329. /**
  22330. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22331. * This allowed control for front to back rendering or reversly depending of the special needs.
  22332. *
  22333. * @param renderingGroupId The rendering group id corresponding to its index
  22334. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22335. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22336. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22337. */
  22338. 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;
  22339. /**
  22340. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22341. *
  22342. * @param renderingGroupId The rendering group id corresponding to its index
  22343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22344. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22345. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22346. */
  22347. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22348. /**
  22349. * Gets the current auto clear configuration for one rendering group of the rendering
  22350. * manager.
  22351. * @param index the rendering group index to get the information for
  22352. * @returns The auto clear setup for the requested rendering group
  22353. */
  22354. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22355. }
  22356. }
  22357. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22358. import { Observable } from "babylonjs/Misc/observable";
  22359. import { SmartArray } from "babylonjs/Misc/smartArray";
  22360. import { Nullable } from "babylonjs/types";
  22361. import { Camera } from "babylonjs/Cameras/camera";
  22362. import { Scene } from "babylonjs/scene";
  22363. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22364. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22367. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22368. import { Texture } from "babylonjs/Materials/Textures/texture";
  22369. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22370. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22371. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22372. import { Engine } from "babylonjs/Engines/engine";
  22373. /**
  22374. * This Helps creating a texture that will be created from a camera in your scene.
  22375. * It is basically a dynamic texture that could be used to create special effects for instance.
  22376. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22377. */
  22378. export class RenderTargetTexture extends Texture {
  22379. isCube: boolean;
  22380. /**
  22381. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22382. */
  22383. static readonly REFRESHRATE_RENDER_ONCE: number;
  22384. /**
  22385. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22386. */
  22387. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22388. /**
  22389. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22390. * the central point of your effect and can save a lot of performances.
  22391. */
  22392. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22393. /**
  22394. * Use this predicate to dynamically define the list of mesh you want to render.
  22395. * If set, the renderList property will be overwritten.
  22396. */
  22397. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22398. private _renderList;
  22399. /**
  22400. * Use this list to define the list of mesh you want to render.
  22401. */
  22402. renderList: Nullable<Array<AbstractMesh>>;
  22403. private _hookArray;
  22404. /**
  22405. * Define if particles should be rendered in your texture.
  22406. */
  22407. renderParticles: boolean;
  22408. /**
  22409. * Define if sprites should be rendered in your texture.
  22410. */
  22411. renderSprites: boolean;
  22412. /**
  22413. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22414. */
  22415. coordinatesMode: number;
  22416. /**
  22417. * Define the camera used to render the texture.
  22418. */
  22419. activeCamera: Nullable<Camera>;
  22420. /**
  22421. * Override the render function of the texture with your own one.
  22422. */
  22423. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22424. /**
  22425. * Define if camera post processes should be use while rendering the texture.
  22426. */
  22427. useCameraPostProcesses: boolean;
  22428. /**
  22429. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22430. */
  22431. ignoreCameraViewport: boolean;
  22432. private _postProcessManager;
  22433. private _postProcesses;
  22434. private _resizeObserver;
  22435. /**
  22436. * An event triggered when the texture is unbind.
  22437. */
  22438. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22439. /**
  22440. * An event triggered when the texture is unbind.
  22441. */
  22442. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22443. private _onAfterUnbindObserver;
  22444. /**
  22445. * Set a after unbind callback in the texture.
  22446. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22447. */
  22448. onAfterUnbind: () => void;
  22449. /**
  22450. * An event triggered before rendering the texture
  22451. */
  22452. onBeforeRenderObservable: Observable<number>;
  22453. private _onBeforeRenderObserver;
  22454. /**
  22455. * Set a before render callback in the texture.
  22456. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22457. */
  22458. onBeforeRender: (faceIndex: number) => void;
  22459. /**
  22460. * An event triggered after rendering the texture
  22461. */
  22462. onAfterRenderObservable: Observable<number>;
  22463. private _onAfterRenderObserver;
  22464. /**
  22465. * Set a after render callback in the texture.
  22466. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22467. */
  22468. onAfterRender: (faceIndex: number) => void;
  22469. /**
  22470. * An event triggered after the texture clear
  22471. */
  22472. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22473. private _onClearObserver;
  22474. /**
  22475. * Set a clear callback in the texture.
  22476. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22477. */
  22478. onClear: (Engine: Engine) => void;
  22479. /**
  22480. * Define the clear color of the Render Target if it should be different from the scene.
  22481. */
  22482. clearColor: Color4;
  22483. protected _size: number | {
  22484. width: number;
  22485. height: number;
  22486. };
  22487. protected _initialSizeParameter: number | {
  22488. width: number;
  22489. height: number;
  22490. } | {
  22491. ratio: number;
  22492. };
  22493. protected _sizeRatio: Nullable<number>;
  22494. /** @hidden */
  22495. _generateMipMaps: boolean;
  22496. protected _renderingManager: RenderingManager;
  22497. /** @hidden */
  22498. _waitingRenderList: string[];
  22499. protected _doNotChangeAspectRatio: boolean;
  22500. protected _currentRefreshId: number;
  22501. protected _refreshRate: number;
  22502. protected _textureMatrix: Matrix;
  22503. protected _samples: number;
  22504. protected _renderTargetOptions: RenderTargetCreationOptions;
  22505. /**
  22506. * Gets render target creation options that were used.
  22507. */
  22508. readonly renderTargetOptions: RenderTargetCreationOptions;
  22509. protected _engine: Engine;
  22510. protected _onRatioRescale(): void;
  22511. /**
  22512. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22513. * It must define where the camera used to render the texture is set
  22514. */
  22515. boundingBoxPosition: Vector3;
  22516. private _boundingBoxSize;
  22517. /**
  22518. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22519. * When defined, the cubemap will switch to local mode
  22520. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22521. * @example https://www.babylonjs-playground.com/#RNASML
  22522. */
  22523. boundingBoxSize: Vector3;
  22524. /**
  22525. * In case the RTT has been created with a depth texture, get the associated
  22526. * depth texture.
  22527. * Otherwise, return null.
  22528. */
  22529. depthStencilTexture: Nullable<InternalTexture>;
  22530. /**
  22531. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22532. * or used a shadow, depth texture...
  22533. * @param name The friendly name of the texture
  22534. * @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)
  22535. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22536. * @param generateMipMaps True if mip maps need to be generated after render.
  22537. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22538. * @param type The type of the buffer in the RTT (int, half float, float...)
  22539. * @param isCube True if a cube texture needs to be created
  22540. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22541. * @param generateDepthBuffer True to generate a depth buffer
  22542. * @param generateStencilBuffer True to generate a stencil buffer
  22543. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22544. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22545. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22546. */
  22547. constructor(name: string, size: number | {
  22548. width: number;
  22549. height: number;
  22550. } | {
  22551. ratio: number;
  22552. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22553. /**
  22554. * Creates a depth stencil texture.
  22555. * This is only available in WebGL 2 or with the depth texture extension available.
  22556. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22557. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22558. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22559. */
  22560. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22561. private _processSizeParameter;
  22562. /**
  22563. * Define the number of samples to use in case of MSAA.
  22564. * It defaults to one meaning no MSAA has been enabled.
  22565. */
  22566. samples: number;
  22567. /**
  22568. * Resets the refresh counter of the texture and start bak from scratch.
  22569. * Could be useful to regenerate the texture if it is setup to render only once.
  22570. */
  22571. resetRefreshCounter(): void;
  22572. /**
  22573. * Define the refresh rate of the texture or the rendering frequency.
  22574. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22575. */
  22576. refreshRate: number;
  22577. /**
  22578. * Adds a post process to the render target rendering passes.
  22579. * @param postProcess define the post process to add
  22580. */
  22581. addPostProcess(postProcess: PostProcess): void;
  22582. /**
  22583. * Clear all the post processes attached to the render target
  22584. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22585. */
  22586. clearPostProcesses(dispose?: boolean): void;
  22587. /**
  22588. * Remove one of the post process from the list of attached post processes to the texture
  22589. * @param postProcess define the post process to remove from the list
  22590. */
  22591. removePostProcess(postProcess: PostProcess): void;
  22592. /** @hidden */
  22593. _shouldRender(): boolean;
  22594. /**
  22595. * Gets the actual render size of the texture.
  22596. * @returns the width of the render size
  22597. */
  22598. getRenderSize(): number;
  22599. /**
  22600. * Gets the actual render width of the texture.
  22601. * @returns the width of the render size
  22602. */
  22603. getRenderWidth(): number;
  22604. /**
  22605. * Gets the actual render height of the texture.
  22606. * @returns the height of the render size
  22607. */
  22608. getRenderHeight(): number;
  22609. /**
  22610. * Get if the texture can be rescaled or not.
  22611. */
  22612. readonly canRescale: boolean;
  22613. /**
  22614. * Resize the texture using a ratio.
  22615. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22616. */
  22617. scale(ratio: number): void;
  22618. /**
  22619. * Get the texture reflection matrix used to rotate/transform the reflection.
  22620. * @returns the reflection matrix
  22621. */
  22622. getReflectionTextureMatrix(): Matrix;
  22623. /**
  22624. * Resize the texture to a new desired size.
  22625. * Be carrefull as it will recreate all the data in the new texture.
  22626. * @param size Define the new size. It can be:
  22627. * - a number for squared texture,
  22628. * - an object containing { width: number, height: number }
  22629. * - or an object containing a ratio { ratio: number }
  22630. */
  22631. resize(size: number | {
  22632. width: number;
  22633. height: number;
  22634. } | {
  22635. ratio: number;
  22636. }): void;
  22637. /**
  22638. * Renders all the objects from the render list into the texture.
  22639. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22640. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22641. */
  22642. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22643. private _bestReflectionRenderTargetDimension;
  22644. /**
  22645. * @hidden
  22646. * @param faceIndex face index to bind to if this is a cubetexture
  22647. */
  22648. _bindFrameBuffer(faceIndex?: number): void;
  22649. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22650. private renderToTarget;
  22651. /**
  22652. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22653. * This allowed control for front to back rendering or reversly depending of the special needs.
  22654. *
  22655. * @param renderingGroupId The rendering group id corresponding to its index
  22656. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22657. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22658. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22659. */
  22660. 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;
  22661. /**
  22662. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22663. *
  22664. * @param renderingGroupId The rendering group id corresponding to its index
  22665. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22666. */
  22667. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22668. /**
  22669. * Clones the texture.
  22670. * @returns the cloned texture
  22671. */
  22672. clone(): RenderTargetTexture;
  22673. /**
  22674. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22675. * @returns The JSON representation of the texture
  22676. */
  22677. serialize(): any;
  22678. /**
  22679. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22680. */
  22681. disposeFramebufferObjects(): void;
  22682. /**
  22683. * Dispose the texture and release its associated resources.
  22684. */
  22685. dispose(): void;
  22686. /** @hidden */
  22687. _rebuild(): void;
  22688. /**
  22689. * Clear the info related to rendering groups preventing retention point in material dispose.
  22690. */
  22691. freeRenderingGroups(): void;
  22692. /**
  22693. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22694. * @returns the view count
  22695. */
  22696. getViewCount(): number;
  22697. }
  22698. }
  22699. declare module "babylonjs/Materials/material" {
  22700. import { IAnimatable } from "babylonjs/Misc/tools";
  22701. import { SmartArray } from "babylonjs/Misc/smartArray";
  22702. import { Observable } from "babylonjs/Misc/observable";
  22703. import { Nullable } from "babylonjs/types";
  22704. import { Scene } from "babylonjs/scene";
  22705. import { Matrix } from "babylonjs/Maths/math";
  22706. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22708. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22709. import { Effect } from "babylonjs/Materials/effect";
  22710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22712. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22713. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22714. import { Mesh } from "babylonjs/Meshes/mesh";
  22715. import { Animation } from "babylonjs/Animations/animation";
  22716. /**
  22717. * Base class for the main features of a material in Babylon.js
  22718. */
  22719. export class Material implements IAnimatable {
  22720. /**
  22721. * Returns the triangle fill mode
  22722. */
  22723. static readonly TriangleFillMode: number;
  22724. /**
  22725. * Returns the wireframe mode
  22726. */
  22727. static readonly WireFrameFillMode: number;
  22728. /**
  22729. * Returns the point fill mode
  22730. */
  22731. static readonly PointFillMode: number;
  22732. /**
  22733. * Returns the point list draw mode
  22734. */
  22735. static readonly PointListDrawMode: number;
  22736. /**
  22737. * Returns the line list draw mode
  22738. */
  22739. static readonly LineListDrawMode: number;
  22740. /**
  22741. * Returns the line loop draw mode
  22742. */
  22743. static readonly LineLoopDrawMode: number;
  22744. /**
  22745. * Returns the line strip draw mode
  22746. */
  22747. static readonly LineStripDrawMode: number;
  22748. /**
  22749. * Returns the triangle strip draw mode
  22750. */
  22751. static readonly TriangleStripDrawMode: number;
  22752. /**
  22753. * Returns the triangle fan draw mode
  22754. */
  22755. static readonly TriangleFanDrawMode: number;
  22756. /**
  22757. * Stores the clock-wise side orientation
  22758. */
  22759. static readonly ClockWiseSideOrientation: number;
  22760. /**
  22761. * Stores the counter clock-wise side orientation
  22762. */
  22763. static readonly CounterClockWiseSideOrientation: number;
  22764. /**
  22765. * The dirty texture flag value
  22766. */
  22767. static readonly TextureDirtyFlag: number;
  22768. /**
  22769. * The dirty light flag value
  22770. */
  22771. static readonly LightDirtyFlag: number;
  22772. /**
  22773. * The dirty fresnel flag value
  22774. */
  22775. static readonly FresnelDirtyFlag: number;
  22776. /**
  22777. * The dirty attribute flag value
  22778. */
  22779. static readonly AttributesDirtyFlag: number;
  22780. /**
  22781. * The dirty misc flag value
  22782. */
  22783. static readonly MiscDirtyFlag: number;
  22784. /**
  22785. * The all dirty flag value
  22786. */
  22787. static readonly AllDirtyFlag: number;
  22788. /**
  22789. * The ID of the material
  22790. */
  22791. id: string;
  22792. /**
  22793. * Gets or sets the unique id of the material
  22794. */
  22795. uniqueId: number;
  22796. /**
  22797. * The name of the material
  22798. */
  22799. name: string;
  22800. /**
  22801. * Gets or sets user defined metadata
  22802. */
  22803. metadata: any;
  22804. /**
  22805. * For internal use only. Please do not use.
  22806. */
  22807. reservedDataStore: any;
  22808. /**
  22809. * Specifies if the ready state should be checked on each call
  22810. */
  22811. checkReadyOnEveryCall: boolean;
  22812. /**
  22813. * Specifies if the ready state should be checked once
  22814. */
  22815. checkReadyOnlyOnce: boolean;
  22816. /**
  22817. * The state of the material
  22818. */
  22819. state: string;
  22820. /**
  22821. * The alpha value of the material
  22822. */
  22823. protected _alpha: number;
  22824. /**
  22825. * List of inspectable custom properties (used by the Inspector)
  22826. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22827. */
  22828. inspectableCustomProperties: IInspectable[];
  22829. /**
  22830. * Sets the alpha value of the material
  22831. */
  22832. /**
  22833. * Gets the alpha value of the material
  22834. */
  22835. alpha: number;
  22836. /**
  22837. * Specifies if back face culling is enabled
  22838. */
  22839. protected _backFaceCulling: boolean;
  22840. /**
  22841. * Sets the back-face culling state
  22842. */
  22843. /**
  22844. * Gets the back-face culling state
  22845. */
  22846. backFaceCulling: boolean;
  22847. /**
  22848. * Stores the value for side orientation
  22849. */
  22850. sideOrientation: number;
  22851. /**
  22852. * Callback triggered when the material is compiled
  22853. */
  22854. onCompiled: Nullable<(effect: Effect) => void>;
  22855. /**
  22856. * Callback triggered when an error occurs
  22857. */
  22858. onError: Nullable<(effect: Effect, errors: string) => void>;
  22859. /**
  22860. * Callback triggered to get the render target textures
  22861. */
  22862. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22863. /**
  22864. * Gets a boolean indicating that current material needs to register RTT
  22865. */
  22866. readonly hasRenderTargetTextures: boolean;
  22867. /**
  22868. * Specifies if the material should be serialized
  22869. */
  22870. doNotSerialize: boolean;
  22871. /**
  22872. * @hidden
  22873. */
  22874. _storeEffectOnSubMeshes: boolean;
  22875. /**
  22876. * Stores the animations for the material
  22877. */
  22878. animations: Nullable<Array<Animation>>;
  22879. /**
  22880. * An event triggered when the material is disposed
  22881. */
  22882. onDisposeObservable: Observable<Material>;
  22883. /**
  22884. * An observer which watches for dispose events
  22885. */
  22886. private _onDisposeObserver;
  22887. private _onUnBindObservable;
  22888. /**
  22889. * Called during a dispose event
  22890. */
  22891. onDispose: () => void;
  22892. private _onBindObservable;
  22893. /**
  22894. * An event triggered when the material is bound
  22895. */
  22896. readonly onBindObservable: Observable<AbstractMesh>;
  22897. /**
  22898. * An observer which watches for bind events
  22899. */
  22900. private _onBindObserver;
  22901. /**
  22902. * Called during a bind event
  22903. */
  22904. onBind: (Mesh: AbstractMesh) => void;
  22905. /**
  22906. * An event triggered when the material is unbound
  22907. */
  22908. readonly onUnBindObservable: Observable<Material>;
  22909. /**
  22910. * Stores the value of the alpha mode
  22911. */
  22912. private _alphaMode;
  22913. /**
  22914. * Sets the value of the alpha mode.
  22915. *
  22916. * | Value | Type | Description |
  22917. * | --- | --- | --- |
  22918. * | 0 | ALPHA_DISABLE | |
  22919. * | 1 | ALPHA_ADD | |
  22920. * | 2 | ALPHA_COMBINE | |
  22921. * | 3 | ALPHA_SUBTRACT | |
  22922. * | 4 | ALPHA_MULTIPLY | |
  22923. * | 5 | ALPHA_MAXIMIZED | |
  22924. * | 6 | ALPHA_ONEONE | |
  22925. * | 7 | ALPHA_PREMULTIPLIED | |
  22926. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22927. * | 9 | ALPHA_INTERPOLATE | |
  22928. * | 10 | ALPHA_SCREENMODE | |
  22929. *
  22930. */
  22931. /**
  22932. * Gets the value of the alpha mode
  22933. */
  22934. alphaMode: number;
  22935. /**
  22936. * Stores the state of the need depth pre-pass value
  22937. */
  22938. private _needDepthPrePass;
  22939. /**
  22940. * Sets the need depth pre-pass value
  22941. */
  22942. /**
  22943. * Gets the depth pre-pass value
  22944. */
  22945. needDepthPrePass: boolean;
  22946. /**
  22947. * Specifies if depth writing should be disabled
  22948. */
  22949. disableDepthWrite: boolean;
  22950. /**
  22951. * Specifies if depth writing should be forced
  22952. */
  22953. forceDepthWrite: boolean;
  22954. /**
  22955. * Specifies if there should be a separate pass for culling
  22956. */
  22957. separateCullingPass: boolean;
  22958. /**
  22959. * Stores the state specifing if fog should be enabled
  22960. */
  22961. private _fogEnabled;
  22962. /**
  22963. * Sets the state for enabling fog
  22964. */
  22965. /**
  22966. * Gets the value of the fog enabled state
  22967. */
  22968. fogEnabled: boolean;
  22969. /**
  22970. * Stores the size of points
  22971. */
  22972. pointSize: number;
  22973. /**
  22974. * Stores the z offset value
  22975. */
  22976. zOffset: number;
  22977. /**
  22978. * Gets a value specifying if wireframe mode is enabled
  22979. */
  22980. /**
  22981. * Sets the state of wireframe mode
  22982. */
  22983. wireframe: boolean;
  22984. /**
  22985. * Gets the value specifying if point clouds are enabled
  22986. */
  22987. /**
  22988. * Sets the state of point cloud mode
  22989. */
  22990. pointsCloud: boolean;
  22991. /**
  22992. * Gets the material fill mode
  22993. */
  22994. /**
  22995. * Sets the material fill mode
  22996. */
  22997. fillMode: number;
  22998. /**
  22999. * @hidden
  23000. * Stores the effects for the material
  23001. */
  23002. _effect: Nullable<Effect>;
  23003. /**
  23004. * @hidden
  23005. * Specifies if the material was previously ready
  23006. */
  23007. _wasPreviouslyReady: boolean;
  23008. /**
  23009. * Specifies if uniform buffers should be used
  23010. */
  23011. private _useUBO;
  23012. /**
  23013. * Stores a reference to the scene
  23014. */
  23015. private _scene;
  23016. /**
  23017. * Stores the fill mode state
  23018. */
  23019. private _fillMode;
  23020. /**
  23021. * Specifies if the depth write state should be cached
  23022. */
  23023. private _cachedDepthWriteState;
  23024. /**
  23025. * Stores the uniform buffer
  23026. */
  23027. protected _uniformBuffer: UniformBuffer;
  23028. /** @hidden */
  23029. _indexInSceneMaterialArray: number;
  23030. /** @hidden */
  23031. meshMap: Nullable<{
  23032. [id: string]: AbstractMesh | undefined;
  23033. }>;
  23034. /**
  23035. * Creates a material instance
  23036. * @param name defines the name of the material
  23037. * @param scene defines the scene to reference
  23038. * @param doNotAdd specifies if the material should be added to the scene
  23039. */
  23040. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23041. /**
  23042. * Returns a string representation of the current material
  23043. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23044. * @returns a string with material information
  23045. */
  23046. toString(fullDetails?: boolean): string;
  23047. /**
  23048. * Gets the class name of the material
  23049. * @returns a string with the class name of the material
  23050. */
  23051. getClassName(): string;
  23052. /**
  23053. * Specifies if updates for the material been locked
  23054. */
  23055. readonly isFrozen: boolean;
  23056. /**
  23057. * Locks updates for the material
  23058. */
  23059. freeze(): void;
  23060. /**
  23061. * Unlocks updates for the material
  23062. */
  23063. unfreeze(): void;
  23064. /**
  23065. * Specifies if the material is ready to be used
  23066. * @param mesh defines the mesh to check
  23067. * @param useInstances specifies if instances should be used
  23068. * @returns a boolean indicating if the material is ready to be used
  23069. */
  23070. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23071. /**
  23072. * Specifies that the submesh is ready to be used
  23073. * @param mesh defines the mesh to check
  23074. * @param subMesh defines which submesh to check
  23075. * @param useInstances specifies that instances should be used
  23076. * @returns a boolean indicating that the submesh is ready or not
  23077. */
  23078. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23079. /**
  23080. * Returns the material effect
  23081. * @returns the effect associated with the material
  23082. */
  23083. getEffect(): Nullable<Effect>;
  23084. /**
  23085. * Returns the current scene
  23086. * @returns a Scene
  23087. */
  23088. getScene(): Scene;
  23089. /**
  23090. * Specifies if the material will require alpha blending
  23091. * @returns a boolean specifying if alpha blending is needed
  23092. */
  23093. needAlphaBlending(): boolean;
  23094. /**
  23095. * Specifies if the mesh will require alpha blending
  23096. * @param mesh defines the mesh to check
  23097. * @returns a boolean specifying if alpha blending is needed for the mesh
  23098. */
  23099. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23100. /**
  23101. * Specifies if this material should be rendered in alpha test mode
  23102. * @returns a boolean specifying if an alpha test is needed.
  23103. */
  23104. needAlphaTesting(): boolean;
  23105. /**
  23106. * Gets the texture used for the alpha test
  23107. * @returns the texture to use for alpha testing
  23108. */
  23109. getAlphaTestTexture(): Nullable<BaseTexture>;
  23110. /**
  23111. * Marks the material to indicate that it needs to be re-calculated
  23112. */
  23113. markDirty(): void;
  23114. /** @hidden */
  23115. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23116. /**
  23117. * Binds the material to the mesh
  23118. * @param world defines the world transformation matrix
  23119. * @param mesh defines the mesh to bind the material to
  23120. */
  23121. bind(world: Matrix, mesh?: Mesh): void;
  23122. /**
  23123. * Binds the submesh to the material
  23124. * @param world defines the world transformation matrix
  23125. * @param mesh defines the mesh containing the submesh
  23126. * @param subMesh defines the submesh to bind the material to
  23127. */
  23128. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23129. /**
  23130. * Binds the world matrix to the material
  23131. * @param world defines the world transformation matrix
  23132. */
  23133. bindOnlyWorldMatrix(world: Matrix): void;
  23134. /**
  23135. * Binds the scene's uniform buffer to the effect.
  23136. * @param effect defines the effect to bind to the scene uniform buffer
  23137. * @param sceneUbo defines the uniform buffer storing scene data
  23138. */
  23139. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23140. /**
  23141. * Binds the view matrix to the effect
  23142. * @param effect defines the effect to bind the view matrix to
  23143. */
  23144. bindView(effect: Effect): void;
  23145. /**
  23146. * Binds the view projection matrix to the effect
  23147. * @param effect defines the effect to bind the view projection matrix to
  23148. */
  23149. bindViewProjection(effect: Effect): void;
  23150. /**
  23151. * Specifies if material alpha testing should be turned on for the mesh
  23152. * @param mesh defines the mesh to check
  23153. */
  23154. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23155. /**
  23156. * Processes to execute after binding the material to a mesh
  23157. * @param mesh defines the rendered mesh
  23158. */
  23159. protected _afterBind(mesh?: Mesh): void;
  23160. /**
  23161. * Unbinds the material from the mesh
  23162. */
  23163. unbind(): void;
  23164. /**
  23165. * Gets the active textures from the material
  23166. * @returns an array of textures
  23167. */
  23168. getActiveTextures(): BaseTexture[];
  23169. /**
  23170. * Specifies if the material uses a texture
  23171. * @param texture defines the texture to check against the material
  23172. * @returns a boolean specifying if the material uses the texture
  23173. */
  23174. hasTexture(texture: BaseTexture): boolean;
  23175. /**
  23176. * Makes a duplicate of the material, and gives it a new name
  23177. * @param name defines the new name for the duplicated material
  23178. * @returns the cloned material
  23179. */
  23180. clone(name: string): Nullable<Material>;
  23181. /**
  23182. * Gets the meshes bound to the material
  23183. * @returns an array of meshes bound to the material
  23184. */
  23185. getBindedMeshes(): AbstractMesh[];
  23186. /**
  23187. * Force shader compilation
  23188. * @param mesh defines the mesh associated with this material
  23189. * @param onCompiled defines a function to execute once the material is compiled
  23190. * @param options defines the options to configure the compilation
  23191. */
  23192. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23193. clipPlane: boolean;
  23194. }>): void;
  23195. /**
  23196. * Force shader compilation
  23197. * @param mesh defines the mesh that will use this material
  23198. * @param options defines additional options for compiling the shaders
  23199. * @returns a promise that resolves when the compilation completes
  23200. */
  23201. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23202. clipPlane: boolean;
  23203. }>): Promise<void>;
  23204. private static readonly _AllDirtyCallBack;
  23205. private static readonly _ImageProcessingDirtyCallBack;
  23206. private static readonly _TextureDirtyCallBack;
  23207. private static readonly _FresnelDirtyCallBack;
  23208. private static readonly _MiscDirtyCallBack;
  23209. private static readonly _LightsDirtyCallBack;
  23210. private static readonly _AttributeDirtyCallBack;
  23211. private static _FresnelAndMiscDirtyCallBack;
  23212. private static _TextureAndMiscDirtyCallBack;
  23213. private static readonly _DirtyCallbackArray;
  23214. private static readonly _RunDirtyCallBacks;
  23215. /**
  23216. * Marks a define in the material to indicate that it needs to be re-computed
  23217. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23218. */
  23219. markAsDirty(flag: number): void;
  23220. /**
  23221. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23222. * @param func defines a function which checks material defines against the submeshes
  23223. */
  23224. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23225. /**
  23226. * Indicates that we need to re-calculated for all submeshes
  23227. */
  23228. protected _markAllSubMeshesAsAllDirty(): void;
  23229. /**
  23230. * Indicates that image processing needs to be re-calculated for all submeshes
  23231. */
  23232. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23233. /**
  23234. * Indicates that textures need to be re-calculated for all submeshes
  23235. */
  23236. protected _markAllSubMeshesAsTexturesDirty(): void;
  23237. /**
  23238. * Indicates that fresnel needs to be re-calculated for all submeshes
  23239. */
  23240. protected _markAllSubMeshesAsFresnelDirty(): void;
  23241. /**
  23242. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23243. */
  23244. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23245. /**
  23246. * Indicates that lights need to be re-calculated for all submeshes
  23247. */
  23248. protected _markAllSubMeshesAsLightsDirty(): void;
  23249. /**
  23250. * Indicates that attributes need to be re-calculated for all submeshes
  23251. */
  23252. protected _markAllSubMeshesAsAttributesDirty(): void;
  23253. /**
  23254. * Indicates that misc needs to be re-calculated for all submeshes
  23255. */
  23256. protected _markAllSubMeshesAsMiscDirty(): void;
  23257. /**
  23258. * Indicates that textures and misc need to be re-calculated for all submeshes
  23259. */
  23260. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23261. /**
  23262. * Disposes the material
  23263. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23264. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23265. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23266. */
  23267. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23268. /** @hidden */
  23269. private releaseVertexArrayObject;
  23270. /**
  23271. * Serializes this material
  23272. * @returns the serialized material object
  23273. */
  23274. serialize(): any;
  23275. /**
  23276. * Creates a material from parsed material data
  23277. * @param parsedMaterial defines parsed material data
  23278. * @param scene defines the hosting scene
  23279. * @param rootUrl defines the root URL to use to load textures
  23280. * @returns a new material
  23281. */
  23282. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23283. }
  23284. }
  23285. declare module "babylonjs/Meshes/subMesh" {
  23286. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23287. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23288. import { Engine } from "babylonjs/Engines/engine";
  23289. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23290. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23291. import { Effect } from "babylonjs/Materials/effect";
  23292. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23293. import { Collider } from "babylonjs/Collisions/collider";
  23294. import { Material } from "babylonjs/Materials/material";
  23295. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23297. import { Mesh } from "babylonjs/Meshes/mesh";
  23298. import { Ray } from "babylonjs/Culling/ray";
  23299. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23300. /**
  23301. * Base class for submeshes
  23302. */
  23303. export class BaseSubMesh {
  23304. /** @hidden */
  23305. _materialDefines: Nullable<MaterialDefines>;
  23306. /** @hidden */
  23307. _materialEffect: Nullable<Effect>;
  23308. /**
  23309. * Gets associated effect
  23310. */
  23311. readonly effect: Nullable<Effect>;
  23312. /**
  23313. * Sets associated effect (effect used to render this submesh)
  23314. * @param effect defines the effect to associate with
  23315. * @param defines defines the set of defines used to compile this effect
  23316. */
  23317. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23318. }
  23319. /**
  23320. * Defines a subdivision inside a mesh
  23321. */
  23322. export class SubMesh extends BaseSubMesh implements ICullable {
  23323. /** the material index to use */
  23324. materialIndex: number;
  23325. /** vertex index start */
  23326. verticesStart: number;
  23327. /** vertices count */
  23328. verticesCount: number;
  23329. /** index start */
  23330. indexStart: number;
  23331. /** indices count */
  23332. indexCount: number;
  23333. /** @hidden */
  23334. _linesIndexCount: number;
  23335. private _mesh;
  23336. private _renderingMesh;
  23337. private _boundingInfo;
  23338. private _linesIndexBuffer;
  23339. /** @hidden */
  23340. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23341. /** @hidden */
  23342. _trianglePlanes: Plane[];
  23343. /** @hidden */
  23344. _lastColliderTransformMatrix: Nullable<Matrix>;
  23345. /** @hidden */
  23346. _renderId: number;
  23347. /** @hidden */
  23348. _alphaIndex: number;
  23349. /** @hidden */
  23350. _distanceToCamera: number;
  23351. /** @hidden */
  23352. _id: number;
  23353. private _currentMaterial;
  23354. /**
  23355. * Add a new submesh to a mesh
  23356. * @param materialIndex defines the material index to use
  23357. * @param verticesStart defines vertex index start
  23358. * @param verticesCount defines vertices count
  23359. * @param indexStart defines index start
  23360. * @param indexCount defines indices count
  23361. * @param mesh defines the parent mesh
  23362. * @param renderingMesh defines an optional rendering mesh
  23363. * @param createBoundingBox defines if bounding box should be created for this submesh
  23364. * @returns the new submesh
  23365. */
  23366. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23367. /**
  23368. * Creates a new submesh
  23369. * @param materialIndex defines the material index to use
  23370. * @param verticesStart defines vertex index start
  23371. * @param verticesCount defines vertices count
  23372. * @param indexStart defines index start
  23373. * @param indexCount defines indices count
  23374. * @param mesh defines the parent mesh
  23375. * @param renderingMesh defines an optional rendering mesh
  23376. * @param createBoundingBox defines if bounding box should be created for this submesh
  23377. */
  23378. constructor(
  23379. /** the material index to use */
  23380. materialIndex: number,
  23381. /** vertex index start */
  23382. verticesStart: number,
  23383. /** vertices count */
  23384. verticesCount: number,
  23385. /** index start */
  23386. indexStart: number,
  23387. /** indices count */
  23388. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23389. /**
  23390. * Returns true if this submesh covers the entire parent mesh
  23391. * @ignorenaming
  23392. */
  23393. readonly IsGlobal: boolean;
  23394. /**
  23395. * Returns the submesh BoudingInfo object
  23396. * @returns current bounding info (or mesh's one if the submesh is global)
  23397. */
  23398. getBoundingInfo(): BoundingInfo;
  23399. /**
  23400. * Sets the submesh BoundingInfo
  23401. * @param boundingInfo defines the new bounding info to use
  23402. * @returns the SubMesh
  23403. */
  23404. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23405. /**
  23406. * Returns the mesh of the current submesh
  23407. * @return the parent mesh
  23408. */
  23409. getMesh(): AbstractMesh;
  23410. /**
  23411. * Returns the rendering mesh of the submesh
  23412. * @returns the rendering mesh (could be different from parent mesh)
  23413. */
  23414. getRenderingMesh(): Mesh;
  23415. /**
  23416. * Returns the submesh material
  23417. * @returns null or the current material
  23418. */
  23419. getMaterial(): Nullable<Material>;
  23420. /**
  23421. * Sets a new updated BoundingInfo object to the submesh
  23422. * @param data defines an optional position array to use to determine the bounding info
  23423. * @returns the SubMesh
  23424. */
  23425. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23426. /** @hidden */
  23427. _checkCollision(collider: Collider): boolean;
  23428. /**
  23429. * Updates the submesh BoundingInfo
  23430. * @param world defines the world matrix to use to update the bounding info
  23431. * @returns the submesh
  23432. */
  23433. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23434. /**
  23435. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23436. * @param frustumPlanes defines the frustum planes
  23437. * @returns true if the submesh is intersecting with the frustum
  23438. */
  23439. isInFrustum(frustumPlanes: Plane[]): boolean;
  23440. /**
  23441. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23442. * @param frustumPlanes defines the frustum planes
  23443. * @returns true if the submesh is inside the frustum
  23444. */
  23445. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23446. /**
  23447. * Renders the submesh
  23448. * @param enableAlphaMode defines if alpha needs to be used
  23449. * @returns the submesh
  23450. */
  23451. render(enableAlphaMode: boolean): SubMesh;
  23452. /**
  23453. * @hidden
  23454. */
  23455. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23456. /**
  23457. * Checks if the submesh intersects with a ray
  23458. * @param ray defines the ray to test
  23459. * @returns true is the passed ray intersects the submesh bounding box
  23460. */
  23461. canIntersects(ray: Ray): boolean;
  23462. /**
  23463. * Intersects current submesh with a ray
  23464. * @param ray defines the ray to test
  23465. * @param positions defines mesh's positions array
  23466. * @param indices defines mesh's indices array
  23467. * @param fastCheck defines if only bounding info should be used
  23468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23469. * @returns intersection info or null if no intersection
  23470. */
  23471. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23472. /** @hidden */
  23473. private _intersectLines;
  23474. /** @hidden */
  23475. private _intersectUnIndexedLines;
  23476. /** @hidden */
  23477. private _intersectTriangles;
  23478. /** @hidden */
  23479. private _intersectUnIndexedTriangles;
  23480. /** @hidden */
  23481. _rebuild(): void;
  23482. /**
  23483. * Creates a new submesh from the passed mesh
  23484. * @param newMesh defines the new hosting mesh
  23485. * @param newRenderingMesh defines an optional rendering mesh
  23486. * @returns the new submesh
  23487. */
  23488. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23489. /**
  23490. * Release associated resources
  23491. */
  23492. dispose(): void;
  23493. /**
  23494. * Gets the class name
  23495. * @returns the string "SubMesh".
  23496. */
  23497. getClassName(): string;
  23498. /**
  23499. * Creates a new submesh from indices data
  23500. * @param materialIndex the index of the main mesh material
  23501. * @param startIndex the index where to start the copy in the mesh indices array
  23502. * @param indexCount the number of indices to copy then from the startIndex
  23503. * @param mesh the main mesh to create the submesh from
  23504. * @param renderingMesh the optional rendering mesh
  23505. * @returns a new submesh
  23506. */
  23507. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23508. }
  23509. }
  23510. declare module "babylonjs/Meshes/geometry" {
  23511. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23512. import { Scene } from "babylonjs/scene";
  23513. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23514. import { Engine } from "babylonjs/Engines/engine";
  23515. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23516. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23517. import { Effect } from "babylonjs/Materials/effect";
  23518. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23519. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23520. import { Mesh } from "babylonjs/Meshes/mesh";
  23521. /**
  23522. * Class used to store geometry data (vertex buffers + index buffer)
  23523. */
  23524. export class Geometry implements IGetSetVerticesData {
  23525. /**
  23526. * Gets or sets the ID of the geometry
  23527. */
  23528. id: string;
  23529. /**
  23530. * Gets or sets the unique ID of the geometry
  23531. */
  23532. uniqueId: number;
  23533. /**
  23534. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23535. */
  23536. delayLoadState: number;
  23537. /**
  23538. * Gets the file containing the data to load when running in delay load state
  23539. */
  23540. delayLoadingFile: Nullable<string>;
  23541. /**
  23542. * Callback called when the geometry is updated
  23543. */
  23544. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23545. private _scene;
  23546. private _engine;
  23547. private _meshes;
  23548. private _totalVertices;
  23549. /** @hidden */
  23550. _indices: IndicesArray;
  23551. /** @hidden */
  23552. _vertexBuffers: {
  23553. [key: string]: VertexBuffer;
  23554. };
  23555. private _isDisposed;
  23556. private _extend;
  23557. private _boundingBias;
  23558. /** @hidden */
  23559. _delayInfo: Array<string>;
  23560. private _indexBuffer;
  23561. private _indexBufferIsUpdatable;
  23562. /** @hidden */
  23563. _boundingInfo: Nullable<BoundingInfo>;
  23564. /** @hidden */
  23565. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23566. /** @hidden */
  23567. _softwareSkinningFrameId: number;
  23568. private _vertexArrayObjects;
  23569. private _updatable;
  23570. /** @hidden */
  23571. _positions: Nullable<Vector3[]>;
  23572. /**
  23573. * 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
  23574. */
  23575. /**
  23576. * 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
  23577. */
  23578. boundingBias: Vector2;
  23579. /**
  23580. * Static function used to attach a new empty geometry to a mesh
  23581. * @param mesh defines the mesh to attach the geometry to
  23582. * @returns the new Geometry
  23583. */
  23584. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23585. /**
  23586. * Creates a new geometry
  23587. * @param id defines the unique ID
  23588. * @param scene defines the hosting scene
  23589. * @param vertexData defines the VertexData used to get geometry data
  23590. * @param updatable defines if geometry must be updatable (false by default)
  23591. * @param mesh defines the mesh that will be associated with the geometry
  23592. */
  23593. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23594. /**
  23595. * Gets the current extend of the geometry
  23596. */
  23597. readonly extend: {
  23598. minimum: Vector3;
  23599. maximum: Vector3;
  23600. };
  23601. /**
  23602. * Gets the hosting scene
  23603. * @returns the hosting Scene
  23604. */
  23605. getScene(): Scene;
  23606. /**
  23607. * Gets the hosting engine
  23608. * @returns the hosting Engine
  23609. */
  23610. getEngine(): Engine;
  23611. /**
  23612. * Defines if the geometry is ready to use
  23613. * @returns true if the geometry is ready to be used
  23614. */
  23615. isReady(): boolean;
  23616. /**
  23617. * Gets a value indicating that the geometry should not be serialized
  23618. */
  23619. readonly doNotSerialize: boolean;
  23620. /** @hidden */
  23621. _rebuild(): void;
  23622. /**
  23623. * Affects all geometry data in one call
  23624. * @param vertexData defines the geometry data
  23625. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23626. */
  23627. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23628. /**
  23629. * Set specific vertex data
  23630. * @param kind defines the data kind (Position, normal, etc...)
  23631. * @param data defines the vertex data to use
  23632. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23633. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23634. */
  23635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23636. /**
  23637. * Removes a specific vertex data
  23638. * @param kind defines the data kind (Position, normal, etc...)
  23639. */
  23640. removeVerticesData(kind: string): void;
  23641. /**
  23642. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23643. * @param buffer defines the vertex buffer to use
  23644. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23645. */
  23646. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23647. /**
  23648. * Update a specific vertex buffer
  23649. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23650. * It will do nothing if the buffer is not updatable
  23651. * @param kind defines the data kind (Position, normal, etc...)
  23652. * @param data defines the data to use
  23653. * @param offset defines the offset in the target buffer where to store the data
  23654. * @param useBytes set to true if the offset is in bytes
  23655. */
  23656. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23657. /**
  23658. * Update a specific vertex buffer
  23659. * This function will create a new buffer if the current one is not updatable
  23660. * @param kind defines the data kind (Position, normal, etc...)
  23661. * @param data defines the data to use
  23662. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23663. */
  23664. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23665. private _updateBoundingInfo;
  23666. /** @hidden */
  23667. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23668. /**
  23669. * Gets total number of vertices
  23670. * @returns the total number of vertices
  23671. */
  23672. getTotalVertices(): number;
  23673. /**
  23674. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23675. * @param kind defines the data kind (Position, normal, etc...)
  23676. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23677. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23678. * @returns a float array containing vertex data
  23679. */
  23680. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23681. /**
  23682. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23683. * @param kind defines the data kind (Position, normal, etc...)
  23684. * @returns true if the vertex buffer with the specified kind is updatable
  23685. */
  23686. isVertexBufferUpdatable(kind: string): boolean;
  23687. /**
  23688. * Gets a specific vertex buffer
  23689. * @param kind defines the data kind (Position, normal, etc...)
  23690. * @returns a VertexBuffer
  23691. */
  23692. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23693. /**
  23694. * Returns all vertex buffers
  23695. * @return an object holding all vertex buffers indexed by kind
  23696. */
  23697. getVertexBuffers(): Nullable<{
  23698. [key: string]: VertexBuffer;
  23699. }>;
  23700. /**
  23701. * Gets a boolean indicating if specific vertex buffer is present
  23702. * @param kind defines the data kind (Position, normal, etc...)
  23703. * @returns true if data is present
  23704. */
  23705. isVerticesDataPresent(kind: string): boolean;
  23706. /**
  23707. * Gets a list of all attached data kinds (Position, normal, etc...)
  23708. * @returns a list of string containing all kinds
  23709. */
  23710. getVerticesDataKinds(): string[];
  23711. /**
  23712. * Update index buffer
  23713. * @param indices defines the indices to store in the index buffer
  23714. * @param offset defines the offset in the target buffer where to store the data
  23715. * @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)
  23716. */
  23717. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23718. /**
  23719. * Creates a new index buffer
  23720. * @param indices defines the indices to store in the index buffer
  23721. * @param totalVertices defines the total number of vertices (could be null)
  23722. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23723. */
  23724. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23725. /**
  23726. * Return the total number of indices
  23727. * @returns the total number of indices
  23728. */
  23729. getTotalIndices(): number;
  23730. /**
  23731. * Gets the index buffer array
  23732. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23733. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23734. * @returns the index buffer array
  23735. */
  23736. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23737. /**
  23738. * Gets the index buffer
  23739. * @return the index buffer
  23740. */
  23741. getIndexBuffer(): Nullable<DataBuffer>;
  23742. /** @hidden */
  23743. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23744. /**
  23745. * Release the associated resources for a specific mesh
  23746. * @param mesh defines the source mesh
  23747. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23748. */
  23749. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23750. /**
  23751. * Apply current geometry to a given mesh
  23752. * @param mesh defines the mesh to apply geometry to
  23753. */
  23754. applyToMesh(mesh: Mesh): void;
  23755. private _updateExtend;
  23756. private _applyToMesh;
  23757. private notifyUpdate;
  23758. /**
  23759. * Load the geometry if it was flagged as delay loaded
  23760. * @param scene defines the hosting scene
  23761. * @param onLoaded defines a callback called when the geometry is loaded
  23762. */
  23763. load(scene: Scene, onLoaded?: () => void): void;
  23764. private _queueLoad;
  23765. /**
  23766. * Invert the geometry to move from a right handed system to a left handed one.
  23767. */
  23768. toLeftHanded(): void;
  23769. /** @hidden */
  23770. _resetPointsArrayCache(): void;
  23771. /** @hidden */
  23772. _generatePointsArray(): boolean;
  23773. /**
  23774. * Gets a value indicating if the geometry is disposed
  23775. * @returns true if the geometry was disposed
  23776. */
  23777. isDisposed(): boolean;
  23778. private _disposeVertexArrayObjects;
  23779. /**
  23780. * Free all associated resources
  23781. */
  23782. dispose(): void;
  23783. /**
  23784. * Clone the current geometry into a new geometry
  23785. * @param id defines the unique ID of the new geometry
  23786. * @returns a new geometry object
  23787. */
  23788. copy(id: string): Geometry;
  23789. /**
  23790. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23791. * @return a JSON representation of the current geometry data (without the vertices data)
  23792. */
  23793. serialize(): any;
  23794. private toNumberArray;
  23795. /**
  23796. * Serialize all vertices data into a JSON oject
  23797. * @returns a JSON representation of the current geometry data
  23798. */
  23799. serializeVerticeData(): any;
  23800. /**
  23801. * Extracts a clone of a mesh geometry
  23802. * @param mesh defines the source mesh
  23803. * @param id defines the unique ID of the new geometry object
  23804. * @returns the new geometry object
  23805. */
  23806. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23807. /**
  23808. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23809. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23810. * Be aware Math.random() could cause collisions, but:
  23811. * "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"
  23812. * @returns a string containing a new GUID
  23813. */
  23814. static RandomId(): string;
  23815. /** @hidden */
  23816. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23817. private static _CleanMatricesWeights;
  23818. /**
  23819. * Create a new geometry from persisted data (Using .babylon file format)
  23820. * @param parsedVertexData defines the persisted data
  23821. * @param scene defines the hosting scene
  23822. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23823. * @returns the new geometry object
  23824. */
  23825. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23826. }
  23827. }
  23828. declare module "babylonjs/Meshes/mesh.vertexData" {
  23829. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23830. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23831. import { Geometry } from "babylonjs/Meshes/geometry";
  23832. import { Mesh } from "babylonjs/Meshes/mesh";
  23833. /**
  23834. * Define an interface for all classes that will get and set the data on vertices
  23835. */
  23836. export interface IGetSetVerticesData {
  23837. /**
  23838. * Gets a boolean indicating if specific vertex data is present
  23839. * @param kind defines the vertex data kind to use
  23840. * @returns true is data kind is present
  23841. */
  23842. isVerticesDataPresent(kind: string): boolean;
  23843. /**
  23844. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23845. * @param kind defines the data kind (Position, normal, etc...)
  23846. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23847. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23848. * @returns a float array containing vertex data
  23849. */
  23850. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23851. /**
  23852. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23853. * @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.
  23854. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23855. * @returns the indices array or an empty array if the mesh has no geometry
  23856. */
  23857. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23858. /**
  23859. * Set specific vertex data
  23860. * @param kind defines the data kind (Position, normal, etc...)
  23861. * @param data defines the vertex data to use
  23862. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23863. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23864. */
  23865. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23866. /**
  23867. * Update a specific associated vertex buffer
  23868. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23869. * - VertexBuffer.PositionKind
  23870. * - VertexBuffer.UVKind
  23871. * - VertexBuffer.UV2Kind
  23872. * - VertexBuffer.UV3Kind
  23873. * - VertexBuffer.UV4Kind
  23874. * - VertexBuffer.UV5Kind
  23875. * - VertexBuffer.UV6Kind
  23876. * - VertexBuffer.ColorKind
  23877. * - VertexBuffer.MatricesIndicesKind
  23878. * - VertexBuffer.MatricesIndicesExtraKind
  23879. * - VertexBuffer.MatricesWeightsKind
  23880. * - VertexBuffer.MatricesWeightsExtraKind
  23881. * @param data defines the data source
  23882. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23883. * @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)
  23884. */
  23885. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23886. /**
  23887. * Creates a new index buffer
  23888. * @param indices defines the indices to store in the index buffer
  23889. * @param totalVertices defines the total number of vertices (could be null)
  23890. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23891. */
  23892. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23893. }
  23894. /**
  23895. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23896. */
  23897. export class VertexData {
  23898. /**
  23899. * Mesh side orientation : usually the external or front surface
  23900. */
  23901. static readonly FRONTSIDE: number;
  23902. /**
  23903. * Mesh side orientation : usually the internal or back surface
  23904. */
  23905. static readonly BACKSIDE: number;
  23906. /**
  23907. * Mesh side orientation : both internal and external or front and back surfaces
  23908. */
  23909. static readonly DOUBLESIDE: number;
  23910. /**
  23911. * Mesh side orientation : by default, `FRONTSIDE`
  23912. */
  23913. static readonly DEFAULTSIDE: number;
  23914. /**
  23915. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23916. */
  23917. positions: Nullable<FloatArray>;
  23918. /**
  23919. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23920. */
  23921. normals: Nullable<FloatArray>;
  23922. /**
  23923. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23924. */
  23925. tangents: Nullable<FloatArray>;
  23926. /**
  23927. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23928. */
  23929. uvs: Nullable<FloatArray>;
  23930. /**
  23931. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23932. */
  23933. uvs2: Nullable<FloatArray>;
  23934. /**
  23935. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23936. */
  23937. uvs3: Nullable<FloatArray>;
  23938. /**
  23939. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23940. */
  23941. uvs4: Nullable<FloatArray>;
  23942. /**
  23943. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23944. */
  23945. uvs5: Nullable<FloatArray>;
  23946. /**
  23947. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23948. */
  23949. uvs6: Nullable<FloatArray>;
  23950. /**
  23951. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23952. */
  23953. colors: Nullable<FloatArray>;
  23954. /**
  23955. * 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).
  23956. */
  23957. matricesIndices: Nullable<FloatArray>;
  23958. /**
  23959. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23960. */
  23961. matricesWeights: Nullable<FloatArray>;
  23962. /**
  23963. * An array extending the number of possible indices
  23964. */
  23965. matricesIndicesExtra: Nullable<FloatArray>;
  23966. /**
  23967. * An array extending the number of possible weights when the number of indices is extended
  23968. */
  23969. matricesWeightsExtra: Nullable<FloatArray>;
  23970. /**
  23971. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23972. */
  23973. indices: Nullable<IndicesArray>;
  23974. /**
  23975. * Uses the passed data array to set the set the values for the specified kind of data
  23976. * @param data a linear array of floating numbers
  23977. * @param kind the type of data that is being set, eg positions, colors etc
  23978. */
  23979. set(data: FloatArray, kind: string): void;
  23980. /**
  23981. * Associates the vertexData to the passed Mesh.
  23982. * Sets it as updatable or not (default `false`)
  23983. * @param mesh the mesh the vertexData is applied to
  23984. * @param updatable when used and having the value true allows new data to update the vertexData
  23985. * @returns the VertexData
  23986. */
  23987. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23988. /**
  23989. * Associates the vertexData to the passed Geometry.
  23990. * Sets it as updatable or not (default `false`)
  23991. * @param geometry the geometry the vertexData is applied to
  23992. * @param updatable when used and having the value true allows new data to update the vertexData
  23993. * @returns VertexData
  23994. */
  23995. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23996. /**
  23997. * Updates the associated mesh
  23998. * @param mesh the mesh to be updated
  23999. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24000. * @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
  24001. * @returns VertexData
  24002. */
  24003. updateMesh(mesh: Mesh): VertexData;
  24004. /**
  24005. * Updates the associated geometry
  24006. * @param geometry the geometry to be updated
  24007. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24008. * @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
  24009. * @returns VertexData.
  24010. */
  24011. updateGeometry(geometry: Geometry): VertexData;
  24012. private _applyTo;
  24013. private _update;
  24014. /**
  24015. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24016. * @param matrix the transforming matrix
  24017. * @returns the VertexData
  24018. */
  24019. transform(matrix: Matrix): VertexData;
  24020. /**
  24021. * Merges the passed VertexData into the current one
  24022. * @param other the VertexData to be merged into the current one
  24023. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24024. * @returns the modified VertexData
  24025. */
  24026. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24027. private _mergeElement;
  24028. private _validate;
  24029. /**
  24030. * Serializes the VertexData
  24031. * @returns a serialized object
  24032. */
  24033. serialize(): any;
  24034. /**
  24035. * Extracts the vertexData from a mesh
  24036. * @param mesh the mesh from which to extract the VertexData
  24037. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24038. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24039. * @returns the object VertexData associated to the passed mesh
  24040. */
  24041. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24042. /**
  24043. * Extracts the vertexData from the geometry
  24044. * @param geometry the geometry from which to extract the VertexData
  24045. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24046. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24047. * @returns the object VertexData associated to the passed mesh
  24048. */
  24049. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24050. private static _ExtractFrom;
  24051. /**
  24052. * Creates the VertexData for a Ribbon
  24053. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24054. * * pathArray array of paths, each of which an array of successive Vector3
  24055. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24056. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24057. * * 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
  24058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24059. * * 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)
  24060. * * 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)
  24061. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24062. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24063. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24064. * @returns the VertexData of the ribbon
  24065. */
  24066. static CreateRibbon(options: {
  24067. pathArray: Vector3[][];
  24068. closeArray?: boolean;
  24069. closePath?: boolean;
  24070. offset?: number;
  24071. sideOrientation?: number;
  24072. frontUVs?: Vector4;
  24073. backUVs?: Vector4;
  24074. invertUV?: boolean;
  24075. uvs?: Vector2[];
  24076. colors?: Color4[];
  24077. }): VertexData;
  24078. /**
  24079. * Creates the VertexData for a box
  24080. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24081. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24082. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24083. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24084. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24085. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24086. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24087. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24088. * * 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)
  24089. * * 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)
  24090. * @returns the VertexData of the box
  24091. */
  24092. static CreateBox(options: {
  24093. size?: number;
  24094. width?: number;
  24095. height?: number;
  24096. depth?: number;
  24097. faceUV?: Vector4[];
  24098. faceColors?: Color4[];
  24099. sideOrientation?: number;
  24100. frontUVs?: Vector4;
  24101. backUVs?: Vector4;
  24102. }): VertexData;
  24103. /**
  24104. * Creates the VertexData for a tiled box
  24105. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24106. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24107. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24108. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24110. * @returns the VertexData of the box
  24111. */
  24112. static CreateTiledBox(options: {
  24113. pattern?: number;
  24114. width?: number;
  24115. height?: number;
  24116. depth?: number;
  24117. tileSize?: number;
  24118. tileWidth?: number;
  24119. tileHeight?: number;
  24120. alignHorizontal?: number;
  24121. alignVertical?: number;
  24122. faceUV?: Vector4[];
  24123. faceColors?: Color4[];
  24124. sideOrientation?: number;
  24125. }): VertexData;
  24126. /**
  24127. * Creates the VertexData for a tiled plane
  24128. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24129. * * pattern a limited pattern arrangement depending on the number
  24130. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24131. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24132. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24134. * * 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)
  24135. * * 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)
  24136. * @returns the VertexData of the tiled plane
  24137. */
  24138. static CreateTiledPlane(options: {
  24139. pattern?: number;
  24140. tileSize?: number;
  24141. tileWidth?: number;
  24142. tileHeight?: number;
  24143. size?: number;
  24144. width?: number;
  24145. height?: number;
  24146. alignHorizontal?: number;
  24147. alignVertical?: number;
  24148. sideOrientation?: number;
  24149. frontUVs?: Vector4;
  24150. backUVs?: Vector4;
  24151. }): VertexData;
  24152. /**
  24153. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24155. * * segments sets the number of horizontal strips optional, default 32
  24156. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24157. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24158. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24159. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24160. * * 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
  24161. * * 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
  24162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24163. * * 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)
  24164. * * 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)
  24165. * @returns the VertexData of the ellipsoid
  24166. */
  24167. static CreateSphere(options: {
  24168. segments?: number;
  24169. diameter?: number;
  24170. diameterX?: number;
  24171. diameterY?: number;
  24172. diameterZ?: number;
  24173. arc?: number;
  24174. slice?: number;
  24175. sideOrientation?: number;
  24176. frontUVs?: Vector4;
  24177. backUVs?: Vector4;
  24178. }): VertexData;
  24179. /**
  24180. * Creates the VertexData for a cylinder, cone or prism
  24181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24182. * * height sets the height (y direction) of the cylinder, optional, default 2
  24183. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24184. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24185. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24186. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24187. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24188. * * 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
  24189. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24190. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24191. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24192. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24194. * * 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)
  24195. * * 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)
  24196. * @returns the VertexData of the cylinder, cone or prism
  24197. */
  24198. static CreateCylinder(options: {
  24199. height?: number;
  24200. diameterTop?: number;
  24201. diameterBottom?: number;
  24202. diameter?: number;
  24203. tessellation?: number;
  24204. subdivisions?: number;
  24205. arc?: number;
  24206. faceColors?: Color4[];
  24207. faceUV?: Vector4[];
  24208. hasRings?: boolean;
  24209. enclose?: boolean;
  24210. sideOrientation?: number;
  24211. frontUVs?: Vector4;
  24212. backUVs?: Vector4;
  24213. }): VertexData;
  24214. /**
  24215. * Creates the VertexData for a torus
  24216. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24217. * * diameter the diameter of the torus, optional default 1
  24218. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24219. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24221. * * 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)
  24222. * * 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)
  24223. * @returns the VertexData of the torus
  24224. */
  24225. static CreateTorus(options: {
  24226. diameter?: number;
  24227. thickness?: number;
  24228. tessellation?: number;
  24229. sideOrientation?: number;
  24230. frontUVs?: Vector4;
  24231. backUVs?: Vector4;
  24232. }): VertexData;
  24233. /**
  24234. * Creates the VertexData of the LineSystem
  24235. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24236. * - lines an array of lines, each line being an array of successive Vector3
  24237. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24238. * @returns the VertexData of the LineSystem
  24239. */
  24240. static CreateLineSystem(options: {
  24241. lines: Vector3[][];
  24242. colors?: Nullable<Color4[][]>;
  24243. }): VertexData;
  24244. /**
  24245. * Create the VertexData for a DashedLines
  24246. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24247. * - points an array successive Vector3
  24248. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24249. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24250. * - dashNb the intended total number of dashes, optional, default 200
  24251. * @returns the VertexData for the DashedLines
  24252. */
  24253. static CreateDashedLines(options: {
  24254. points: Vector3[];
  24255. dashSize?: number;
  24256. gapSize?: number;
  24257. dashNb?: number;
  24258. }): VertexData;
  24259. /**
  24260. * Creates the VertexData for a Ground
  24261. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24262. * - width the width (x direction) of the ground, optional, default 1
  24263. * - height the height (z direction) of the ground, optional, default 1
  24264. * - subdivisions the number of subdivisions per side, optional, default 1
  24265. * @returns the VertexData of the Ground
  24266. */
  24267. static CreateGround(options: {
  24268. width?: number;
  24269. height?: number;
  24270. subdivisions?: number;
  24271. subdivisionsX?: number;
  24272. subdivisionsY?: number;
  24273. }): VertexData;
  24274. /**
  24275. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24276. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24277. * * xmin the ground minimum X coordinate, optional, default -1
  24278. * * zmin the ground minimum Z coordinate, optional, default -1
  24279. * * xmax the ground maximum X coordinate, optional, default 1
  24280. * * zmax the ground maximum Z coordinate, optional, default 1
  24281. * * 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}
  24282. * * 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}
  24283. * @returns the VertexData of the TiledGround
  24284. */
  24285. static CreateTiledGround(options: {
  24286. xmin: number;
  24287. zmin: number;
  24288. xmax: number;
  24289. zmax: number;
  24290. subdivisions?: {
  24291. w: number;
  24292. h: number;
  24293. };
  24294. precision?: {
  24295. w: number;
  24296. h: number;
  24297. };
  24298. }): VertexData;
  24299. /**
  24300. * Creates the VertexData of the Ground designed from a heightmap
  24301. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24302. * * width the width (x direction) of the ground
  24303. * * height the height (z direction) of the ground
  24304. * * subdivisions the number of subdivisions per side
  24305. * * minHeight the minimum altitude on the ground, optional, default 0
  24306. * * maxHeight the maximum altitude on the ground, optional default 1
  24307. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24308. * * buffer the array holding the image color data
  24309. * * bufferWidth the width of image
  24310. * * bufferHeight the height of image
  24311. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24312. * @returns the VertexData of the Ground designed from a heightmap
  24313. */
  24314. static CreateGroundFromHeightMap(options: {
  24315. width: number;
  24316. height: number;
  24317. subdivisions: number;
  24318. minHeight: number;
  24319. maxHeight: number;
  24320. colorFilter: Color3;
  24321. buffer: Uint8Array;
  24322. bufferWidth: number;
  24323. bufferHeight: number;
  24324. alphaFilter: number;
  24325. }): VertexData;
  24326. /**
  24327. * Creates the VertexData for a Plane
  24328. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24329. * * size sets the width and height of the plane to the value of size, optional default 1
  24330. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24331. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24333. * * 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)
  24334. * * 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)
  24335. * @returns the VertexData of the box
  24336. */
  24337. static CreatePlane(options: {
  24338. size?: number;
  24339. width?: number;
  24340. height?: number;
  24341. sideOrientation?: number;
  24342. frontUVs?: Vector4;
  24343. backUVs?: Vector4;
  24344. }): VertexData;
  24345. /**
  24346. * Creates the VertexData of the Disc or regular Polygon
  24347. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24348. * * radius the radius of the disc, optional default 0.5
  24349. * * tessellation the number of polygon sides, optional, default 64
  24350. * * 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
  24351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24352. * * 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)
  24353. * * 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)
  24354. * @returns the VertexData of the box
  24355. */
  24356. static CreateDisc(options: {
  24357. radius?: number;
  24358. tessellation?: number;
  24359. arc?: number;
  24360. sideOrientation?: number;
  24361. frontUVs?: Vector4;
  24362. backUVs?: Vector4;
  24363. }): VertexData;
  24364. /**
  24365. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24366. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24367. * @param polygon a mesh built from polygonTriangulation.build()
  24368. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24369. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24370. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24371. * @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)
  24372. * @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)
  24373. * @returns the VertexData of the Polygon
  24374. */
  24375. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24376. /**
  24377. * Creates the VertexData of the IcoSphere
  24378. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24379. * * radius the radius of the IcoSphere, optional default 1
  24380. * * radiusX allows stretching in the x direction, optional, default radius
  24381. * * radiusY allows stretching in the y direction, optional, default radius
  24382. * * radiusZ allows stretching in the z direction, optional, default radius
  24383. * * flat when true creates a flat shaded mesh, optional, default true
  24384. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24386. * * 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)
  24387. * * 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)
  24388. * @returns the VertexData of the IcoSphere
  24389. */
  24390. static CreateIcoSphere(options: {
  24391. radius?: number;
  24392. radiusX?: number;
  24393. radiusY?: number;
  24394. radiusZ?: number;
  24395. flat?: boolean;
  24396. subdivisions?: number;
  24397. sideOrientation?: number;
  24398. frontUVs?: Vector4;
  24399. backUVs?: Vector4;
  24400. }): VertexData;
  24401. /**
  24402. * Creates the VertexData for a Polyhedron
  24403. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24404. * * type provided types are:
  24405. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24406. * * 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)
  24407. * * size the size of the IcoSphere, optional default 1
  24408. * * sizeX allows stretching in the x direction, optional, default size
  24409. * * sizeY allows stretching in the y direction, optional, default size
  24410. * * sizeZ allows stretching in the z direction, optional, default size
  24411. * * 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
  24412. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24413. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24414. * * flat when true creates a flat shaded mesh, optional, default true
  24415. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24417. * * 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)
  24418. * * 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)
  24419. * @returns the VertexData of the Polyhedron
  24420. */
  24421. static CreatePolyhedron(options: {
  24422. type?: number;
  24423. size?: number;
  24424. sizeX?: number;
  24425. sizeY?: number;
  24426. sizeZ?: number;
  24427. custom?: any;
  24428. faceUV?: Vector4[];
  24429. faceColors?: Color4[];
  24430. flat?: boolean;
  24431. sideOrientation?: number;
  24432. frontUVs?: Vector4;
  24433. backUVs?: Vector4;
  24434. }): VertexData;
  24435. /**
  24436. * Creates the VertexData for a TorusKnot
  24437. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24438. * * radius the radius of the torus knot, optional, default 2
  24439. * * tube the thickness of the tube, optional, default 0.5
  24440. * * radialSegments the number of sides on each tube segments, optional, default 32
  24441. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24442. * * p the number of windings around the z axis, optional, default 2
  24443. * * q the number of windings around the x axis, optional, default 3
  24444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24445. * * 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)
  24446. * * 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)
  24447. * @returns the VertexData of the Torus Knot
  24448. */
  24449. static CreateTorusKnot(options: {
  24450. radius?: number;
  24451. tube?: number;
  24452. radialSegments?: number;
  24453. tubularSegments?: number;
  24454. p?: number;
  24455. q?: number;
  24456. sideOrientation?: number;
  24457. frontUVs?: Vector4;
  24458. backUVs?: Vector4;
  24459. }): VertexData;
  24460. /**
  24461. * Compute normals for given positions and indices
  24462. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24463. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24464. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24465. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24466. * * facetNormals : optional array of facet normals (vector3)
  24467. * * facetPositions : optional array of facet positions (vector3)
  24468. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24469. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24470. * * bInfo : optional bounding info, required for facetPartitioning computation
  24471. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24472. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24473. * * useRightHandedSystem: optional boolean to for right handed system computation
  24474. * * depthSort : optional boolean to enable the facet depth sort computation
  24475. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24476. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24477. */
  24478. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24479. facetNormals?: any;
  24480. facetPositions?: any;
  24481. facetPartitioning?: any;
  24482. ratio?: number;
  24483. bInfo?: any;
  24484. bbSize?: Vector3;
  24485. subDiv?: any;
  24486. useRightHandedSystem?: boolean;
  24487. depthSort?: boolean;
  24488. distanceTo?: Vector3;
  24489. depthSortedFacets?: any;
  24490. }): void;
  24491. /** @hidden */
  24492. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24493. /**
  24494. * Applies VertexData created from the imported parameters to the geometry
  24495. * @param parsedVertexData the parsed data from an imported file
  24496. * @param geometry the geometry to apply the VertexData to
  24497. */
  24498. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24499. }
  24500. }
  24501. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24502. import { Nullable } from "babylonjs/types";
  24503. import { Scene } from "babylonjs/scene";
  24504. import { Vector4 } from "babylonjs/Maths/math";
  24505. import { Mesh } from "babylonjs/Meshes/mesh";
  24506. /**
  24507. * Class containing static functions to help procedurally build meshes
  24508. */
  24509. export class DiscBuilder {
  24510. /**
  24511. * Creates a plane polygonal mesh. By default, this is a disc
  24512. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24513. * * 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
  24514. * * 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
  24515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24518. * @param name defines the name of the mesh
  24519. * @param options defines the options used to create the mesh
  24520. * @param scene defines the hosting scene
  24521. * @returns the plane polygonal mesh
  24522. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24523. */
  24524. static CreateDisc(name: string, options: {
  24525. radius?: number;
  24526. tessellation?: number;
  24527. arc?: number;
  24528. updatable?: boolean;
  24529. sideOrientation?: number;
  24530. frontUVs?: Vector4;
  24531. backUVs?: Vector4;
  24532. }, scene?: Nullable<Scene>): Mesh;
  24533. }
  24534. }
  24535. declare module "babylonjs/Particles/solidParticleSystem" {
  24536. import { Vector3 } from "babylonjs/Maths/math";
  24537. import { Mesh } from "babylonjs/Meshes/mesh";
  24538. import { Scene, IDisposable } from "babylonjs/scene";
  24539. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24540. /**
  24541. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24542. *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.
  24543. * The SPS is also a particle system. It provides some methods to manage the particles.
  24544. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24545. *
  24546. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24547. */
  24548. export class SolidParticleSystem implements IDisposable {
  24549. /**
  24550. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24551. * Example : var p = SPS.particles[i];
  24552. */
  24553. particles: SolidParticle[];
  24554. /**
  24555. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24556. */
  24557. nbParticles: number;
  24558. /**
  24559. * If the particles must ever face the camera (default false). Useful for planar particles.
  24560. */
  24561. billboard: boolean;
  24562. /**
  24563. * Recompute normals when adding a shape
  24564. */
  24565. recomputeNormals: boolean;
  24566. /**
  24567. * This a counter ofr your own usage. It's not set by any SPS functions.
  24568. */
  24569. counter: number;
  24570. /**
  24571. * The SPS name. This name is also given to the underlying mesh.
  24572. */
  24573. name: string;
  24574. /**
  24575. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24576. */
  24577. mesh: Mesh;
  24578. /**
  24579. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24580. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24581. */
  24582. vars: any;
  24583. /**
  24584. * This array is populated when the SPS is set as 'pickable'.
  24585. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24586. * Each element of this array is an object `{idx: int, faceId: int}`.
  24587. * `idx` is the picked particle index in the `SPS.particles` array
  24588. * `faceId` is the picked face index counted within this particle.
  24589. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24590. */
  24591. pickedParticles: {
  24592. idx: number;
  24593. faceId: number;
  24594. }[];
  24595. /**
  24596. * This array is populated when `enableDepthSort` is set to true.
  24597. * Each element of this array is an instance of the class DepthSortedParticle.
  24598. */
  24599. depthSortedParticles: DepthSortedParticle[];
  24600. /**
  24601. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24602. * @hidden
  24603. */
  24604. _bSphereOnly: boolean;
  24605. /**
  24606. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24607. * @hidden
  24608. */
  24609. _bSphereRadiusFactor: number;
  24610. private _scene;
  24611. private _positions;
  24612. private _indices;
  24613. private _normals;
  24614. private _colors;
  24615. private _uvs;
  24616. private _indices32;
  24617. private _positions32;
  24618. private _normals32;
  24619. private _fixedNormal32;
  24620. private _colors32;
  24621. private _uvs32;
  24622. private _index;
  24623. private _updatable;
  24624. private _pickable;
  24625. private _isVisibilityBoxLocked;
  24626. private _alwaysVisible;
  24627. private _depthSort;
  24628. private _shapeCounter;
  24629. private _copy;
  24630. private _color;
  24631. private _computeParticleColor;
  24632. private _computeParticleTexture;
  24633. private _computeParticleRotation;
  24634. private _computeParticleVertex;
  24635. private _computeBoundingBox;
  24636. private _depthSortParticles;
  24637. private _camera;
  24638. private _mustUnrotateFixedNormals;
  24639. private _particlesIntersect;
  24640. private _needs32Bits;
  24641. /**
  24642. * Creates a SPS (Solid Particle System) object.
  24643. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24644. * @param scene (Scene) is the scene in which the SPS is added.
  24645. * @param options defines the options of the sps e.g.
  24646. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24647. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24648. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24649. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24650. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24651. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24652. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24653. */
  24654. constructor(name: string, scene: Scene, options?: {
  24655. updatable?: boolean;
  24656. isPickable?: boolean;
  24657. enableDepthSort?: boolean;
  24658. particleIntersection?: boolean;
  24659. boundingSphereOnly?: boolean;
  24660. bSphereRadiusFactor?: number;
  24661. });
  24662. /**
  24663. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24664. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24665. * @returns the created mesh
  24666. */
  24667. buildMesh(): Mesh;
  24668. /**
  24669. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24670. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24671. * Thus the particles generated from `digest()` have their property `position` set yet.
  24672. * @param mesh ( Mesh ) is the mesh to be digested
  24673. * @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
  24674. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24675. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24676. * @returns the current SPS
  24677. */
  24678. digest(mesh: Mesh, options?: {
  24679. facetNb?: number;
  24680. number?: number;
  24681. delta?: number;
  24682. }): SolidParticleSystem;
  24683. private _unrotateFixedNormals;
  24684. private _resetCopy;
  24685. private _meshBuilder;
  24686. private _posToShape;
  24687. private _uvsToShapeUV;
  24688. private _addParticle;
  24689. /**
  24690. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24691. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24692. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24693. * @param nb (positive integer) the number of particles to be created from this model
  24694. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24695. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24696. * @returns the number of shapes in the system
  24697. */
  24698. addShape(mesh: Mesh, nb: number, options?: {
  24699. positionFunction?: any;
  24700. vertexFunction?: any;
  24701. }): number;
  24702. private _rebuildParticle;
  24703. /**
  24704. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24705. * @returns the SPS.
  24706. */
  24707. rebuildMesh(): SolidParticleSystem;
  24708. /**
  24709. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24710. * This method calls `updateParticle()` for each particle of the SPS.
  24711. * For an animated SPS, it is usually called within the render loop.
  24712. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24713. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24714. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24715. * @returns the SPS.
  24716. */
  24717. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24718. /**
  24719. * Disposes the SPS.
  24720. */
  24721. dispose(): void;
  24722. /**
  24723. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24724. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24725. * @returns the SPS.
  24726. */
  24727. refreshVisibleSize(): SolidParticleSystem;
  24728. /**
  24729. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24730. * @param size the size (float) of the visibility box
  24731. * note : this doesn't lock the SPS mesh bounding box.
  24732. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24733. */
  24734. setVisibilityBox(size: number): void;
  24735. /**
  24736. * Gets whether the SPS as always visible or not
  24737. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24738. */
  24739. /**
  24740. * Sets the SPS as always visible or not
  24741. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24742. */
  24743. isAlwaysVisible: boolean;
  24744. /**
  24745. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24746. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24747. */
  24748. /**
  24749. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24750. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24751. */
  24752. isVisibilityBoxLocked: boolean;
  24753. /**
  24754. * Tells to `setParticles()` to compute the particle rotations or not.
  24755. * Default value : true. The SPS is faster when it's set to false.
  24756. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24757. */
  24758. /**
  24759. * Gets if `setParticles()` computes the particle rotations or not.
  24760. * Default value : true. The SPS is faster when it's set to false.
  24761. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24762. */
  24763. computeParticleRotation: boolean;
  24764. /**
  24765. * Tells to `setParticles()` to compute the particle colors or not.
  24766. * Default value : true. The SPS is faster when it's set to false.
  24767. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24768. */
  24769. /**
  24770. * Gets if `setParticles()` computes the particle colors or not.
  24771. * Default value : true. The SPS is faster when it's set to false.
  24772. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24773. */
  24774. computeParticleColor: boolean;
  24775. /**
  24776. * Gets if `setParticles()` computes the particle textures or not.
  24777. * Default value : true. The SPS is faster when it's set to false.
  24778. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24779. */
  24780. computeParticleTexture: boolean;
  24781. /**
  24782. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24783. * Default value : false. The SPS is faster when it's set to false.
  24784. * Note : the particle custom vertex positions aren't stored values.
  24785. */
  24786. /**
  24787. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24788. * Default value : false. The SPS is faster when it's set to false.
  24789. * Note : the particle custom vertex positions aren't stored values.
  24790. */
  24791. computeParticleVertex: boolean;
  24792. /**
  24793. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24794. */
  24795. /**
  24796. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24797. */
  24798. computeBoundingBox: boolean;
  24799. /**
  24800. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24801. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24802. * Default : `true`
  24803. */
  24804. /**
  24805. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24806. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24807. * Default : `true`
  24808. */
  24809. depthSortParticles: boolean;
  24810. /**
  24811. * This function does nothing. It may be overwritten to set all the particle first values.
  24812. * The SPS doesn't call this function, you may have to call it by your own.
  24813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24814. */
  24815. initParticles(): void;
  24816. /**
  24817. * This function does nothing. It may be overwritten to recycle a particle.
  24818. * The SPS doesn't call this function, you may have to call it by your own.
  24819. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24820. * @param particle The particle to recycle
  24821. * @returns the recycled particle
  24822. */
  24823. recycleParticle(particle: SolidParticle): SolidParticle;
  24824. /**
  24825. * Updates a particle : this function should be overwritten by the user.
  24826. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24827. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24828. * @example : just set a particle position or velocity and recycle conditions
  24829. * @param particle The particle to update
  24830. * @returns the updated particle
  24831. */
  24832. updateParticle(particle: SolidParticle): SolidParticle;
  24833. /**
  24834. * Updates a vertex of a particle : it can be overwritten by the user.
  24835. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24836. * @param particle the current particle
  24837. * @param vertex the current index of the current particle
  24838. * @param pt the index of the current vertex in the particle shape
  24839. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24840. * @example : just set a vertex particle position
  24841. * @returns the updated vertex
  24842. */
  24843. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24844. /**
  24845. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24846. * This does nothing and may be overwritten by the user.
  24847. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24848. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24849. * @param update the boolean update value actually passed to setParticles()
  24850. */
  24851. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24852. /**
  24853. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24854. * This will be passed three parameters.
  24855. * This does nothing and may be overwritten by the user.
  24856. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24857. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24858. * @param update the boolean update value actually passed to setParticles()
  24859. */
  24860. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24861. }
  24862. }
  24863. declare module "babylonjs/Particles/solidParticle" {
  24864. import { Nullable } from "babylonjs/types";
  24865. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24866. import { Mesh } from "babylonjs/Meshes/mesh";
  24867. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24868. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24869. /**
  24870. * Represents one particle of a solid particle system.
  24871. */
  24872. export class SolidParticle {
  24873. /**
  24874. * particle global index
  24875. */
  24876. idx: number;
  24877. /**
  24878. * The color of the particle
  24879. */
  24880. color: Nullable<Color4>;
  24881. /**
  24882. * The world space position of the particle.
  24883. */
  24884. position: Vector3;
  24885. /**
  24886. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24887. */
  24888. rotation: Vector3;
  24889. /**
  24890. * The world space rotation quaternion of the particle.
  24891. */
  24892. rotationQuaternion: Nullable<Quaternion>;
  24893. /**
  24894. * The scaling of the particle.
  24895. */
  24896. scaling: Vector3;
  24897. /**
  24898. * The uvs of the particle.
  24899. */
  24900. uvs: Vector4;
  24901. /**
  24902. * The current speed of the particle.
  24903. */
  24904. velocity: Vector3;
  24905. /**
  24906. * The pivot point in the particle local space.
  24907. */
  24908. pivot: Vector3;
  24909. /**
  24910. * Must the particle be translated from its pivot point in its local space ?
  24911. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24912. * Default : false
  24913. */
  24914. translateFromPivot: boolean;
  24915. /**
  24916. * Is the particle active or not ?
  24917. */
  24918. alive: boolean;
  24919. /**
  24920. * Is the particle visible or not ?
  24921. */
  24922. isVisible: boolean;
  24923. /**
  24924. * Index of this particle in the global "positions" array (Internal use)
  24925. * @hidden
  24926. */
  24927. _pos: number;
  24928. /**
  24929. * @hidden Index of this particle in the global "indices" array (Internal use)
  24930. */
  24931. _ind: number;
  24932. /**
  24933. * @hidden ModelShape of this particle (Internal use)
  24934. */
  24935. _model: ModelShape;
  24936. /**
  24937. * ModelShape id of this particle
  24938. */
  24939. shapeId: number;
  24940. /**
  24941. * Index of the particle in its shape id (Internal use)
  24942. */
  24943. idxInShape: number;
  24944. /**
  24945. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24946. */
  24947. _modelBoundingInfo: BoundingInfo;
  24948. /**
  24949. * @hidden Particle BoundingInfo object (Internal use)
  24950. */
  24951. _boundingInfo: BoundingInfo;
  24952. /**
  24953. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24954. */
  24955. _sps: SolidParticleSystem;
  24956. /**
  24957. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24958. */
  24959. _stillInvisible: boolean;
  24960. /**
  24961. * @hidden Last computed particle rotation matrix
  24962. */
  24963. _rotationMatrix: number[];
  24964. /**
  24965. * Parent particle Id, if any.
  24966. * Default null.
  24967. */
  24968. parentId: Nullable<number>;
  24969. /**
  24970. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24971. * The possible values are :
  24972. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24973. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24974. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24975. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24976. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24977. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24978. * */
  24979. cullingStrategy: number;
  24980. /**
  24981. * @hidden Internal global position in the SPS.
  24982. */
  24983. _globalPosition: Vector3;
  24984. /**
  24985. * Creates a Solid Particle object.
  24986. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24987. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24988. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24989. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24990. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24991. * @param shapeId (integer) is the model shape identifier in the SPS.
  24992. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24993. * @param sps defines the sps it is associated to
  24994. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24995. */
  24996. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24997. /**
  24998. * Legacy support, changed scale to scaling
  24999. */
  25000. /**
  25001. * Legacy support, changed scale to scaling
  25002. */
  25003. scale: Vector3;
  25004. /**
  25005. * Legacy support, changed quaternion to rotationQuaternion
  25006. */
  25007. /**
  25008. * Legacy support, changed quaternion to rotationQuaternion
  25009. */
  25010. quaternion: Nullable<Quaternion>;
  25011. /**
  25012. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25013. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25014. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25015. * @returns true if it intersects
  25016. */
  25017. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25018. /**
  25019. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25020. * A particle is in the frustum if its bounding box intersects the frustum
  25021. * @param frustumPlanes defines the frustum to test
  25022. * @returns true if the particle is in the frustum planes
  25023. */
  25024. isInFrustum(frustumPlanes: Plane[]): boolean;
  25025. /**
  25026. * get the rotation matrix of the particle
  25027. * @hidden
  25028. */
  25029. getRotationMatrix(m: Matrix): void;
  25030. }
  25031. /**
  25032. * Represents the shape of the model used by one particle of a solid particle system.
  25033. * SPS internal tool, don't use it manually.
  25034. */
  25035. export class ModelShape {
  25036. /**
  25037. * The shape id
  25038. * @hidden
  25039. */
  25040. shapeID: number;
  25041. /**
  25042. * flat array of model positions (internal use)
  25043. * @hidden
  25044. */
  25045. _shape: Vector3[];
  25046. /**
  25047. * flat array of model UVs (internal use)
  25048. * @hidden
  25049. */
  25050. _shapeUV: number[];
  25051. /**
  25052. * length of the shape in the model indices array (internal use)
  25053. * @hidden
  25054. */
  25055. _indicesLength: number;
  25056. /**
  25057. * Custom position function (internal use)
  25058. * @hidden
  25059. */
  25060. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25061. /**
  25062. * Custom vertex function (internal use)
  25063. * @hidden
  25064. */
  25065. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25066. /**
  25067. * 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.
  25068. * SPS internal tool, don't use it manually.
  25069. * @hidden
  25070. */
  25071. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25072. }
  25073. /**
  25074. * Represents a Depth Sorted Particle in the solid particle system.
  25075. */
  25076. export class DepthSortedParticle {
  25077. /**
  25078. * Index of the particle in the "indices" array
  25079. */
  25080. ind: number;
  25081. /**
  25082. * Length of the particle shape in the "indices" array
  25083. */
  25084. indicesLength: number;
  25085. /**
  25086. * Squared distance from the particle to the camera
  25087. */
  25088. sqDistance: number;
  25089. }
  25090. }
  25091. declare module "babylonjs/Collisions/meshCollisionData" {
  25092. import { Collider } from "babylonjs/Collisions/collider";
  25093. import { Vector3 } from "babylonjs/Maths/math";
  25094. import { Nullable } from "babylonjs/types";
  25095. import { Observer } from "babylonjs/Misc/observable";
  25096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25097. /**
  25098. * @hidden
  25099. */
  25100. export class _MeshCollisionData {
  25101. _checkCollisions: boolean;
  25102. _collisionMask: number;
  25103. _collisionGroup: number;
  25104. _collider: Nullable<Collider>;
  25105. _oldPositionForCollisions: Vector3;
  25106. _diffPositionForCollisions: Vector3;
  25107. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25108. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25109. }
  25110. }
  25111. declare module "babylonjs/Meshes/abstractMesh" {
  25112. import { Observable } from "babylonjs/Misc/observable";
  25113. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25114. import { Camera } from "babylonjs/Cameras/camera";
  25115. import { Scene, IDisposable } from "babylonjs/scene";
  25116. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25117. import { Node } from "babylonjs/node";
  25118. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25119. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25120. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25121. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25122. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25123. import { Material } from "babylonjs/Materials/material";
  25124. import { Light } from "babylonjs/Lights/light";
  25125. import { Skeleton } from "babylonjs/Bones/skeleton";
  25126. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25127. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25129. import { Ray } from "babylonjs/Culling/ray";
  25130. import { Collider } from "babylonjs/Collisions/collider";
  25131. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25132. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25133. /** @hidden */
  25134. class _FacetDataStorage {
  25135. facetPositions: Vector3[];
  25136. facetNormals: Vector3[];
  25137. facetPartitioning: number[][];
  25138. facetNb: number;
  25139. partitioningSubdivisions: number;
  25140. partitioningBBoxRatio: number;
  25141. facetDataEnabled: boolean;
  25142. facetParameters: any;
  25143. bbSize: Vector3;
  25144. subDiv: {
  25145. max: number;
  25146. X: number;
  25147. Y: number;
  25148. Z: number;
  25149. };
  25150. facetDepthSort: boolean;
  25151. facetDepthSortEnabled: boolean;
  25152. depthSortedIndices: IndicesArray;
  25153. depthSortedFacets: {
  25154. ind: number;
  25155. sqDistance: number;
  25156. }[];
  25157. facetDepthSortFunction: (f1: {
  25158. ind: number;
  25159. sqDistance: number;
  25160. }, f2: {
  25161. ind: number;
  25162. sqDistance: number;
  25163. }) => number;
  25164. facetDepthSortFrom: Vector3;
  25165. facetDepthSortOrigin: Vector3;
  25166. invertedMatrix: Matrix;
  25167. }
  25168. /**
  25169. * @hidden
  25170. **/
  25171. class _InternalAbstractMeshDataInfo {
  25172. _hasVertexAlpha: boolean;
  25173. _useVertexColors: boolean;
  25174. _numBoneInfluencers: number;
  25175. _applyFog: boolean;
  25176. _receiveShadows: boolean;
  25177. _facetData: _FacetDataStorage;
  25178. _visibility: number;
  25179. _skeleton: Nullable<Skeleton>;
  25180. _layerMask: number;
  25181. _computeBonesUsingShaders: boolean;
  25182. _isActive: boolean;
  25183. _onlyForInstances: boolean;
  25184. _isActiveIntermediate: boolean;
  25185. _onlyForInstancesIntermediate: boolean;
  25186. }
  25187. /**
  25188. * Class used to store all common mesh properties
  25189. */
  25190. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25191. /** No occlusion */
  25192. static OCCLUSION_TYPE_NONE: number;
  25193. /** Occlusion set to optimisitic */
  25194. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25195. /** Occlusion set to strict */
  25196. static OCCLUSION_TYPE_STRICT: number;
  25197. /** Use an accurante occlusion algorithm */
  25198. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25199. /** Use a conservative occlusion algorithm */
  25200. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25201. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25202. * Test order :
  25203. * Is the bounding sphere outside the frustum ?
  25204. * If not, are the bounding box vertices outside the frustum ?
  25205. * It not, then the cullable object is in the frustum.
  25206. */
  25207. static readonly CULLINGSTRATEGY_STANDARD: number;
  25208. /** Culling strategy : Bounding Sphere Only.
  25209. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25210. * It's also less accurate than the standard because some not visible objects can still be selected.
  25211. * Test : is the bounding sphere outside the frustum ?
  25212. * If not, then the cullable object is in the frustum.
  25213. */
  25214. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25215. /** Culling strategy : Optimistic Inclusion.
  25216. * This in an inclusion test first, then the standard exclusion test.
  25217. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25218. * 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.
  25219. * Anyway, it's as accurate as the standard strategy.
  25220. * Test :
  25221. * Is the cullable object bounding sphere center in the frustum ?
  25222. * If not, apply the default culling strategy.
  25223. */
  25224. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25225. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25226. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25227. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25228. * 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.
  25229. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25230. * Test :
  25231. * Is the cullable object bounding sphere center in the frustum ?
  25232. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25233. */
  25234. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25235. /**
  25236. * No billboard
  25237. */
  25238. static readonly BILLBOARDMODE_NONE: number;
  25239. /** Billboard on X axis */
  25240. static readonly BILLBOARDMODE_X: number;
  25241. /** Billboard on Y axis */
  25242. static readonly BILLBOARDMODE_Y: number;
  25243. /** Billboard on Z axis */
  25244. static readonly BILLBOARDMODE_Z: number;
  25245. /** Billboard on all axes */
  25246. static readonly BILLBOARDMODE_ALL: number;
  25247. /** @hidden */
  25248. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25249. /**
  25250. * The culling strategy to use to check whether the mesh must be rendered or not.
  25251. * This value can be changed at any time and will be used on the next render mesh selection.
  25252. * The possible values are :
  25253. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25254. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25255. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25256. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25257. * Please read each static variable documentation to get details about the culling process.
  25258. * */
  25259. cullingStrategy: number;
  25260. /**
  25261. * Gets the number of facets in the mesh
  25262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25263. */
  25264. readonly facetNb: number;
  25265. /**
  25266. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25268. */
  25269. partitioningSubdivisions: number;
  25270. /**
  25271. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25272. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25274. */
  25275. partitioningBBoxRatio: number;
  25276. /**
  25277. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25278. * Works only for updatable meshes.
  25279. * Doesn't work with multi-materials
  25280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25281. */
  25282. mustDepthSortFacets: boolean;
  25283. /**
  25284. * The location (Vector3) where the facet depth sort must be computed from.
  25285. * By default, the active camera position.
  25286. * Used only when facet depth sort is enabled
  25287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25288. */
  25289. facetDepthSortFrom: Vector3;
  25290. /**
  25291. * gets a boolean indicating if facetData is enabled
  25292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25293. */
  25294. readonly isFacetDataEnabled: boolean;
  25295. /** @hidden */
  25296. _updateNonUniformScalingState(value: boolean): boolean;
  25297. /**
  25298. * An event triggered when this mesh collides with another one
  25299. */
  25300. onCollideObservable: Observable<AbstractMesh>;
  25301. /** Set a function to call when this mesh collides with another one */
  25302. onCollide: () => void;
  25303. /**
  25304. * An event triggered when the collision's position changes
  25305. */
  25306. onCollisionPositionChangeObservable: Observable<Vector3>;
  25307. /** Set a function to call when the collision's position changes */
  25308. onCollisionPositionChange: () => void;
  25309. /**
  25310. * An event triggered when material is changed
  25311. */
  25312. onMaterialChangedObservable: Observable<AbstractMesh>;
  25313. /**
  25314. * Gets or sets the orientation for POV movement & rotation
  25315. */
  25316. definedFacingForward: boolean;
  25317. /** @hidden */
  25318. _occlusionQuery: Nullable<WebGLQuery>;
  25319. /** @hidden */
  25320. _renderingGroup: Nullable<RenderingGroup>;
  25321. /**
  25322. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25323. */
  25324. /**
  25325. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25326. */
  25327. visibility: number;
  25328. /** Gets or sets the alpha index used to sort transparent meshes
  25329. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25330. */
  25331. alphaIndex: number;
  25332. /**
  25333. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25334. */
  25335. isVisible: boolean;
  25336. /**
  25337. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25338. */
  25339. isPickable: boolean;
  25340. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25341. showSubMeshesBoundingBox: boolean;
  25342. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25343. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25344. */
  25345. isBlocker: boolean;
  25346. /**
  25347. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25348. */
  25349. enablePointerMoveEvents: boolean;
  25350. /**
  25351. * Specifies the rendering group id for this mesh (0 by default)
  25352. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25353. */
  25354. renderingGroupId: number;
  25355. private _material;
  25356. /** Gets or sets current material */
  25357. material: Nullable<Material>;
  25358. /**
  25359. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25360. * @see http://doc.babylonjs.com/babylon101/shadows
  25361. */
  25362. receiveShadows: boolean;
  25363. /** Defines color to use when rendering outline */
  25364. outlineColor: Color3;
  25365. /** Define width to use when rendering outline */
  25366. outlineWidth: number;
  25367. /** Defines color to use when rendering overlay */
  25368. overlayColor: Color3;
  25369. /** Defines alpha to use when rendering overlay */
  25370. overlayAlpha: number;
  25371. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25372. hasVertexAlpha: boolean;
  25373. /** 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) */
  25374. useVertexColors: boolean;
  25375. /**
  25376. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25377. */
  25378. computeBonesUsingShaders: boolean;
  25379. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25380. numBoneInfluencers: number;
  25381. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25382. applyFog: boolean;
  25383. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25384. useOctreeForRenderingSelection: boolean;
  25385. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25386. useOctreeForPicking: boolean;
  25387. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25388. useOctreeForCollisions: boolean;
  25389. /**
  25390. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25391. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25392. */
  25393. layerMask: number;
  25394. /**
  25395. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25396. */
  25397. alwaysSelectAsActiveMesh: boolean;
  25398. /**
  25399. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25400. */
  25401. doNotSyncBoundingInfo: boolean;
  25402. /**
  25403. * Gets or sets the current action manager
  25404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25405. */
  25406. actionManager: Nullable<AbstractActionManager>;
  25407. private _meshCollisionData;
  25408. /**
  25409. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25411. */
  25412. ellipsoid: Vector3;
  25413. /**
  25414. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25416. */
  25417. ellipsoidOffset: Vector3;
  25418. /**
  25419. * Gets or sets a collision mask used to mask collisions (default is -1).
  25420. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25421. */
  25422. collisionMask: number;
  25423. /**
  25424. * Gets or sets the current collision group mask (-1 by default).
  25425. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25426. */
  25427. collisionGroup: number;
  25428. /**
  25429. * Defines edge width used when edgesRenderer is enabled
  25430. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25431. */
  25432. edgesWidth: number;
  25433. /**
  25434. * Defines edge color used when edgesRenderer is enabled
  25435. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25436. */
  25437. edgesColor: Color4;
  25438. /** @hidden */
  25439. _edgesRenderer: Nullable<IEdgesRenderer>;
  25440. /** @hidden */
  25441. _masterMesh: Nullable<AbstractMesh>;
  25442. /** @hidden */
  25443. _boundingInfo: Nullable<BoundingInfo>;
  25444. /** @hidden */
  25445. _renderId: number;
  25446. /**
  25447. * Gets or sets the list of subMeshes
  25448. * @see http://doc.babylonjs.com/how_to/multi_materials
  25449. */
  25450. subMeshes: SubMesh[];
  25451. /** @hidden */
  25452. _intersectionsInProgress: AbstractMesh[];
  25453. /** @hidden */
  25454. _unIndexed: boolean;
  25455. /** @hidden */
  25456. _lightSources: Light[];
  25457. /** Gets the list of lights affecting that mesh */
  25458. readonly lightSources: Light[];
  25459. /** @hidden */
  25460. readonly _positions: Nullable<Vector3[]>;
  25461. /** @hidden */
  25462. _waitingData: {
  25463. lods: Nullable<any>;
  25464. actions: Nullable<any>;
  25465. freezeWorldMatrix: Nullable<boolean>;
  25466. };
  25467. /** @hidden */
  25468. _bonesTransformMatrices: Nullable<Float32Array>;
  25469. /**
  25470. * Gets or sets a skeleton to apply skining transformations
  25471. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25472. */
  25473. skeleton: Nullable<Skeleton>;
  25474. /**
  25475. * An event triggered when the mesh is rebuilt.
  25476. */
  25477. onRebuildObservable: Observable<AbstractMesh>;
  25478. /**
  25479. * Creates a new AbstractMesh
  25480. * @param name defines the name of the mesh
  25481. * @param scene defines the hosting scene
  25482. */
  25483. constructor(name: string, scene?: Nullable<Scene>);
  25484. /**
  25485. * Returns the string "AbstractMesh"
  25486. * @returns "AbstractMesh"
  25487. */
  25488. getClassName(): string;
  25489. /**
  25490. * Gets a string representation of the current mesh
  25491. * @param fullDetails defines a boolean indicating if full details must be included
  25492. * @returns a string representation of the current mesh
  25493. */
  25494. toString(fullDetails?: boolean): string;
  25495. /**
  25496. * @hidden
  25497. */
  25498. protected _getEffectiveParent(): Nullable<Node>;
  25499. /** @hidden */
  25500. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25501. /** @hidden */
  25502. _rebuild(): void;
  25503. /** @hidden */
  25504. _resyncLightSources(): void;
  25505. /** @hidden */
  25506. _resyncLighSource(light: Light): void;
  25507. /** @hidden */
  25508. _unBindEffect(): void;
  25509. /** @hidden */
  25510. _removeLightSource(light: Light): void;
  25511. private _markSubMeshesAsDirty;
  25512. /** @hidden */
  25513. _markSubMeshesAsLightDirty(): void;
  25514. /** @hidden */
  25515. _markSubMeshesAsAttributesDirty(): void;
  25516. /** @hidden */
  25517. _markSubMeshesAsMiscDirty(): void;
  25518. /**
  25519. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25520. */
  25521. scaling: Vector3;
  25522. /**
  25523. * Returns true if the mesh is blocked. Implemented by child classes
  25524. */
  25525. readonly isBlocked: boolean;
  25526. /**
  25527. * Returns the mesh itself by default. Implemented by child classes
  25528. * @param camera defines the camera to use to pick the right LOD level
  25529. * @returns the currentAbstractMesh
  25530. */
  25531. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25532. /**
  25533. * Returns 0 by default. Implemented by child classes
  25534. * @returns an integer
  25535. */
  25536. getTotalVertices(): number;
  25537. /**
  25538. * Returns a positive integer : the total number of indices in this mesh geometry.
  25539. * @returns the numner of indices or zero if the mesh has no geometry.
  25540. */
  25541. getTotalIndices(): number;
  25542. /**
  25543. * Returns null by default. Implemented by child classes
  25544. * @returns null
  25545. */
  25546. getIndices(): Nullable<IndicesArray>;
  25547. /**
  25548. * Returns the array of the requested vertex data kind. Implemented by child classes
  25549. * @param kind defines the vertex data kind to use
  25550. * @returns null
  25551. */
  25552. getVerticesData(kind: string): Nullable<FloatArray>;
  25553. /**
  25554. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25555. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25556. * Note that a new underlying VertexBuffer object is created each call.
  25557. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25558. * @param kind defines vertex data kind:
  25559. * * VertexBuffer.PositionKind
  25560. * * VertexBuffer.UVKind
  25561. * * VertexBuffer.UV2Kind
  25562. * * VertexBuffer.UV3Kind
  25563. * * VertexBuffer.UV4Kind
  25564. * * VertexBuffer.UV5Kind
  25565. * * VertexBuffer.UV6Kind
  25566. * * VertexBuffer.ColorKind
  25567. * * VertexBuffer.MatricesIndicesKind
  25568. * * VertexBuffer.MatricesIndicesExtraKind
  25569. * * VertexBuffer.MatricesWeightsKind
  25570. * * VertexBuffer.MatricesWeightsExtraKind
  25571. * @param data defines the data source
  25572. * @param updatable defines if the data must be flagged as updatable (or static)
  25573. * @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
  25574. * @returns the current mesh
  25575. */
  25576. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25577. /**
  25578. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25579. * If the mesh has no geometry, it is simply returned as it is.
  25580. * @param kind defines vertex data kind:
  25581. * * VertexBuffer.PositionKind
  25582. * * VertexBuffer.UVKind
  25583. * * VertexBuffer.UV2Kind
  25584. * * VertexBuffer.UV3Kind
  25585. * * VertexBuffer.UV4Kind
  25586. * * VertexBuffer.UV5Kind
  25587. * * VertexBuffer.UV6Kind
  25588. * * VertexBuffer.ColorKind
  25589. * * VertexBuffer.MatricesIndicesKind
  25590. * * VertexBuffer.MatricesIndicesExtraKind
  25591. * * VertexBuffer.MatricesWeightsKind
  25592. * * VertexBuffer.MatricesWeightsExtraKind
  25593. * @param data defines the data source
  25594. * @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
  25595. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25596. * @returns the current mesh
  25597. */
  25598. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25599. /**
  25600. * Sets the mesh indices,
  25601. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25602. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25603. * @param totalVertices Defines the total number of vertices
  25604. * @returns the current mesh
  25605. */
  25606. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25607. /**
  25608. * Gets a boolean indicating if specific vertex data is present
  25609. * @param kind defines the vertex data kind to use
  25610. * @returns true is data kind is present
  25611. */
  25612. isVerticesDataPresent(kind: string): boolean;
  25613. /**
  25614. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25615. * @returns a BoundingInfo
  25616. */
  25617. getBoundingInfo(): BoundingInfo;
  25618. /**
  25619. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25620. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25621. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25622. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25623. * @returns the current mesh
  25624. */
  25625. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25626. /**
  25627. * Overwrite the current bounding info
  25628. * @param boundingInfo defines the new bounding info
  25629. * @returns the current mesh
  25630. */
  25631. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25632. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25633. readonly useBones: boolean;
  25634. /** @hidden */
  25635. _preActivate(): void;
  25636. /** @hidden */
  25637. _preActivateForIntermediateRendering(renderId: number): void;
  25638. /** @hidden */
  25639. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25640. /** @hidden */
  25641. _postActivate(): void;
  25642. /** @hidden */
  25643. _freeze(): void;
  25644. /** @hidden */
  25645. _unFreeze(): void;
  25646. /**
  25647. * Gets the current world matrix
  25648. * @returns a Matrix
  25649. */
  25650. getWorldMatrix(): Matrix;
  25651. /** @hidden */
  25652. _getWorldMatrixDeterminant(): number;
  25653. /**
  25654. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25655. */
  25656. readonly isAnInstance: boolean;
  25657. /**
  25658. * Perform relative position change from the point of view of behind the front of the mesh.
  25659. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25660. * Supports definition of mesh facing forward or backward
  25661. * @param amountRight defines the distance on the right axis
  25662. * @param amountUp defines the distance on the up axis
  25663. * @param amountForward defines the distance on the forward axis
  25664. * @returns the current mesh
  25665. */
  25666. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25667. /**
  25668. * Calculate relative position change from the point of view of behind the front of the mesh.
  25669. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25670. * Supports definition of mesh facing forward or backward
  25671. * @param amountRight defines the distance on the right axis
  25672. * @param amountUp defines the distance on the up axis
  25673. * @param amountForward defines the distance on the forward axis
  25674. * @returns the new displacement vector
  25675. */
  25676. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25677. /**
  25678. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25679. * Supports definition of mesh facing forward or backward
  25680. * @param flipBack defines the flip
  25681. * @param twirlClockwise defines the twirl
  25682. * @param tiltRight defines the tilt
  25683. * @returns the current mesh
  25684. */
  25685. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25686. /**
  25687. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25688. * Supports definition of mesh facing forward or backward.
  25689. * @param flipBack defines the flip
  25690. * @param twirlClockwise defines the twirl
  25691. * @param tiltRight defines the tilt
  25692. * @returns the new rotation vector
  25693. */
  25694. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25695. /**
  25696. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25697. * This means the mesh underlying bounding box and sphere are recomputed.
  25698. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25699. * @returns the current mesh
  25700. */
  25701. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25702. /** @hidden */
  25703. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25704. /** @hidden */
  25705. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25706. /** @hidden */
  25707. _updateBoundingInfo(): AbstractMesh;
  25708. /** @hidden */
  25709. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25710. /** @hidden */
  25711. protected _afterComputeWorldMatrix(): void;
  25712. /** @hidden */
  25713. readonly _effectiveMesh: AbstractMesh;
  25714. /**
  25715. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25716. * A mesh is in the frustum if its bounding box intersects the frustum
  25717. * @param frustumPlanes defines the frustum to test
  25718. * @returns true if the mesh is in the frustum planes
  25719. */
  25720. isInFrustum(frustumPlanes: Plane[]): boolean;
  25721. /**
  25722. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25723. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25724. * @param frustumPlanes defines the frustum to test
  25725. * @returns true if the mesh is completely in the frustum planes
  25726. */
  25727. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25728. /**
  25729. * True if the mesh intersects another mesh or a SolidParticle object
  25730. * @param mesh defines a target mesh or SolidParticle to test
  25731. * @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)
  25732. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25733. * @returns true if there is an intersection
  25734. */
  25735. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25736. /**
  25737. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25738. * @param point defines the point to test
  25739. * @returns true if there is an intersection
  25740. */
  25741. intersectsPoint(point: Vector3): boolean;
  25742. /**
  25743. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25745. */
  25746. checkCollisions: boolean;
  25747. /**
  25748. * Gets Collider object used to compute collisions (not physics)
  25749. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25750. */
  25751. readonly collider: Nullable<Collider>;
  25752. /**
  25753. * Move the mesh using collision engine
  25754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25755. * @param displacement defines the requested displacement vector
  25756. * @returns the current mesh
  25757. */
  25758. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25759. private _onCollisionPositionChange;
  25760. /** @hidden */
  25761. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25762. /** @hidden */
  25763. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25764. /** @hidden */
  25765. _checkCollision(collider: Collider): AbstractMesh;
  25766. /** @hidden */
  25767. _generatePointsArray(): boolean;
  25768. /**
  25769. * Checks if the passed Ray intersects with the mesh
  25770. * @param ray defines the ray to use
  25771. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25772. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25773. * @returns the picking info
  25774. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25775. */
  25776. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25777. /**
  25778. * Clones the current mesh
  25779. * @param name defines the mesh name
  25780. * @param newParent defines the new mesh parent
  25781. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25782. * @returns the new mesh
  25783. */
  25784. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25785. /**
  25786. * Disposes all the submeshes of the current meshnp
  25787. * @returns the current mesh
  25788. */
  25789. releaseSubMeshes(): AbstractMesh;
  25790. /**
  25791. * Releases resources associated with this abstract mesh.
  25792. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25793. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25794. */
  25795. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25796. /**
  25797. * Adds the passed mesh as a child to the current mesh
  25798. * @param mesh defines the child mesh
  25799. * @returns the current mesh
  25800. */
  25801. addChild(mesh: AbstractMesh): AbstractMesh;
  25802. /**
  25803. * Removes the passed mesh from the current mesh children list
  25804. * @param mesh defines the child mesh
  25805. * @returns the current mesh
  25806. */
  25807. removeChild(mesh: AbstractMesh): AbstractMesh;
  25808. /** @hidden */
  25809. private _initFacetData;
  25810. /**
  25811. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25812. * This method can be called within the render loop.
  25813. * 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
  25814. * @returns the current mesh
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25816. */
  25817. updateFacetData(): AbstractMesh;
  25818. /**
  25819. * Returns the facetLocalNormals array.
  25820. * The normals are expressed in the mesh local spac
  25821. * @returns an array of Vector3
  25822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25823. */
  25824. getFacetLocalNormals(): Vector3[];
  25825. /**
  25826. * Returns the facetLocalPositions array.
  25827. * The facet positions are expressed in the mesh local space
  25828. * @returns an array of Vector3
  25829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25830. */
  25831. getFacetLocalPositions(): Vector3[];
  25832. /**
  25833. * Returns the facetLocalPartioning array
  25834. * @returns an array of array of numbers
  25835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25836. */
  25837. getFacetLocalPartitioning(): number[][];
  25838. /**
  25839. * Returns the i-th facet position in the world system.
  25840. * This method allocates a new Vector3 per call
  25841. * @param i defines the facet index
  25842. * @returns a new Vector3
  25843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25844. */
  25845. getFacetPosition(i: number): Vector3;
  25846. /**
  25847. * Sets the reference Vector3 with the i-th facet position in the world system
  25848. * @param i defines the facet index
  25849. * @param ref defines the target vector
  25850. * @returns the current mesh
  25851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25852. */
  25853. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25854. /**
  25855. * Returns the i-th facet normal in the world system.
  25856. * This method allocates a new Vector3 per call
  25857. * @param i defines the facet index
  25858. * @returns a new Vector3
  25859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25860. */
  25861. getFacetNormal(i: number): Vector3;
  25862. /**
  25863. * Sets the reference Vector3 with the i-th facet normal in the world system
  25864. * @param i defines the facet index
  25865. * @param ref defines the target vector
  25866. * @returns the current mesh
  25867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25868. */
  25869. getFacetNormalToRef(i: number, ref: Vector3): this;
  25870. /**
  25871. * 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)
  25872. * @param x defines x coordinate
  25873. * @param y defines y coordinate
  25874. * @param z defines z coordinate
  25875. * @returns the array of facet indexes
  25876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25877. */
  25878. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25879. /**
  25880. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25881. * @param projected sets as the (x,y,z) world projection on the facet
  25882. * @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
  25883. * @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
  25884. * @param x defines x coordinate
  25885. * @param y defines y coordinate
  25886. * @param z defines z coordinate
  25887. * @returns the face index if found (or null instead)
  25888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25889. */
  25890. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25891. /**
  25892. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25893. * @param projected sets as the (x,y,z) local projection on the facet
  25894. * @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
  25895. * @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
  25896. * @param x defines x coordinate
  25897. * @param y defines y coordinate
  25898. * @param z defines z coordinate
  25899. * @returns the face index if found (or null instead)
  25900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25901. */
  25902. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25903. /**
  25904. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25905. * @returns the parameters
  25906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25907. */
  25908. getFacetDataParameters(): any;
  25909. /**
  25910. * Disables the feature FacetData and frees the related memory
  25911. * @returns the current mesh
  25912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25913. */
  25914. disableFacetData(): AbstractMesh;
  25915. /**
  25916. * Updates the AbstractMesh indices array
  25917. * @param indices defines the data source
  25918. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25919. * @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)
  25920. * @returns the current mesh
  25921. */
  25922. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25923. /**
  25924. * Creates new normals data for the mesh
  25925. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25926. * @returns the current mesh
  25927. */
  25928. createNormals(updatable: boolean): AbstractMesh;
  25929. /**
  25930. * Align the mesh with a normal
  25931. * @param normal defines the normal to use
  25932. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25933. * @returns the current mesh
  25934. */
  25935. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25936. /** @hidden */
  25937. _checkOcclusionQuery(): boolean;
  25938. /**
  25939. * Disables the mesh edge rendering mode
  25940. * @returns the currentAbstractMesh
  25941. */
  25942. disableEdgesRendering(): AbstractMesh;
  25943. /**
  25944. * Enables the edge rendering mode on the mesh.
  25945. * This mode makes the mesh edges visible
  25946. * @param epsilon defines the maximal distance between two angles to detect a face
  25947. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25948. * @returns the currentAbstractMesh
  25949. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25950. */
  25951. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25952. }
  25953. }
  25954. declare module "babylonjs/Actions/actionEvent" {
  25955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25956. import { Nullable } from "babylonjs/types";
  25957. import { Sprite } from "babylonjs/Sprites/sprite";
  25958. import { Scene } from "babylonjs/scene";
  25959. import { Vector2 } from "babylonjs/Maths/math";
  25960. /**
  25961. * Interface used to define ActionEvent
  25962. */
  25963. export interface IActionEvent {
  25964. /** The mesh or sprite that triggered the action */
  25965. source: any;
  25966. /** The X mouse cursor position at the time of the event */
  25967. pointerX: number;
  25968. /** The Y mouse cursor position at the time of the event */
  25969. pointerY: number;
  25970. /** The mesh that is currently pointed at (can be null) */
  25971. meshUnderPointer: Nullable<AbstractMesh>;
  25972. /** the original (browser) event that triggered the ActionEvent */
  25973. sourceEvent?: any;
  25974. /** additional data for the event */
  25975. additionalData?: any;
  25976. }
  25977. /**
  25978. * ActionEvent is the event being sent when an action is triggered.
  25979. */
  25980. export class ActionEvent implements IActionEvent {
  25981. /** The mesh or sprite that triggered the action */
  25982. source: any;
  25983. /** The X mouse cursor position at the time of the event */
  25984. pointerX: number;
  25985. /** The Y mouse cursor position at the time of the event */
  25986. pointerY: number;
  25987. /** The mesh that is currently pointed at (can be null) */
  25988. meshUnderPointer: Nullable<AbstractMesh>;
  25989. /** the original (browser) event that triggered the ActionEvent */
  25990. sourceEvent?: any;
  25991. /** additional data for the event */
  25992. additionalData?: any;
  25993. /**
  25994. * Creates a new ActionEvent
  25995. * @param source The mesh or sprite that triggered the action
  25996. * @param pointerX The X mouse cursor position at the time of the event
  25997. * @param pointerY The Y mouse cursor position at the time of the event
  25998. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25999. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26000. * @param additionalData additional data for the event
  26001. */
  26002. constructor(
  26003. /** The mesh or sprite that triggered the action */
  26004. source: any,
  26005. /** The X mouse cursor position at the time of the event */
  26006. pointerX: number,
  26007. /** The Y mouse cursor position at the time of the event */
  26008. pointerY: number,
  26009. /** The mesh that is currently pointed at (can be null) */
  26010. meshUnderPointer: Nullable<AbstractMesh>,
  26011. /** the original (browser) event that triggered the ActionEvent */
  26012. sourceEvent?: any,
  26013. /** additional data for the event */
  26014. additionalData?: any);
  26015. /**
  26016. * Helper function to auto-create an ActionEvent from a source mesh.
  26017. * @param source The source mesh that triggered the event
  26018. * @param evt The original (browser) event
  26019. * @param additionalData additional data for the event
  26020. * @returns the new ActionEvent
  26021. */
  26022. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26023. /**
  26024. * Helper function to auto-create an ActionEvent from a source sprite
  26025. * @param source The source sprite that triggered the event
  26026. * @param scene Scene associated with the sprite
  26027. * @param evt The original (browser) event
  26028. * @param additionalData additional data for the event
  26029. * @returns the new ActionEvent
  26030. */
  26031. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26032. /**
  26033. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26034. * @param scene the scene where the event occurred
  26035. * @param evt The original (browser) event
  26036. * @returns the new ActionEvent
  26037. */
  26038. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26039. /**
  26040. * Helper function to auto-create an ActionEvent from a primitive
  26041. * @param prim defines the target primitive
  26042. * @param pointerPos defines the pointer position
  26043. * @param evt The original (browser) event
  26044. * @param additionalData additional data for the event
  26045. * @returns the new ActionEvent
  26046. */
  26047. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26048. }
  26049. }
  26050. declare module "babylonjs/Actions/abstractActionManager" {
  26051. import { IDisposable } from "babylonjs/scene";
  26052. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26053. import { IAction } from "babylonjs/Actions/action";
  26054. import { Nullable } from "babylonjs/types";
  26055. /**
  26056. * Abstract class used to decouple action Manager from scene and meshes.
  26057. * Do not instantiate.
  26058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26059. */
  26060. export abstract class AbstractActionManager implements IDisposable {
  26061. /** Gets the list of active triggers */
  26062. static Triggers: {
  26063. [key: string]: number;
  26064. };
  26065. /** Gets the cursor to use when hovering items */
  26066. hoverCursor: string;
  26067. /** Gets the list of actions */
  26068. actions: IAction[];
  26069. /**
  26070. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26071. */
  26072. isRecursive: boolean;
  26073. /**
  26074. * Releases all associated resources
  26075. */
  26076. abstract dispose(): void;
  26077. /**
  26078. * Does this action manager has pointer triggers
  26079. */
  26080. abstract readonly hasPointerTriggers: boolean;
  26081. /**
  26082. * Does this action manager has pick triggers
  26083. */
  26084. abstract readonly hasPickTriggers: boolean;
  26085. /**
  26086. * Process a specific trigger
  26087. * @param trigger defines the trigger to process
  26088. * @param evt defines the event details to be processed
  26089. */
  26090. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26091. /**
  26092. * Does this action manager handles actions of any of the given triggers
  26093. * @param triggers defines the triggers to be tested
  26094. * @return a boolean indicating whether one (or more) of the triggers is handled
  26095. */
  26096. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26097. /**
  26098. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26099. * speed.
  26100. * @param triggerA defines the trigger to be tested
  26101. * @param triggerB defines the trigger to be tested
  26102. * @return a boolean indicating whether one (or more) of the triggers is handled
  26103. */
  26104. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26105. /**
  26106. * Does this action manager handles actions of a given trigger
  26107. * @param trigger defines the trigger to be tested
  26108. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26109. * @return whether the trigger is handled
  26110. */
  26111. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26112. /**
  26113. * Serialize this manager to a JSON object
  26114. * @param name defines the property name to store this manager
  26115. * @returns a JSON representation of this manager
  26116. */
  26117. abstract serialize(name: string): any;
  26118. /**
  26119. * Registers an action to this action manager
  26120. * @param action defines the action to be registered
  26121. * @return the action amended (prepared) after registration
  26122. */
  26123. abstract registerAction(action: IAction): Nullable<IAction>;
  26124. /**
  26125. * Unregisters an action to this action manager
  26126. * @param action defines the action to be unregistered
  26127. * @return a boolean indicating whether the action has been unregistered
  26128. */
  26129. abstract unregisterAction(action: IAction): Boolean;
  26130. /**
  26131. * Does exist one action manager with at least one trigger
  26132. **/
  26133. static readonly HasTriggers: boolean;
  26134. /**
  26135. * Does exist one action manager with at least one pick trigger
  26136. **/
  26137. static readonly HasPickTriggers: boolean;
  26138. /**
  26139. * Does exist one action manager that handles actions of a given trigger
  26140. * @param trigger defines the trigger to be tested
  26141. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26142. **/
  26143. static HasSpecificTrigger(trigger: number): boolean;
  26144. }
  26145. }
  26146. declare module "babylonjs/node" {
  26147. import { Scene } from "babylonjs/scene";
  26148. import { Nullable } from "babylonjs/types";
  26149. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26150. import { Engine } from "babylonjs/Engines/engine";
  26151. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26152. import { Observable } from "babylonjs/Misc/observable";
  26153. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26154. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26155. import { Animatable } from "babylonjs/Animations/animatable";
  26156. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26157. import { Animation } from "babylonjs/Animations/animation";
  26158. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26160. /**
  26161. * Defines how a node can be built from a string name.
  26162. */
  26163. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26164. /**
  26165. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26166. */
  26167. export class Node implements IBehaviorAware<Node> {
  26168. /** @hidden */
  26169. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26170. private static _NodeConstructors;
  26171. /**
  26172. * Add a new node constructor
  26173. * @param type defines the type name of the node to construct
  26174. * @param constructorFunc defines the constructor function
  26175. */
  26176. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26177. /**
  26178. * Returns a node constructor based on type name
  26179. * @param type defines the type name
  26180. * @param name defines the new node name
  26181. * @param scene defines the hosting scene
  26182. * @param options defines optional options to transmit to constructors
  26183. * @returns the new constructor or null
  26184. */
  26185. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26186. /**
  26187. * Gets or sets the name of the node
  26188. */
  26189. name: string;
  26190. /**
  26191. * Gets or sets the id of the node
  26192. */
  26193. id: string;
  26194. /**
  26195. * Gets or sets the unique id of the node
  26196. */
  26197. uniqueId: number;
  26198. /**
  26199. * Gets or sets a string used to store user defined state for the node
  26200. */
  26201. state: string;
  26202. /**
  26203. * Gets or sets an object used to store user defined information for the node
  26204. */
  26205. metadata: any;
  26206. /**
  26207. * For internal use only. Please do not use.
  26208. */
  26209. reservedDataStore: any;
  26210. /**
  26211. * List of inspectable custom properties (used by the Inspector)
  26212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26213. */
  26214. inspectableCustomProperties: IInspectable[];
  26215. /**
  26216. * Gets or sets a boolean used to define if the node must be serialized
  26217. */
  26218. doNotSerialize: boolean;
  26219. /** @hidden */
  26220. _isDisposed: boolean;
  26221. /**
  26222. * Gets a list of Animations associated with the node
  26223. */
  26224. animations: import("babylonjs/Animations/animation").Animation[];
  26225. protected _ranges: {
  26226. [name: string]: Nullable<AnimationRange>;
  26227. };
  26228. /**
  26229. * Callback raised when the node is ready to be used
  26230. */
  26231. onReady: Nullable<(node: Node) => void>;
  26232. private _isEnabled;
  26233. private _isParentEnabled;
  26234. private _isReady;
  26235. /** @hidden */
  26236. _currentRenderId: number;
  26237. private _parentUpdateId;
  26238. /** @hidden */
  26239. _childUpdateId: number;
  26240. /** @hidden */
  26241. _waitingParentId: Nullable<string>;
  26242. /** @hidden */
  26243. _scene: Scene;
  26244. /** @hidden */
  26245. _cache: any;
  26246. private _parentNode;
  26247. private _children;
  26248. /** @hidden */
  26249. _worldMatrix: Matrix;
  26250. /** @hidden */
  26251. _worldMatrixDeterminant: number;
  26252. /** @hidden */
  26253. _worldMatrixDeterminantIsDirty: boolean;
  26254. /** @hidden */
  26255. private _sceneRootNodesIndex;
  26256. /**
  26257. * Gets a boolean indicating if the node has been disposed
  26258. * @returns true if the node was disposed
  26259. */
  26260. isDisposed(): boolean;
  26261. /**
  26262. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26263. * @see https://doc.babylonjs.com/how_to/parenting
  26264. */
  26265. parent: Nullable<Node>;
  26266. private addToSceneRootNodes;
  26267. private removeFromSceneRootNodes;
  26268. private _animationPropertiesOverride;
  26269. /**
  26270. * Gets or sets the animation properties override
  26271. */
  26272. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26273. /**
  26274. * Gets a string idenfifying the name of the class
  26275. * @returns "Node" string
  26276. */
  26277. getClassName(): string;
  26278. /** @hidden */
  26279. readonly _isNode: boolean;
  26280. /**
  26281. * An event triggered when the mesh is disposed
  26282. */
  26283. onDisposeObservable: Observable<Node>;
  26284. private _onDisposeObserver;
  26285. /**
  26286. * Sets a callback that will be raised when the node will be disposed
  26287. */
  26288. onDispose: () => void;
  26289. /**
  26290. * Creates a new Node
  26291. * @param name the name and id to be given to this node
  26292. * @param scene the scene this node will be added to
  26293. * @param addToRootNodes the node will be added to scene.rootNodes
  26294. */
  26295. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26296. /**
  26297. * Gets the scene of the node
  26298. * @returns a scene
  26299. */
  26300. getScene(): Scene;
  26301. /**
  26302. * Gets the engine of the node
  26303. * @returns a Engine
  26304. */
  26305. getEngine(): Engine;
  26306. private _behaviors;
  26307. /**
  26308. * Attach a behavior to the node
  26309. * @see http://doc.babylonjs.com/features/behaviour
  26310. * @param behavior defines the behavior to attach
  26311. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26312. * @returns the current Node
  26313. */
  26314. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26315. /**
  26316. * Remove an attached behavior
  26317. * @see http://doc.babylonjs.com/features/behaviour
  26318. * @param behavior defines the behavior to attach
  26319. * @returns the current Node
  26320. */
  26321. removeBehavior(behavior: Behavior<Node>): Node;
  26322. /**
  26323. * Gets the list of attached behaviors
  26324. * @see http://doc.babylonjs.com/features/behaviour
  26325. */
  26326. readonly behaviors: Behavior<Node>[];
  26327. /**
  26328. * Gets an attached behavior by name
  26329. * @param name defines the name of the behavior to look for
  26330. * @see http://doc.babylonjs.com/features/behaviour
  26331. * @returns null if behavior was not found else the requested behavior
  26332. */
  26333. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26334. /**
  26335. * Returns the latest update of the World matrix
  26336. * @returns a Matrix
  26337. */
  26338. getWorldMatrix(): Matrix;
  26339. /** @hidden */
  26340. _getWorldMatrixDeterminant(): number;
  26341. /**
  26342. * Returns directly the latest state of the mesh World matrix.
  26343. * A Matrix is returned.
  26344. */
  26345. readonly worldMatrixFromCache: Matrix;
  26346. /** @hidden */
  26347. _initCache(): void;
  26348. /** @hidden */
  26349. updateCache(force?: boolean): void;
  26350. /** @hidden */
  26351. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26352. /** @hidden */
  26353. _updateCache(ignoreParentClass?: boolean): void;
  26354. /** @hidden */
  26355. _isSynchronized(): boolean;
  26356. /** @hidden */
  26357. _markSyncedWithParent(): void;
  26358. /** @hidden */
  26359. isSynchronizedWithParent(): boolean;
  26360. /** @hidden */
  26361. isSynchronized(): boolean;
  26362. /**
  26363. * Is this node ready to be used/rendered
  26364. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26365. * @return true if the node is ready
  26366. */
  26367. isReady(completeCheck?: boolean): boolean;
  26368. /**
  26369. * Is this node enabled?
  26370. * 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
  26371. * @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
  26372. * @return whether this node (and its parent) is enabled
  26373. */
  26374. isEnabled(checkAncestors?: boolean): boolean;
  26375. /** @hidden */
  26376. protected _syncParentEnabledState(): void;
  26377. /**
  26378. * Set the enabled state of this node
  26379. * @param value defines the new enabled state
  26380. */
  26381. setEnabled(value: boolean): void;
  26382. /**
  26383. * Is this node a descendant of the given node?
  26384. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26385. * @param ancestor defines the parent node to inspect
  26386. * @returns a boolean indicating if this node is a descendant of the given node
  26387. */
  26388. isDescendantOf(ancestor: Node): boolean;
  26389. /** @hidden */
  26390. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26391. /**
  26392. * Will return all nodes that have this node as ascendant
  26393. * @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
  26394. * @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
  26395. * @return all children nodes of all types
  26396. */
  26397. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26398. /**
  26399. * Get all child-meshes of this node
  26400. * @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)
  26401. * @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
  26402. * @returns an array of AbstractMesh
  26403. */
  26404. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26405. /**
  26406. * Get all direct children of this node
  26407. * @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
  26408. * @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)
  26409. * @returns an array of Node
  26410. */
  26411. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26412. /** @hidden */
  26413. _setReady(state: boolean): void;
  26414. /**
  26415. * Get an animation by name
  26416. * @param name defines the name of the animation to look for
  26417. * @returns null if not found else the requested animation
  26418. */
  26419. getAnimationByName(name: string): Nullable<Animation>;
  26420. /**
  26421. * Creates an animation range for this node
  26422. * @param name defines the name of the range
  26423. * @param from defines the starting key
  26424. * @param to defines the end key
  26425. */
  26426. createAnimationRange(name: string, from: number, to: number): void;
  26427. /**
  26428. * Delete a specific animation range
  26429. * @param name defines the name of the range to delete
  26430. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26431. */
  26432. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26433. /**
  26434. * Get an animation range by name
  26435. * @param name defines the name of the animation range to look for
  26436. * @returns null if not found else the requested animation range
  26437. */
  26438. getAnimationRange(name: string): Nullable<AnimationRange>;
  26439. /**
  26440. * Gets the list of all animation ranges defined on this node
  26441. * @returns an array
  26442. */
  26443. getAnimationRanges(): Nullable<AnimationRange>[];
  26444. /**
  26445. * Will start the animation sequence
  26446. * @param name defines the range frames for animation sequence
  26447. * @param loop defines if the animation should loop (false by default)
  26448. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26449. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26450. * @returns the object created for this animation. If range does not exist, it will return null
  26451. */
  26452. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26453. /**
  26454. * Serialize animation ranges into a JSON compatible object
  26455. * @returns serialization object
  26456. */
  26457. serializeAnimationRanges(): any;
  26458. /**
  26459. * Computes the world matrix of the node
  26460. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26461. * @returns the world matrix
  26462. */
  26463. computeWorldMatrix(force?: boolean): Matrix;
  26464. /**
  26465. * Releases resources associated with this node.
  26466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26468. */
  26469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26470. /**
  26471. * Parse animation range data from a serialization object and store them into a given node
  26472. * @param node defines where to store the animation ranges
  26473. * @param parsedNode defines the serialization object to read data from
  26474. * @param scene defines the hosting scene
  26475. */
  26476. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26477. /**
  26478. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26479. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26480. * @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
  26481. * @returns the new bounding vectors
  26482. */
  26483. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26484. min: Vector3;
  26485. max: Vector3;
  26486. };
  26487. }
  26488. }
  26489. declare module "babylonjs/Animations/animation" {
  26490. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26491. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26492. import { Nullable } from "babylonjs/types";
  26493. import { Scene } from "babylonjs/scene";
  26494. import { IAnimatable } from "babylonjs/Misc/tools";
  26495. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26496. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26497. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26498. import { Node } from "babylonjs/node";
  26499. import { Animatable } from "babylonjs/Animations/animatable";
  26500. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26501. /**
  26502. * @hidden
  26503. */
  26504. export class _IAnimationState {
  26505. key: number;
  26506. repeatCount: number;
  26507. workValue?: any;
  26508. loopMode?: number;
  26509. offsetValue?: any;
  26510. highLimitValue?: any;
  26511. }
  26512. /**
  26513. * Class used to store any kind of animation
  26514. */
  26515. export class Animation {
  26516. /**Name of the animation */
  26517. name: string;
  26518. /**Property to animate */
  26519. targetProperty: string;
  26520. /**The frames per second of the animation */
  26521. framePerSecond: number;
  26522. /**The data type of the animation */
  26523. dataType: number;
  26524. /**The loop mode of the animation */
  26525. loopMode?: number | undefined;
  26526. /**Specifies if blending should be enabled */
  26527. enableBlending?: boolean | undefined;
  26528. /**
  26529. * Use matrix interpolation instead of using direct key value when animating matrices
  26530. */
  26531. static AllowMatricesInterpolation: boolean;
  26532. /**
  26533. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26534. */
  26535. static AllowMatrixDecomposeForInterpolation: boolean;
  26536. /**
  26537. * Stores the key frames of the animation
  26538. */
  26539. private _keys;
  26540. /**
  26541. * Stores the easing function of the animation
  26542. */
  26543. private _easingFunction;
  26544. /**
  26545. * @hidden Internal use only
  26546. */
  26547. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26548. /**
  26549. * The set of event that will be linked to this animation
  26550. */
  26551. private _events;
  26552. /**
  26553. * Stores an array of target property paths
  26554. */
  26555. targetPropertyPath: string[];
  26556. /**
  26557. * Stores the blending speed of the animation
  26558. */
  26559. blendingSpeed: number;
  26560. /**
  26561. * Stores the animation ranges for the animation
  26562. */
  26563. private _ranges;
  26564. /**
  26565. * @hidden Internal use
  26566. */
  26567. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26568. /**
  26569. * Sets up an animation
  26570. * @param property The property to animate
  26571. * @param animationType The animation type to apply
  26572. * @param framePerSecond The frames per second of the animation
  26573. * @param easingFunction The easing function used in the animation
  26574. * @returns The created animation
  26575. */
  26576. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26577. /**
  26578. * Create and start an animation on a node
  26579. * @param name defines the name of the global animation that will be run on all nodes
  26580. * @param node defines the root node where the animation will take place
  26581. * @param targetProperty defines property to animate
  26582. * @param framePerSecond defines the number of frame per second yo use
  26583. * @param totalFrame defines the number of frames in total
  26584. * @param from defines the initial value
  26585. * @param to defines the final value
  26586. * @param loopMode defines which loop mode you want to use (off by default)
  26587. * @param easingFunction defines the easing function to use (linear by default)
  26588. * @param onAnimationEnd defines the callback to call when animation end
  26589. * @returns the animatable created for this animation
  26590. */
  26591. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26592. /**
  26593. * Create and start an animation on a node and its descendants
  26594. * @param name defines the name of the global animation that will be run on all nodes
  26595. * @param node defines the root node where the animation will take place
  26596. * @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
  26597. * @param targetProperty defines property to animate
  26598. * @param framePerSecond defines the number of frame per second to use
  26599. * @param totalFrame defines the number of frames in total
  26600. * @param from defines the initial value
  26601. * @param to defines the final value
  26602. * @param loopMode defines which loop mode you want to use (off by default)
  26603. * @param easingFunction defines the easing function to use (linear by default)
  26604. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26605. * @returns the list of animatables created for all nodes
  26606. * @example https://www.babylonjs-playground.com/#MH0VLI
  26607. */
  26608. 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[]>;
  26609. /**
  26610. * Creates a new animation, merges it with the existing animations and starts it
  26611. * @param name Name of the animation
  26612. * @param node Node which contains the scene that begins the animations
  26613. * @param targetProperty Specifies which property to animate
  26614. * @param framePerSecond The frames per second of the animation
  26615. * @param totalFrame The total number of frames
  26616. * @param from The frame at the beginning of the animation
  26617. * @param to The frame at the end of the animation
  26618. * @param loopMode Specifies the loop mode of the animation
  26619. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26620. * @param onAnimationEnd Callback to run once the animation is complete
  26621. * @returns Nullable animation
  26622. */
  26623. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26624. /**
  26625. * Transition property of an host to the target Value
  26626. * @param property The property to transition
  26627. * @param targetValue The target Value of the property
  26628. * @param host The object where the property to animate belongs
  26629. * @param scene Scene used to run the animation
  26630. * @param frameRate Framerate (in frame/s) to use
  26631. * @param transition The transition type we want to use
  26632. * @param duration The duration of the animation, in milliseconds
  26633. * @param onAnimationEnd Callback trigger at the end of the animation
  26634. * @returns Nullable animation
  26635. */
  26636. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26637. /**
  26638. * Return the array of runtime animations currently using this animation
  26639. */
  26640. readonly runtimeAnimations: RuntimeAnimation[];
  26641. /**
  26642. * Specifies if any of the runtime animations are currently running
  26643. */
  26644. readonly hasRunningRuntimeAnimations: boolean;
  26645. /**
  26646. * Initializes the animation
  26647. * @param name Name of the animation
  26648. * @param targetProperty Property to animate
  26649. * @param framePerSecond The frames per second of the animation
  26650. * @param dataType The data type of the animation
  26651. * @param loopMode The loop mode of the animation
  26652. * @param enableBlending Specifies if blending should be enabled
  26653. */
  26654. constructor(
  26655. /**Name of the animation */
  26656. name: string,
  26657. /**Property to animate */
  26658. targetProperty: string,
  26659. /**The frames per second of the animation */
  26660. framePerSecond: number,
  26661. /**The data type of the animation */
  26662. dataType: number,
  26663. /**The loop mode of the animation */
  26664. loopMode?: number | undefined,
  26665. /**Specifies if blending should be enabled */
  26666. enableBlending?: boolean | undefined);
  26667. /**
  26668. * Converts the animation to a string
  26669. * @param fullDetails support for multiple levels of logging within scene loading
  26670. * @returns String form of the animation
  26671. */
  26672. toString(fullDetails?: boolean): string;
  26673. /**
  26674. * Add an event to this animation
  26675. * @param event Event to add
  26676. */
  26677. addEvent(event: AnimationEvent): void;
  26678. /**
  26679. * Remove all events found at the given frame
  26680. * @param frame The frame to remove events from
  26681. */
  26682. removeEvents(frame: number): void;
  26683. /**
  26684. * Retrieves all the events from the animation
  26685. * @returns Events from the animation
  26686. */
  26687. getEvents(): AnimationEvent[];
  26688. /**
  26689. * Creates an animation range
  26690. * @param name Name of the animation range
  26691. * @param from Starting frame of the animation range
  26692. * @param to Ending frame of the animation
  26693. */
  26694. createRange(name: string, from: number, to: number): void;
  26695. /**
  26696. * Deletes an animation range by name
  26697. * @param name Name of the animation range to delete
  26698. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26699. */
  26700. deleteRange(name: string, deleteFrames?: boolean): void;
  26701. /**
  26702. * Gets the animation range by name, or null if not defined
  26703. * @param name Name of the animation range
  26704. * @returns Nullable animation range
  26705. */
  26706. getRange(name: string): Nullable<AnimationRange>;
  26707. /**
  26708. * Gets the key frames from the animation
  26709. * @returns The key frames of the animation
  26710. */
  26711. getKeys(): Array<IAnimationKey>;
  26712. /**
  26713. * Gets the highest frame rate of the animation
  26714. * @returns Highest frame rate of the animation
  26715. */
  26716. getHighestFrame(): number;
  26717. /**
  26718. * Gets the easing function of the animation
  26719. * @returns Easing function of the animation
  26720. */
  26721. getEasingFunction(): IEasingFunction;
  26722. /**
  26723. * Sets the easing function of the animation
  26724. * @param easingFunction A custom mathematical formula for animation
  26725. */
  26726. setEasingFunction(easingFunction: EasingFunction): void;
  26727. /**
  26728. * Interpolates a scalar linearly
  26729. * @param startValue Start value of the animation curve
  26730. * @param endValue End value of the animation curve
  26731. * @param gradient Scalar amount to interpolate
  26732. * @returns Interpolated scalar value
  26733. */
  26734. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26735. /**
  26736. * Interpolates a scalar cubically
  26737. * @param startValue Start value of the animation curve
  26738. * @param outTangent End tangent of the animation
  26739. * @param endValue End value of the animation curve
  26740. * @param inTangent Start tangent of the animation curve
  26741. * @param gradient Scalar amount to interpolate
  26742. * @returns Interpolated scalar value
  26743. */
  26744. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26745. /**
  26746. * Interpolates a quaternion using a spherical linear interpolation
  26747. * @param startValue Start value of the animation curve
  26748. * @param endValue End value of the animation curve
  26749. * @param gradient Scalar amount to interpolate
  26750. * @returns Interpolated quaternion value
  26751. */
  26752. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26753. /**
  26754. * Interpolates a quaternion cubically
  26755. * @param startValue Start value of the animation curve
  26756. * @param outTangent End tangent of the animation curve
  26757. * @param endValue End value of the animation curve
  26758. * @param inTangent Start tangent of the animation curve
  26759. * @param gradient Scalar amount to interpolate
  26760. * @returns Interpolated quaternion value
  26761. */
  26762. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26763. /**
  26764. * Interpolates a Vector3 linearl
  26765. * @param startValue Start value of the animation curve
  26766. * @param endValue End value of the animation curve
  26767. * @param gradient Scalar amount to interpolate
  26768. * @returns Interpolated scalar value
  26769. */
  26770. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26771. /**
  26772. * Interpolates a Vector3 cubically
  26773. * @param startValue Start value of the animation curve
  26774. * @param outTangent End tangent of the animation
  26775. * @param endValue End value of the animation curve
  26776. * @param inTangent Start tangent of the animation curve
  26777. * @param gradient Scalar amount to interpolate
  26778. * @returns InterpolatedVector3 value
  26779. */
  26780. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26781. /**
  26782. * Interpolates a Vector2 linearly
  26783. * @param startValue Start value of the animation curve
  26784. * @param endValue End value of the animation curve
  26785. * @param gradient Scalar amount to interpolate
  26786. * @returns Interpolated Vector2 value
  26787. */
  26788. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26789. /**
  26790. * Interpolates a Vector2 cubically
  26791. * @param startValue Start value of the animation curve
  26792. * @param outTangent End tangent of the animation
  26793. * @param endValue End value of the animation curve
  26794. * @param inTangent Start tangent of the animation curve
  26795. * @param gradient Scalar amount to interpolate
  26796. * @returns Interpolated Vector2 value
  26797. */
  26798. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26799. /**
  26800. * Interpolates a size linearly
  26801. * @param startValue Start value of the animation curve
  26802. * @param endValue End value of the animation curve
  26803. * @param gradient Scalar amount to interpolate
  26804. * @returns Interpolated Size value
  26805. */
  26806. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26807. /**
  26808. * Interpolates a Color3 linearly
  26809. * @param startValue Start value of the animation curve
  26810. * @param endValue End value of the animation curve
  26811. * @param gradient Scalar amount to interpolate
  26812. * @returns Interpolated Color3 value
  26813. */
  26814. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26815. /**
  26816. * @hidden Internal use only
  26817. */
  26818. _getKeyValue(value: any): any;
  26819. /**
  26820. * @hidden Internal use only
  26821. */
  26822. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26823. /**
  26824. * Defines the function to use to interpolate matrices
  26825. * @param startValue defines the start matrix
  26826. * @param endValue defines the end matrix
  26827. * @param gradient defines the gradient between both matrices
  26828. * @param result defines an optional target matrix where to store the interpolation
  26829. * @returns the interpolated matrix
  26830. */
  26831. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26832. /**
  26833. * Makes a copy of the animation
  26834. * @returns Cloned animation
  26835. */
  26836. clone(): Animation;
  26837. /**
  26838. * Sets the key frames of the animation
  26839. * @param values The animation key frames to set
  26840. */
  26841. setKeys(values: Array<IAnimationKey>): void;
  26842. /**
  26843. * Serializes the animation to an object
  26844. * @returns Serialized object
  26845. */
  26846. serialize(): any;
  26847. /**
  26848. * Float animation type
  26849. */
  26850. private static _ANIMATIONTYPE_FLOAT;
  26851. /**
  26852. * Vector3 animation type
  26853. */
  26854. private static _ANIMATIONTYPE_VECTOR3;
  26855. /**
  26856. * Quaternion animation type
  26857. */
  26858. private static _ANIMATIONTYPE_QUATERNION;
  26859. /**
  26860. * Matrix animation type
  26861. */
  26862. private static _ANIMATIONTYPE_MATRIX;
  26863. /**
  26864. * Color3 animation type
  26865. */
  26866. private static _ANIMATIONTYPE_COLOR3;
  26867. /**
  26868. * Vector2 animation type
  26869. */
  26870. private static _ANIMATIONTYPE_VECTOR2;
  26871. /**
  26872. * Size animation type
  26873. */
  26874. private static _ANIMATIONTYPE_SIZE;
  26875. /**
  26876. * Relative Loop Mode
  26877. */
  26878. private static _ANIMATIONLOOPMODE_RELATIVE;
  26879. /**
  26880. * Cycle Loop Mode
  26881. */
  26882. private static _ANIMATIONLOOPMODE_CYCLE;
  26883. /**
  26884. * Constant Loop Mode
  26885. */
  26886. private static _ANIMATIONLOOPMODE_CONSTANT;
  26887. /**
  26888. * Get the float animation type
  26889. */
  26890. static readonly ANIMATIONTYPE_FLOAT: number;
  26891. /**
  26892. * Get the Vector3 animation type
  26893. */
  26894. static readonly ANIMATIONTYPE_VECTOR3: number;
  26895. /**
  26896. * Get the Vector2 animation type
  26897. */
  26898. static readonly ANIMATIONTYPE_VECTOR2: number;
  26899. /**
  26900. * Get the Size animation type
  26901. */
  26902. static readonly ANIMATIONTYPE_SIZE: number;
  26903. /**
  26904. * Get the Quaternion animation type
  26905. */
  26906. static readonly ANIMATIONTYPE_QUATERNION: number;
  26907. /**
  26908. * Get the Matrix animation type
  26909. */
  26910. static readonly ANIMATIONTYPE_MATRIX: number;
  26911. /**
  26912. * Get the Color3 animation type
  26913. */
  26914. static readonly ANIMATIONTYPE_COLOR3: number;
  26915. /**
  26916. * Get the Relative Loop Mode
  26917. */
  26918. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26919. /**
  26920. * Get the Cycle Loop Mode
  26921. */
  26922. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26923. /**
  26924. * Get the Constant Loop Mode
  26925. */
  26926. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26927. /** @hidden */
  26928. static _UniversalLerp(left: any, right: any, amount: number): any;
  26929. /**
  26930. * Parses an animation object and creates an animation
  26931. * @param parsedAnimation Parsed animation object
  26932. * @returns Animation object
  26933. */
  26934. static Parse(parsedAnimation: any): Animation;
  26935. /**
  26936. * Appends the serialized animations from the source animations
  26937. * @param source Source containing the animations
  26938. * @param destination Target to store the animations
  26939. */
  26940. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26941. }
  26942. }
  26943. declare module "babylonjs/Materials/Textures/baseTexture" {
  26944. import { Observable } from "babylonjs/Misc/observable";
  26945. import { IAnimatable } from "babylonjs/Misc/tools";
  26946. import { Nullable } from "babylonjs/types";
  26947. import { Scene } from "babylonjs/scene";
  26948. import { Matrix, ISize } from "babylonjs/Maths/math";
  26949. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26950. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26951. /**
  26952. * Base class of all the textures in babylon.
  26953. * It groups all the common properties the materials, post process, lights... might need
  26954. * in order to make a correct use of the texture.
  26955. */
  26956. export class BaseTexture implements IAnimatable {
  26957. /**
  26958. * Default anisotropic filtering level for the application.
  26959. * It is set to 4 as a good tradeoff between perf and quality.
  26960. */
  26961. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26962. /**
  26963. * Gets or sets the unique id of the texture
  26964. */
  26965. uniqueId: number;
  26966. /**
  26967. * Define the name of the texture.
  26968. */
  26969. name: string;
  26970. /**
  26971. * Gets or sets an object used to store user defined information.
  26972. */
  26973. metadata: any;
  26974. /**
  26975. * For internal use only. Please do not use.
  26976. */
  26977. reservedDataStore: any;
  26978. private _hasAlpha;
  26979. /**
  26980. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26981. */
  26982. hasAlpha: boolean;
  26983. /**
  26984. * Defines if the alpha value should be determined via the rgb values.
  26985. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26986. */
  26987. getAlphaFromRGB: boolean;
  26988. /**
  26989. * Intensity or strength of the texture.
  26990. * It is commonly used by materials to fine tune the intensity of the texture
  26991. */
  26992. level: number;
  26993. /**
  26994. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26995. * This is part of the texture as textures usually maps to one uv set.
  26996. */
  26997. coordinatesIndex: number;
  26998. private _coordinatesMode;
  26999. /**
  27000. * How a texture is mapped.
  27001. *
  27002. * | Value | Type | Description |
  27003. * | ----- | ----------------------------------- | ----------- |
  27004. * | 0 | EXPLICIT_MODE | |
  27005. * | 1 | SPHERICAL_MODE | |
  27006. * | 2 | PLANAR_MODE | |
  27007. * | 3 | CUBIC_MODE | |
  27008. * | 4 | PROJECTION_MODE | |
  27009. * | 5 | SKYBOX_MODE | |
  27010. * | 6 | INVCUBIC_MODE | |
  27011. * | 7 | EQUIRECTANGULAR_MODE | |
  27012. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27013. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27014. */
  27015. coordinatesMode: number;
  27016. /**
  27017. * | Value | Type | Description |
  27018. * | ----- | ------------------ | ----------- |
  27019. * | 0 | CLAMP_ADDRESSMODE | |
  27020. * | 1 | WRAP_ADDRESSMODE | |
  27021. * | 2 | MIRROR_ADDRESSMODE | |
  27022. */
  27023. wrapU: number;
  27024. /**
  27025. * | Value | Type | Description |
  27026. * | ----- | ------------------ | ----------- |
  27027. * | 0 | CLAMP_ADDRESSMODE | |
  27028. * | 1 | WRAP_ADDRESSMODE | |
  27029. * | 2 | MIRROR_ADDRESSMODE | |
  27030. */
  27031. wrapV: number;
  27032. /**
  27033. * | Value | Type | Description |
  27034. * | ----- | ------------------ | ----------- |
  27035. * | 0 | CLAMP_ADDRESSMODE | |
  27036. * | 1 | WRAP_ADDRESSMODE | |
  27037. * | 2 | MIRROR_ADDRESSMODE | |
  27038. */
  27039. wrapR: number;
  27040. /**
  27041. * With compliant hardware and browser (supporting anisotropic filtering)
  27042. * this defines the level of anisotropic filtering in the texture.
  27043. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27044. */
  27045. anisotropicFilteringLevel: number;
  27046. /**
  27047. * Define if the texture is a cube texture or if false a 2d texture.
  27048. */
  27049. isCube: boolean;
  27050. /**
  27051. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27052. */
  27053. is3D: boolean;
  27054. /**
  27055. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27056. * HDR texture are usually stored in linear space.
  27057. * This only impacts the PBR and Background materials
  27058. */
  27059. gammaSpace: boolean;
  27060. /**
  27061. * Gets whether or not the texture contains RGBD data.
  27062. */
  27063. readonly isRGBD: boolean;
  27064. /**
  27065. * Is Z inverted in the texture (useful in a cube texture).
  27066. */
  27067. invertZ: boolean;
  27068. /**
  27069. * Are mip maps generated for this texture or not.
  27070. */
  27071. readonly noMipmap: boolean;
  27072. /**
  27073. * @hidden
  27074. */
  27075. lodLevelInAlpha: boolean;
  27076. /**
  27077. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27078. */
  27079. lodGenerationOffset: number;
  27080. /**
  27081. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27082. */
  27083. lodGenerationScale: number;
  27084. /**
  27085. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27086. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27087. * average roughness values.
  27088. */
  27089. linearSpecularLOD: boolean;
  27090. /**
  27091. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27092. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27093. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27094. */
  27095. irradianceTexture: Nullable<BaseTexture>;
  27096. /**
  27097. * Define if the texture is a render target.
  27098. */
  27099. isRenderTarget: boolean;
  27100. /**
  27101. * Define the unique id of the texture in the scene.
  27102. */
  27103. readonly uid: string;
  27104. /**
  27105. * Return a string representation of the texture.
  27106. * @returns the texture as a string
  27107. */
  27108. toString(): string;
  27109. /**
  27110. * Get the class name of the texture.
  27111. * @returns "BaseTexture"
  27112. */
  27113. getClassName(): string;
  27114. /**
  27115. * Define the list of animation attached to the texture.
  27116. */
  27117. animations: import("babylonjs/Animations/animation").Animation[];
  27118. /**
  27119. * An event triggered when the texture is disposed.
  27120. */
  27121. onDisposeObservable: Observable<BaseTexture>;
  27122. private _onDisposeObserver;
  27123. /**
  27124. * Callback triggered when the texture has been disposed.
  27125. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27126. */
  27127. onDispose: () => void;
  27128. /**
  27129. * Define the current state of the loading sequence when in delayed load mode.
  27130. */
  27131. delayLoadState: number;
  27132. private _scene;
  27133. /** @hidden */
  27134. _texture: Nullable<InternalTexture>;
  27135. private _uid;
  27136. /**
  27137. * Define if the texture is preventinga material to render or not.
  27138. * If not and the texture is not ready, the engine will use a default black texture instead.
  27139. */
  27140. readonly isBlocking: boolean;
  27141. /**
  27142. * Instantiates a new BaseTexture.
  27143. * Base class of all the textures in babylon.
  27144. * It groups all the common properties the materials, post process, lights... might need
  27145. * in order to make a correct use of the texture.
  27146. * @param scene Define the scene the texture blongs to
  27147. */
  27148. constructor(scene: Nullable<Scene>);
  27149. /**
  27150. * Get the scene the texture belongs to.
  27151. * @returns the scene or null if undefined
  27152. */
  27153. getScene(): Nullable<Scene>;
  27154. /**
  27155. * Get the texture transform matrix used to offset tile the texture for istance.
  27156. * @returns the transformation matrix
  27157. */
  27158. getTextureMatrix(): Matrix;
  27159. /**
  27160. * Get the texture reflection matrix used to rotate/transform the reflection.
  27161. * @returns the reflection matrix
  27162. */
  27163. getReflectionTextureMatrix(): Matrix;
  27164. /**
  27165. * Get the underlying lower level texture from Babylon.
  27166. * @returns the insternal texture
  27167. */
  27168. getInternalTexture(): Nullable<InternalTexture>;
  27169. /**
  27170. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27171. * @returns true if ready or not blocking
  27172. */
  27173. isReadyOrNotBlocking(): boolean;
  27174. /**
  27175. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27176. * @returns true if fully ready
  27177. */
  27178. isReady(): boolean;
  27179. private _cachedSize;
  27180. /**
  27181. * Get the size of the texture.
  27182. * @returns the texture size.
  27183. */
  27184. getSize(): ISize;
  27185. /**
  27186. * Get the base size of the texture.
  27187. * It can be different from the size if the texture has been resized for POT for instance
  27188. * @returns the base size
  27189. */
  27190. getBaseSize(): ISize;
  27191. /**
  27192. * Update the sampling mode of the texture.
  27193. * Default is Trilinear mode.
  27194. *
  27195. * | Value | Type | Description |
  27196. * | ----- | ------------------ | ----------- |
  27197. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27198. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27199. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27200. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27201. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27202. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27203. * | 7 | NEAREST_LINEAR | |
  27204. * | 8 | NEAREST_NEAREST | |
  27205. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27206. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27207. * | 11 | LINEAR_LINEAR | |
  27208. * | 12 | LINEAR_NEAREST | |
  27209. *
  27210. * > _mag_: magnification filter (close to the viewer)
  27211. * > _min_: minification filter (far from the viewer)
  27212. * > _mip_: filter used between mip map levels
  27213. *@param samplingMode Define the new sampling mode of the texture
  27214. */
  27215. updateSamplingMode(samplingMode: number): void;
  27216. /**
  27217. * Scales the texture if is `canRescale()`
  27218. * @param ratio the resize factor we want to use to rescale
  27219. */
  27220. scale(ratio: number): void;
  27221. /**
  27222. * Get if the texture can rescale.
  27223. */
  27224. readonly canRescale: boolean;
  27225. /** @hidden */
  27226. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27227. /** @hidden */
  27228. _rebuild(): void;
  27229. /**
  27230. * Triggers the load sequence in delayed load mode.
  27231. */
  27232. delayLoad(): void;
  27233. /**
  27234. * Clones the texture.
  27235. * @returns the cloned texture
  27236. */
  27237. clone(): Nullable<BaseTexture>;
  27238. /**
  27239. * Get the texture underlying type (INT, FLOAT...)
  27240. */
  27241. readonly textureType: number;
  27242. /**
  27243. * Get the texture underlying format (RGB, RGBA...)
  27244. */
  27245. readonly textureFormat: number;
  27246. /**
  27247. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27248. * This will returns an RGBA array buffer containing either in values (0-255) or
  27249. * float values (0-1) depending of the underlying buffer type.
  27250. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27251. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27252. * @param buffer defines a user defined buffer to fill with data (can be null)
  27253. * @returns The Array buffer containing the pixels data.
  27254. */
  27255. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27256. /**
  27257. * Release and destroy the underlying lower level texture aka internalTexture.
  27258. */
  27259. releaseInternalTexture(): void;
  27260. /**
  27261. * Get the polynomial representation of the texture data.
  27262. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27263. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27264. */
  27265. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27266. /** @hidden */
  27267. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27268. /** @hidden */
  27269. readonly _lodTextureMid: Nullable<BaseTexture>;
  27270. /** @hidden */
  27271. readonly _lodTextureLow: Nullable<BaseTexture>;
  27272. /**
  27273. * Dispose the texture and release its associated resources.
  27274. */
  27275. dispose(): void;
  27276. /**
  27277. * Serialize the texture into a JSON representation that can be parsed later on.
  27278. * @returns the JSON representation of the texture
  27279. */
  27280. serialize(): any;
  27281. /**
  27282. * Helper function to be called back once a list of texture contains only ready textures.
  27283. * @param textures Define the list of textures to wait for
  27284. * @param callback Define the callback triggered once the entire list will be ready
  27285. */
  27286. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27287. }
  27288. }
  27289. declare module "babylonjs/Materials/uniformBuffer" {
  27290. import { Nullable, FloatArray } from "babylonjs/types";
  27291. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27292. import { Engine } from "babylonjs/Engines/engine";
  27293. import { Effect } from "babylonjs/Materials/effect";
  27294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27295. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27296. /**
  27297. * Uniform buffer objects.
  27298. *
  27299. * Handles blocks of uniform on the GPU.
  27300. *
  27301. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27302. *
  27303. * For more information, please refer to :
  27304. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27305. */
  27306. export class UniformBuffer {
  27307. private _engine;
  27308. private _buffer;
  27309. private _data;
  27310. private _bufferData;
  27311. private _dynamic?;
  27312. private _uniformLocations;
  27313. private _uniformSizes;
  27314. private _uniformLocationPointer;
  27315. private _needSync;
  27316. private _noUBO;
  27317. private _currentEffect;
  27318. private static _MAX_UNIFORM_SIZE;
  27319. private static _tempBuffer;
  27320. /**
  27321. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27322. * This is dynamic to allow compat with webgl 1 and 2.
  27323. * You will need to pass the name of the uniform as well as the value.
  27324. */
  27325. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27326. /**
  27327. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27328. * This is dynamic to allow compat with webgl 1 and 2.
  27329. * You will need to pass the name of the uniform as well as the value.
  27330. */
  27331. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27332. /**
  27333. * Lambda to Update a single float in a uniform buffer.
  27334. * This is dynamic to allow compat with webgl 1 and 2.
  27335. * You will need to pass the name of the uniform as well as the value.
  27336. */
  27337. updateFloat: (name: string, x: number) => void;
  27338. /**
  27339. * Lambda to Update a vec2 of float in a uniform buffer.
  27340. * This is dynamic to allow compat with webgl 1 and 2.
  27341. * You will need to pass the name of the uniform as well as the value.
  27342. */
  27343. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27344. /**
  27345. * Lambda to Update a vec3 of float in a uniform buffer.
  27346. * This is dynamic to allow compat with webgl 1 and 2.
  27347. * You will need to pass the name of the uniform as well as the value.
  27348. */
  27349. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27350. /**
  27351. * Lambda to Update a vec4 of float in a uniform buffer.
  27352. * This is dynamic to allow compat with webgl 1 and 2.
  27353. * You will need to pass the name of the uniform as well as the value.
  27354. */
  27355. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27356. /**
  27357. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27358. * This is dynamic to allow compat with webgl 1 and 2.
  27359. * You will need to pass the name of the uniform as well as the value.
  27360. */
  27361. updateMatrix: (name: string, mat: Matrix) => void;
  27362. /**
  27363. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27364. * This is dynamic to allow compat with webgl 1 and 2.
  27365. * You will need to pass the name of the uniform as well as the value.
  27366. */
  27367. updateVector3: (name: string, vector: Vector3) => void;
  27368. /**
  27369. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27370. * This is dynamic to allow compat with webgl 1 and 2.
  27371. * You will need to pass the name of the uniform as well as the value.
  27372. */
  27373. updateVector4: (name: string, vector: Vector4) => void;
  27374. /**
  27375. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27376. * This is dynamic to allow compat with webgl 1 and 2.
  27377. * You will need to pass the name of the uniform as well as the value.
  27378. */
  27379. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27380. /**
  27381. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27382. * This is dynamic to allow compat with webgl 1 and 2.
  27383. * You will need to pass the name of the uniform as well as the value.
  27384. */
  27385. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27386. /**
  27387. * Instantiates a new Uniform buffer objects.
  27388. *
  27389. * Handles blocks of uniform on the GPU.
  27390. *
  27391. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27392. *
  27393. * For more information, please refer to :
  27394. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27395. * @param engine Define the engine the buffer is associated with
  27396. * @param data Define the data contained in the buffer
  27397. * @param dynamic Define if the buffer is updatable
  27398. */
  27399. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27400. /**
  27401. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27402. * or just falling back on setUniformXXX calls.
  27403. */
  27404. readonly useUbo: boolean;
  27405. /**
  27406. * Indicates if the WebGL underlying uniform buffer is in sync
  27407. * with the javascript cache data.
  27408. */
  27409. readonly isSync: boolean;
  27410. /**
  27411. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27412. * Also, a dynamic UniformBuffer will disable cache verification and always
  27413. * update the underlying WebGL uniform buffer to the GPU.
  27414. * @returns if Dynamic, otherwise false
  27415. */
  27416. isDynamic(): boolean;
  27417. /**
  27418. * The data cache on JS side.
  27419. * @returns the underlying data as a float array
  27420. */
  27421. getData(): Float32Array;
  27422. /**
  27423. * The underlying WebGL Uniform buffer.
  27424. * @returns the webgl buffer
  27425. */
  27426. getBuffer(): Nullable<DataBuffer>;
  27427. /**
  27428. * std140 layout specifies how to align data within an UBO structure.
  27429. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27430. * for specs.
  27431. */
  27432. private _fillAlignment;
  27433. /**
  27434. * Adds an uniform in the buffer.
  27435. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27436. * for the layout to be correct !
  27437. * @param name Name of the uniform, as used in the uniform block in the shader.
  27438. * @param size Data size, or data directly.
  27439. */
  27440. addUniform(name: string, size: number | number[]): void;
  27441. /**
  27442. * Adds a Matrix 4x4 to the uniform buffer.
  27443. * @param name Name of the uniform, as used in the uniform block in the shader.
  27444. * @param mat A 4x4 matrix.
  27445. */
  27446. addMatrix(name: string, mat: Matrix): void;
  27447. /**
  27448. * Adds a vec2 to the uniform buffer.
  27449. * @param name Name of the uniform, as used in the uniform block in the shader.
  27450. * @param x Define the x component value of the vec2
  27451. * @param y Define the y component value of the vec2
  27452. */
  27453. addFloat2(name: string, x: number, y: number): void;
  27454. /**
  27455. * Adds a vec3 to the uniform buffer.
  27456. * @param name Name of the uniform, as used in the uniform block in the shader.
  27457. * @param x Define the x component value of the vec3
  27458. * @param y Define the y component value of the vec3
  27459. * @param z Define the z component value of the vec3
  27460. */
  27461. addFloat3(name: string, x: number, y: number, z: number): void;
  27462. /**
  27463. * Adds a vec3 to the uniform buffer.
  27464. * @param name Name of the uniform, as used in the uniform block in the shader.
  27465. * @param color Define the vec3 from a Color
  27466. */
  27467. addColor3(name: string, color: Color3): void;
  27468. /**
  27469. * Adds a vec4 to the uniform buffer.
  27470. * @param name Name of the uniform, as used in the uniform block in the shader.
  27471. * @param color Define the rgb components from a Color
  27472. * @param alpha Define the a component of the vec4
  27473. */
  27474. addColor4(name: string, color: Color3, alpha: number): void;
  27475. /**
  27476. * Adds a vec3 to the uniform buffer.
  27477. * @param name Name of the uniform, as used in the uniform block in the shader.
  27478. * @param vector Define the vec3 components from a Vector
  27479. */
  27480. addVector3(name: string, vector: Vector3): void;
  27481. /**
  27482. * Adds a Matrix 3x3 to the uniform buffer.
  27483. * @param name Name of the uniform, as used in the uniform block in the shader.
  27484. */
  27485. addMatrix3x3(name: string): void;
  27486. /**
  27487. * Adds a Matrix 2x2 to the uniform buffer.
  27488. * @param name Name of the uniform, as used in the uniform block in the shader.
  27489. */
  27490. addMatrix2x2(name: string): void;
  27491. /**
  27492. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27493. */
  27494. create(): void;
  27495. /** @hidden */
  27496. _rebuild(): void;
  27497. /**
  27498. * Updates the WebGL Uniform Buffer on the GPU.
  27499. * If the `dynamic` flag is set to true, no cache comparison is done.
  27500. * Otherwise, the buffer will be updated only if the cache differs.
  27501. */
  27502. update(): void;
  27503. /**
  27504. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27505. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27506. * @param data Define the flattened data
  27507. * @param size Define the size of the data.
  27508. */
  27509. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27510. private _updateMatrix3x3ForUniform;
  27511. private _updateMatrix3x3ForEffect;
  27512. private _updateMatrix2x2ForEffect;
  27513. private _updateMatrix2x2ForUniform;
  27514. private _updateFloatForEffect;
  27515. private _updateFloatForUniform;
  27516. private _updateFloat2ForEffect;
  27517. private _updateFloat2ForUniform;
  27518. private _updateFloat3ForEffect;
  27519. private _updateFloat3ForUniform;
  27520. private _updateFloat4ForEffect;
  27521. private _updateFloat4ForUniform;
  27522. private _updateMatrixForEffect;
  27523. private _updateMatrixForUniform;
  27524. private _updateVector3ForEffect;
  27525. private _updateVector3ForUniform;
  27526. private _updateVector4ForEffect;
  27527. private _updateVector4ForUniform;
  27528. private _updateColor3ForEffect;
  27529. private _updateColor3ForUniform;
  27530. private _updateColor4ForEffect;
  27531. private _updateColor4ForUniform;
  27532. /**
  27533. * Sets a sampler uniform on the effect.
  27534. * @param name Define the name of the sampler.
  27535. * @param texture Define the texture to set in the sampler
  27536. */
  27537. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27538. /**
  27539. * Directly updates the value of the uniform in the cache AND on the GPU.
  27540. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27541. * @param data Define the flattened data
  27542. */
  27543. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27544. /**
  27545. * Binds this uniform buffer to an effect.
  27546. * @param effect Define the effect to bind the buffer to
  27547. * @param name Name of the uniform block in the shader.
  27548. */
  27549. bindToEffect(effect: Effect, name: string): void;
  27550. /**
  27551. * Disposes the uniform buffer.
  27552. */
  27553. dispose(): void;
  27554. }
  27555. }
  27556. declare module "babylonjs/Audio/analyser" {
  27557. import { Scene } from "babylonjs/scene";
  27558. /**
  27559. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27561. */
  27562. export class Analyser {
  27563. /**
  27564. * Gets or sets the smoothing
  27565. * @ignorenaming
  27566. */
  27567. SMOOTHING: number;
  27568. /**
  27569. * Gets or sets the FFT table size
  27570. * @ignorenaming
  27571. */
  27572. FFT_SIZE: number;
  27573. /**
  27574. * Gets or sets the bar graph amplitude
  27575. * @ignorenaming
  27576. */
  27577. BARGRAPHAMPLITUDE: number;
  27578. /**
  27579. * Gets or sets the position of the debug canvas
  27580. * @ignorenaming
  27581. */
  27582. DEBUGCANVASPOS: {
  27583. x: number;
  27584. y: number;
  27585. };
  27586. /**
  27587. * Gets or sets the debug canvas size
  27588. * @ignorenaming
  27589. */
  27590. DEBUGCANVASSIZE: {
  27591. width: number;
  27592. height: number;
  27593. };
  27594. private _byteFreqs;
  27595. private _byteTime;
  27596. private _floatFreqs;
  27597. private _webAudioAnalyser;
  27598. private _debugCanvas;
  27599. private _debugCanvasContext;
  27600. private _scene;
  27601. private _registerFunc;
  27602. private _audioEngine;
  27603. /**
  27604. * Creates a new analyser
  27605. * @param scene defines hosting scene
  27606. */
  27607. constructor(scene: Scene);
  27608. /**
  27609. * Get the number of data values you will have to play with for the visualization
  27610. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27611. * @returns a number
  27612. */
  27613. getFrequencyBinCount(): number;
  27614. /**
  27615. * Gets the current frequency data as a byte array
  27616. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27617. * @returns a Uint8Array
  27618. */
  27619. getByteFrequencyData(): Uint8Array;
  27620. /**
  27621. * Gets the current waveform as a byte array
  27622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27623. * @returns a Uint8Array
  27624. */
  27625. getByteTimeDomainData(): Uint8Array;
  27626. /**
  27627. * Gets the current frequency data as a float array
  27628. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27629. * @returns a Float32Array
  27630. */
  27631. getFloatFrequencyData(): Float32Array;
  27632. /**
  27633. * Renders the debug canvas
  27634. */
  27635. drawDebugCanvas(): void;
  27636. /**
  27637. * Stops rendering the debug canvas and removes it
  27638. */
  27639. stopDebugCanvas(): void;
  27640. /**
  27641. * Connects two audio nodes
  27642. * @param inputAudioNode defines first node to connect
  27643. * @param outputAudioNode defines second node to connect
  27644. */
  27645. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27646. /**
  27647. * Releases all associated resources
  27648. */
  27649. dispose(): void;
  27650. }
  27651. }
  27652. declare module "babylonjs/Audio/audioEngine" {
  27653. import { IDisposable } from "babylonjs/scene";
  27654. import { Analyser } from "babylonjs/Audio/analyser";
  27655. import { Nullable } from "babylonjs/types";
  27656. import { Observable } from "babylonjs/Misc/observable";
  27657. /**
  27658. * This represents an audio engine and it is responsible
  27659. * to play, synchronize and analyse sounds throughout the application.
  27660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27661. */
  27662. export interface IAudioEngine extends IDisposable {
  27663. /**
  27664. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27665. */
  27666. readonly canUseWebAudio: boolean;
  27667. /**
  27668. * Gets the current AudioContext if available.
  27669. */
  27670. readonly audioContext: Nullable<AudioContext>;
  27671. /**
  27672. * The master gain node defines the global audio volume of your audio engine.
  27673. */
  27674. readonly masterGain: GainNode;
  27675. /**
  27676. * Gets whether or not mp3 are supported by your browser.
  27677. */
  27678. readonly isMP3supported: boolean;
  27679. /**
  27680. * Gets whether or not ogg are supported by your browser.
  27681. */
  27682. readonly isOGGsupported: boolean;
  27683. /**
  27684. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27685. * @ignoreNaming
  27686. */
  27687. WarnedWebAudioUnsupported: boolean;
  27688. /**
  27689. * Defines if the audio engine relies on a custom unlocked button.
  27690. * In this case, the embedded button will not be displayed.
  27691. */
  27692. useCustomUnlockedButton: boolean;
  27693. /**
  27694. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27695. */
  27696. readonly unlocked: boolean;
  27697. /**
  27698. * Event raised when audio has been unlocked on the browser.
  27699. */
  27700. onAudioUnlockedObservable: Observable<AudioEngine>;
  27701. /**
  27702. * Event raised when audio has been locked on the browser.
  27703. */
  27704. onAudioLockedObservable: Observable<AudioEngine>;
  27705. /**
  27706. * Flags the audio engine in Locked state.
  27707. * This happens due to new browser policies preventing audio to autoplay.
  27708. */
  27709. lock(): void;
  27710. /**
  27711. * Unlocks the audio engine once a user action has been done on the dom.
  27712. * This is helpful to resume play once browser policies have been satisfied.
  27713. */
  27714. unlock(): void;
  27715. }
  27716. /**
  27717. * This represents the default audio engine used in babylon.
  27718. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27720. */
  27721. export class AudioEngine implements IAudioEngine {
  27722. private _audioContext;
  27723. private _audioContextInitialized;
  27724. private _muteButton;
  27725. private _hostElement;
  27726. /**
  27727. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27728. */
  27729. canUseWebAudio: boolean;
  27730. /**
  27731. * The master gain node defines the global audio volume of your audio engine.
  27732. */
  27733. masterGain: GainNode;
  27734. /**
  27735. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27736. * @ignoreNaming
  27737. */
  27738. WarnedWebAudioUnsupported: boolean;
  27739. /**
  27740. * Gets whether or not mp3 are supported by your browser.
  27741. */
  27742. isMP3supported: boolean;
  27743. /**
  27744. * Gets whether or not ogg are supported by your browser.
  27745. */
  27746. isOGGsupported: boolean;
  27747. /**
  27748. * Gets whether audio has been unlocked on the device.
  27749. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27750. * a user interaction has happened.
  27751. */
  27752. unlocked: boolean;
  27753. /**
  27754. * Defines if the audio engine relies on a custom unlocked button.
  27755. * In this case, the embedded button will not be displayed.
  27756. */
  27757. useCustomUnlockedButton: boolean;
  27758. /**
  27759. * Event raised when audio has been unlocked on the browser.
  27760. */
  27761. onAudioUnlockedObservable: Observable<AudioEngine>;
  27762. /**
  27763. * Event raised when audio has been locked on the browser.
  27764. */
  27765. onAudioLockedObservable: Observable<AudioEngine>;
  27766. /**
  27767. * Gets the current AudioContext if available.
  27768. */
  27769. readonly audioContext: Nullable<AudioContext>;
  27770. private _connectedAnalyser;
  27771. /**
  27772. * Instantiates a new audio engine.
  27773. *
  27774. * There should be only one per page as some browsers restrict the number
  27775. * of audio contexts you can create.
  27776. * @param hostElement defines the host element where to display the mute icon if necessary
  27777. */
  27778. constructor(hostElement?: Nullable<HTMLElement>);
  27779. /**
  27780. * Flags the audio engine in Locked state.
  27781. * This happens due to new browser policies preventing audio to autoplay.
  27782. */
  27783. lock(): void;
  27784. /**
  27785. * Unlocks the audio engine once a user action has been done on the dom.
  27786. * This is helpful to resume play once browser policies have been satisfied.
  27787. */
  27788. unlock(): void;
  27789. private _resumeAudioContext;
  27790. private _initializeAudioContext;
  27791. private _tryToRun;
  27792. private _triggerRunningState;
  27793. private _triggerSuspendedState;
  27794. private _displayMuteButton;
  27795. private _moveButtonToTopLeft;
  27796. private _onResize;
  27797. private _hideMuteButton;
  27798. /**
  27799. * Destroy and release the resources associated with the audio ccontext.
  27800. */
  27801. dispose(): void;
  27802. /**
  27803. * Gets the global volume sets on the master gain.
  27804. * @returns the global volume if set or -1 otherwise
  27805. */
  27806. getGlobalVolume(): number;
  27807. /**
  27808. * Sets the global volume of your experience (sets on the master gain).
  27809. * @param newVolume Defines the new global volume of the application
  27810. */
  27811. setGlobalVolume(newVolume: number): void;
  27812. /**
  27813. * Connect the audio engine to an audio analyser allowing some amazing
  27814. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27816. * @param analyser The analyser to connect to the engine
  27817. */
  27818. connectToAnalyser(analyser: Analyser): void;
  27819. }
  27820. }
  27821. declare module "babylonjs/Loading/loadingScreen" {
  27822. /**
  27823. * Interface used to present a loading screen while loading a scene
  27824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27825. */
  27826. export interface ILoadingScreen {
  27827. /**
  27828. * Function called to display the loading screen
  27829. */
  27830. displayLoadingUI: () => void;
  27831. /**
  27832. * Function called to hide the loading screen
  27833. */
  27834. hideLoadingUI: () => void;
  27835. /**
  27836. * Gets or sets the color to use for the background
  27837. */
  27838. loadingUIBackgroundColor: string;
  27839. /**
  27840. * Gets or sets the text to display while loading
  27841. */
  27842. loadingUIText: string;
  27843. }
  27844. /**
  27845. * Class used for the default loading screen
  27846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27847. */
  27848. export class DefaultLoadingScreen implements ILoadingScreen {
  27849. private _renderingCanvas;
  27850. private _loadingText;
  27851. private _loadingDivBackgroundColor;
  27852. private _loadingDiv;
  27853. private _loadingTextDiv;
  27854. /** Gets or sets the logo url to use for the default loading screen */
  27855. static DefaultLogoUrl: string;
  27856. /** Gets or sets the spinner url to use for the default loading screen */
  27857. static DefaultSpinnerUrl: string;
  27858. /**
  27859. * Creates a new default loading screen
  27860. * @param _renderingCanvas defines the canvas used to render the scene
  27861. * @param _loadingText defines the default text to display
  27862. * @param _loadingDivBackgroundColor defines the default background color
  27863. */
  27864. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27865. /**
  27866. * Function called to display the loading screen
  27867. */
  27868. displayLoadingUI(): void;
  27869. /**
  27870. * Function called to hide the loading screen
  27871. */
  27872. hideLoadingUI(): void;
  27873. /**
  27874. * Gets or sets the text to display while loading
  27875. */
  27876. loadingUIText: string;
  27877. /**
  27878. * Gets or sets the color to use for the background
  27879. */
  27880. loadingUIBackgroundColor: string;
  27881. private _resizeLoadingUI;
  27882. }
  27883. }
  27884. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27885. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27886. import { Engine } from "babylonjs/Engines/engine";
  27887. import { Nullable } from "babylonjs/types";
  27888. /** @hidden */
  27889. export class WebGLPipelineContext implements IPipelineContext {
  27890. engine: Engine;
  27891. program: Nullable<WebGLProgram>;
  27892. context?: WebGLRenderingContext;
  27893. vertexShader?: WebGLShader;
  27894. fragmentShader?: WebGLShader;
  27895. isParallelCompiled: boolean;
  27896. onCompiled?: () => void;
  27897. transformFeedback?: WebGLTransformFeedback | null;
  27898. readonly isAsync: boolean;
  27899. readonly isReady: boolean;
  27900. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27901. }
  27902. }
  27903. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27904. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27905. /** @hidden */
  27906. export class WebGLDataBuffer extends DataBuffer {
  27907. private _buffer;
  27908. constructor(resource: WebGLBuffer);
  27909. readonly underlyingResource: any;
  27910. }
  27911. }
  27912. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27913. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27914. /** @hidden */
  27915. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27916. attributeProcessor(attribute: string): string;
  27917. varyingProcessor(varying: string, isFragment: boolean): string;
  27918. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27919. }
  27920. }
  27921. declare module "babylonjs/Materials/Textures/videoTexture" {
  27922. import { Observable } from "babylonjs/Misc/observable";
  27923. import { Nullable } from "babylonjs/types";
  27924. import { Scene } from "babylonjs/scene";
  27925. import { Texture } from "babylonjs/Materials/Textures/texture";
  27926. /**
  27927. * Settings for finer control over video usage
  27928. */
  27929. export interface VideoTextureSettings {
  27930. /**
  27931. * Applies `autoplay` to video, if specified
  27932. */
  27933. autoPlay?: boolean;
  27934. /**
  27935. * Applies `loop` to video, if specified
  27936. */
  27937. loop?: boolean;
  27938. /**
  27939. * Automatically updates internal texture from video at every frame in the render loop
  27940. */
  27941. autoUpdateTexture: boolean;
  27942. /**
  27943. * Image src displayed during the video loading or until the user interacts with the video.
  27944. */
  27945. poster?: string;
  27946. }
  27947. /**
  27948. * If you want to display a video in your scene, this is the special texture for that.
  27949. * This special texture works similar to other textures, with the exception of a few parameters.
  27950. * @see https://doc.babylonjs.com/how_to/video_texture
  27951. */
  27952. export class VideoTexture extends Texture {
  27953. /**
  27954. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27955. */
  27956. readonly autoUpdateTexture: boolean;
  27957. /**
  27958. * The video instance used by the texture internally
  27959. */
  27960. readonly video: HTMLVideoElement;
  27961. private _onUserActionRequestedObservable;
  27962. /**
  27963. * Event triggerd when a dom action is required by the user to play the video.
  27964. * This happens due to recent changes in browser policies preventing video to auto start.
  27965. */
  27966. readonly onUserActionRequestedObservable: Observable<Texture>;
  27967. private _generateMipMaps;
  27968. private _engine;
  27969. private _stillImageCaptured;
  27970. private _displayingPosterTexture;
  27971. private _settings;
  27972. private _createInternalTextureOnEvent;
  27973. /**
  27974. * Creates a video texture.
  27975. * If you want to display a video in your scene, this is the special texture for that.
  27976. * This special texture works similar to other textures, with the exception of a few parameters.
  27977. * @see https://doc.babylonjs.com/how_to/video_texture
  27978. * @param name optional name, will detect from video source, if not defined
  27979. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27980. * @param scene is obviously the current scene.
  27981. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27982. * @param invertY is false by default but can be used to invert video on Y axis
  27983. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27984. * @param settings allows finer control over video usage
  27985. */
  27986. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27987. private _getName;
  27988. private _getVideo;
  27989. private _createInternalTexture;
  27990. private reset;
  27991. /**
  27992. * @hidden Internal method to initiate `update`.
  27993. */
  27994. _rebuild(): void;
  27995. /**
  27996. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27997. */
  27998. update(): void;
  27999. /**
  28000. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28001. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28002. */
  28003. updateTexture(isVisible: boolean): void;
  28004. protected _updateInternalTexture: () => void;
  28005. /**
  28006. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28007. * @param url New url.
  28008. */
  28009. updateURL(url: string): void;
  28010. /**
  28011. * Dispose the texture and release its associated resources.
  28012. */
  28013. dispose(): void;
  28014. /**
  28015. * Creates a video texture straight from a stream.
  28016. * @param scene Define the scene the texture should be created in
  28017. * @param stream Define the stream the texture should be created from
  28018. * @returns The created video texture as a promise
  28019. */
  28020. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28021. /**
  28022. * Creates a video texture straight from your WebCam video feed.
  28023. * @param scene Define the scene the texture should be created in
  28024. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28025. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28026. * @returns The created video texture as a promise
  28027. */
  28028. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28029. minWidth: number;
  28030. maxWidth: number;
  28031. minHeight: number;
  28032. maxHeight: number;
  28033. deviceId: string;
  28034. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28035. /**
  28036. * Creates a video texture straight from your WebCam video feed.
  28037. * @param scene Define the scene the texture should be created in
  28038. * @param onReady Define a callback to triggered once the texture will be ready
  28039. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28040. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28041. */
  28042. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28043. minWidth: number;
  28044. maxWidth: number;
  28045. minHeight: number;
  28046. maxHeight: number;
  28047. deviceId: string;
  28048. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28049. }
  28050. }
  28051. declare module "babylonjs/Engines/engine" {
  28052. import { Observable } from "babylonjs/Misc/observable";
  28053. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28054. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28055. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28056. import { Camera } from "babylonjs/Cameras/camera";
  28057. import { Scene } from "babylonjs/scene";
  28058. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28059. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28060. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28061. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28062. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28063. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28064. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28065. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28066. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28067. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28068. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28069. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28070. import { WebRequest } from "babylonjs/Misc/webRequest";
  28071. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28072. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28073. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28074. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28075. import { Material } from "babylonjs/Materials/material";
  28076. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28077. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28078. /**
  28079. * Interface for attribute information associated with buffer instanciation
  28080. */
  28081. export class InstancingAttributeInfo {
  28082. /**
  28083. * Index/offset of the attribute in the vertex shader
  28084. */
  28085. index: number;
  28086. /**
  28087. * size of the attribute, 1, 2, 3 or 4
  28088. */
  28089. attributeSize: number;
  28090. /**
  28091. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28092. * default is FLOAT
  28093. */
  28094. attribyteType: number;
  28095. /**
  28096. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28097. */
  28098. normalized: boolean;
  28099. /**
  28100. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28101. */
  28102. offset: number;
  28103. /**
  28104. * Name of the GLSL attribute, for debugging purpose only
  28105. */
  28106. attributeName: string;
  28107. }
  28108. /**
  28109. * Define options used to create a depth texture
  28110. */
  28111. export class DepthTextureCreationOptions {
  28112. /** Specifies whether or not a stencil should be allocated in the texture */
  28113. generateStencil?: boolean;
  28114. /** Specifies whether or not bilinear filtering is enable on the texture */
  28115. bilinearFiltering?: boolean;
  28116. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28117. comparisonFunction?: number;
  28118. /** Specifies if the created texture is a cube texture */
  28119. isCube?: boolean;
  28120. }
  28121. /**
  28122. * Class used to describe the capabilities of the engine relatively to the current browser
  28123. */
  28124. export class EngineCapabilities {
  28125. /** Maximum textures units per fragment shader */
  28126. maxTexturesImageUnits: number;
  28127. /** Maximum texture units per vertex shader */
  28128. maxVertexTextureImageUnits: number;
  28129. /** Maximum textures units in the entire pipeline */
  28130. maxCombinedTexturesImageUnits: number;
  28131. /** Maximum texture size */
  28132. maxTextureSize: number;
  28133. /** Maximum cube texture size */
  28134. maxCubemapTextureSize: number;
  28135. /** Maximum render texture size */
  28136. maxRenderTextureSize: number;
  28137. /** Maximum number of vertex attributes */
  28138. maxVertexAttribs: number;
  28139. /** Maximum number of varyings */
  28140. maxVaryingVectors: number;
  28141. /** Maximum number of uniforms per vertex shader */
  28142. maxVertexUniformVectors: number;
  28143. /** Maximum number of uniforms per fragment shader */
  28144. maxFragmentUniformVectors: number;
  28145. /** Defines if standard derivates (dx/dy) are supported */
  28146. standardDerivatives: boolean;
  28147. /** Defines if s3tc texture compression is supported */
  28148. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28149. /** Defines if pvrtc texture compression is supported */
  28150. pvrtc: any;
  28151. /** Defines if etc1 texture compression is supported */
  28152. etc1: any;
  28153. /** Defines if etc2 texture compression is supported */
  28154. etc2: any;
  28155. /** Defines if astc texture compression is supported */
  28156. astc: any;
  28157. /** Defines if float textures are supported */
  28158. textureFloat: boolean;
  28159. /** Defines if vertex array objects are supported */
  28160. vertexArrayObject: boolean;
  28161. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28162. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28163. /** Gets the maximum level of anisotropy supported */
  28164. maxAnisotropy: number;
  28165. /** Defines if instancing is supported */
  28166. instancedArrays: boolean;
  28167. /** Defines if 32 bits indices are supported */
  28168. uintIndices: boolean;
  28169. /** Defines if high precision shaders are supported */
  28170. highPrecisionShaderSupported: boolean;
  28171. /** Defines if depth reading in the fragment shader is supported */
  28172. fragmentDepthSupported: boolean;
  28173. /** Defines if float texture linear filtering is supported*/
  28174. textureFloatLinearFiltering: boolean;
  28175. /** Defines if rendering to float textures is supported */
  28176. textureFloatRender: boolean;
  28177. /** Defines if half float textures are supported*/
  28178. textureHalfFloat: boolean;
  28179. /** Defines if half float texture linear filtering is supported*/
  28180. textureHalfFloatLinearFiltering: boolean;
  28181. /** Defines if rendering to half float textures is supported */
  28182. textureHalfFloatRender: boolean;
  28183. /** Defines if textureLOD shader command is supported */
  28184. textureLOD: boolean;
  28185. /** Defines if draw buffers extension is supported */
  28186. drawBuffersExtension: boolean;
  28187. /** Defines if depth textures are supported */
  28188. depthTextureExtension: boolean;
  28189. /** Defines if float color buffer are supported */
  28190. colorBufferFloat: boolean;
  28191. /** Gets disjoint timer query extension (null if not supported) */
  28192. timerQuery: EXT_disjoint_timer_query;
  28193. /** Defines if timestamp can be used with timer query */
  28194. canUseTimestampForTimerQuery: boolean;
  28195. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28196. multiview: any;
  28197. /** Function used to let the system compiles shaders in background */
  28198. parallelShaderCompile: {
  28199. COMPLETION_STATUS_KHR: number;
  28200. };
  28201. }
  28202. /** Interface defining initialization parameters for Engine class */
  28203. export interface EngineOptions extends WebGLContextAttributes {
  28204. /**
  28205. * Defines if the engine should no exceed a specified device ratio
  28206. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28207. */
  28208. limitDeviceRatio?: number;
  28209. /**
  28210. * Defines if webvr should be enabled automatically
  28211. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28212. */
  28213. autoEnableWebVR?: boolean;
  28214. /**
  28215. * Defines if webgl2 should be turned off even if supported
  28216. * @see http://doc.babylonjs.com/features/webgl2
  28217. */
  28218. disableWebGL2Support?: boolean;
  28219. /**
  28220. * Defines if webaudio should be initialized as well
  28221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28222. */
  28223. audioEngine?: boolean;
  28224. /**
  28225. * Defines if animations should run using a deterministic lock step
  28226. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28227. */
  28228. deterministicLockstep?: boolean;
  28229. /** Defines the maximum steps to use with deterministic lock step mode */
  28230. lockstepMaxSteps?: number;
  28231. /**
  28232. * Defines that engine should ignore context lost events
  28233. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28234. */
  28235. doNotHandleContextLost?: boolean;
  28236. /**
  28237. * Defines that engine should ignore modifying touch action attribute and style
  28238. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28239. */
  28240. doNotHandleTouchAction?: boolean;
  28241. /**
  28242. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28243. */
  28244. useHighPrecisionFloats?: boolean;
  28245. }
  28246. /**
  28247. * Defines the interface used by display changed events
  28248. */
  28249. export interface IDisplayChangedEventArgs {
  28250. /** Gets the vrDisplay object (if any) */
  28251. vrDisplay: Nullable<any>;
  28252. /** Gets a boolean indicating if webVR is supported */
  28253. vrSupported: boolean;
  28254. }
  28255. /**
  28256. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28257. */
  28258. export class Engine {
  28259. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28260. static ExceptionList: ({
  28261. key: string;
  28262. capture: string;
  28263. captureConstraint: number;
  28264. targets: string[];
  28265. } | {
  28266. key: string;
  28267. capture: null;
  28268. captureConstraint: null;
  28269. targets: string[];
  28270. })[];
  28271. /** Gets the list of created engines */
  28272. static readonly Instances: Engine[];
  28273. /**
  28274. * Gets the latest created engine
  28275. */
  28276. static readonly LastCreatedEngine: Nullable<Engine>;
  28277. /**
  28278. * Gets the latest created scene
  28279. */
  28280. static readonly LastCreatedScene: Nullable<Scene>;
  28281. /**
  28282. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28283. * @param flag defines which part of the materials must be marked as dirty
  28284. * @param predicate defines a predicate used to filter which materials should be affected
  28285. */
  28286. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28287. /** @hidden */
  28288. static _TextureLoaders: IInternalTextureLoader[];
  28289. /** Defines that alpha blending is disabled */
  28290. static readonly ALPHA_DISABLE: number;
  28291. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28292. static readonly ALPHA_ADD: number;
  28293. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28294. static readonly ALPHA_COMBINE: number;
  28295. /** Defines that alpha blending to DEST - SRC * DEST */
  28296. static readonly ALPHA_SUBTRACT: number;
  28297. /** Defines that alpha blending to SRC * DEST */
  28298. static readonly ALPHA_MULTIPLY: number;
  28299. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28300. static readonly ALPHA_MAXIMIZED: number;
  28301. /** Defines that alpha blending to SRC + DEST */
  28302. static readonly ALPHA_ONEONE: number;
  28303. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28304. static readonly ALPHA_PREMULTIPLIED: number;
  28305. /**
  28306. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28307. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28308. */
  28309. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28310. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28311. static readonly ALPHA_INTERPOLATE: number;
  28312. /**
  28313. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28314. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28315. */
  28316. static readonly ALPHA_SCREENMODE: number;
  28317. /** Defines that the ressource is not delayed*/
  28318. static readonly DELAYLOADSTATE_NONE: number;
  28319. /** Defines that the ressource was successfully delay loaded */
  28320. static readonly DELAYLOADSTATE_LOADED: number;
  28321. /** Defines that the ressource is currently delay loading */
  28322. static readonly DELAYLOADSTATE_LOADING: number;
  28323. /** Defines that the ressource is delayed and has not started loading */
  28324. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28325. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28326. static readonly NEVER: number;
  28327. /** 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 */
  28328. static readonly ALWAYS: number;
  28329. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28330. static readonly LESS: number;
  28331. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28332. static readonly EQUAL: number;
  28333. /** 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 */
  28334. static readonly LEQUAL: number;
  28335. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28336. static readonly GREATER: number;
  28337. /** 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 */
  28338. static readonly GEQUAL: number;
  28339. /** 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 */
  28340. static readonly NOTEQUAL: number;
  28341. /** Passed to stencilOperation to specify that stencil value must be kept */
  28342. static readonly KEEP: number;
  28343. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28344. static readonly REPLACE: number;
  28345. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28346. static readonly INCR: number;
  28347. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28348. static readonly DECR: number;
  28349. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28350. static readonly INVERT: number;
  28351. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28352. static readonly INCR_WRAP: number;
  28353. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28354. static readonly DECR_WRAP: number;
  28355. /** Texture is not repeating outside of 0..1 UVs */
  28356. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28357. /** Texture is repeating outside of 0..1 UVs */
  28358. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28359. /** Texture is repeating and mirrored */
  28360. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28361. /** ALPHA */
  28362. static readonly TEXTUREFORMAT_ALPHA: number;
  28363. /** LUMINANCE */
  28364. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28365. /** LUMINANCE_ALPHA */
  28366. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28367. /** RGB */
  28368. static readonly TEXTUREFORMAT_RGB: number;
  28369. /** RGBA */
  28370. static readonly TEXTUREFORMAT_RGBA: number;
  28371. /** RED */
  28372. static readonly TEXTUREFORMAT_RED: number;
  28373. /** RED (2nd reference) */
  28374. static readonly TEXTUREFORMAT_R: number;
  28375. /** RG */
  28376. static readonly TEXTUREFORMAT_RG: number;
  28377. /** RED_INTEGER */
  28378. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28379. /** RED_INTEGER (2nd reference) */
  28380. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28381. /** RG_INTEGER */
  28382. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28383. /** RGB_INTEGER */
  28384. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28385. /** RGBA_INTEGER */
  28386. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28387. /** UNSIGNED_BYTE */
  28388. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28389. /** UNSIGNED_BYTE (2nd reference) */
  28390. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28391. /** FLOAT */
  28392. static readonly TEXTURETYPE_FLOAT: number;
  28393. /** HALF_FLOAT */
  28394. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28395. /** BYTE */
  28396. static readonly TEXTURETYPE_BYTE: number;
  28397. /** SHORT */
  28398. static readonly TEXTURETYPE_SHORT: number;
  28399. /** UNSIGNED_SHORT */
  28400. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28401. /** INT */
  28402. static readonly TEXTURETYPE_INT: number;
  28403. /** UNSIGNED_INT */
  28404. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28405. /** UNSIGNED_SHORT_4_4_4_4 */
  28406. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28407. /** UNSIGNED_SHORT_5_5_5_1 */
  28408. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28409. /** UNSIGNED_SHORT_5_6_5 */
  28410. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28411. /** UNSIGNED_INT_2_10_10_10_REV */
  28412. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28413. /** UNSIGNED_INT_24_8 */
  28414. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28415. /** UNSIGNED_INT_10F_11F_11F_REV */
  28416. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28417. /** UNSIGNED_INT_5_9_9_9_REV */
  28418. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28419. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28420. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28421. /** nearest is mag = nearest and min = nearest and mip = linear */
  28422. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28423. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28424. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28425. /** Trilinear is mag = linear and min = linear and mip = linear */
  28426. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28427. /** nearest is mag = nearest and min = nearest and mip = linear */
  28428. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28429. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28430. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28431. /** Trilinear is mag = linear and min = linear and mip = linear */
  28432. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28433. /** mag = nearest and min = nearest and mip = nearest */
  28434. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28435. /** mag = nearest and min = linear and mip = nearest */
  28436. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28437. /** mag = nearest and min = linear and mip = linear */
  28438. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28439. /** mag = nearest and min = linear and mip = none */
  28440. static readonly TEXTURE_NEAREST_LINEAR: number;
  28441. /** mag = nearest and min = nearest and mip = none */
  28442. static readonly TEXTURE_NEAREST_NEAREST: number;
  28443. /** mag = linear and min = nearest and mip = nearest */
  28444. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28445. /** mag = linear and min = nearest and mip = linear */
  28446. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28447. /** mag = linear and min = linear and mip = none */
  28448. static readonly TEXTURE_LINEAR_LINEAR: number;
  28449. /** mag = linear and min = nearest and mip = none */
  28450. static readonly TEXTURE_LINEAR_NEAREST: number;
  28451. /** Explicit coordinates mode */
  28452. static readonly TEXTURE_EXPLICIT_MODE: number;
  28453. /** Spherical coordinates mode */
  28454. static readonly TEXTURE_SPHERICAL_MODE: number;
  28455. /** Planar coordinates mode */
  28456. static readonly TEXTURE_PLANAR_MODE: number;
  28457. /** Cubic coordinates mode */
  28458. static readonly TEXTURE_CUBIC_MODE: number;
  28459. /** Projection coordinates mode */
  28460. static readonly TEXTURE_PROJECTION_MODE: number;
  28461. /** Skybox coordinates mode */
  28462. static readonly TEXTURE_SKYBOX_MODE: number;
  28463. /** Inverse Cubic coordinates mode */
  28464. static readonly TEXTURE_INVCUBIC_MODE: number;
  28465. /** Equirectangular coordinates mode */
  28466. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28467. /** Equirectangular Fixed coordinates mode */
  28468. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28469. /** Equirectangular Fixed Mirrored coordinates mode */
  28470. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28471. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28472. static readonly SCALEMODE_FLOOR: number;
  28473. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28474. static readonly SCALEMODE_NEAREST: number;
  28475. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28476. static readonly SCALEMODE_CEILING: number;
  28477. /**
  28478. * Returns the current npm package of the sdk
  28479. */
  28480. static readonly NpmPackage: string;
  28481. /**
  28482. * Returns the current version of the framework
  28483. */
  28484. static readonly Version: string;
  28485. /**
  28486. * Returns a string describing the current engine
  28487. */
  28488. readonly description: string;
  28489. /**
  28490. * Gets or sets the epsilon value used by collision engine
  28491. */
  28492. static CollisionsEpsilon: number;
  28493. /**
  28494. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28495. */
  28496. static ShadersRepository: string;
  28497. /**
  28498. * Method called to create the default loading screen.
  28499. * This can be overriden in your own app.
  28500. * @param canvas The rendering canvas element
  28501. * @returns The loading screen
  28502. */
  28503. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28504. /**
  28505. * Method called to create the default rescale post process on each engine.
  28506. */
  28507. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28508. /** @hidden */
  28509. _shaderProcessor: IShaderProcessor;
  28510. /**
  28511. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28512. */
  28513. forcePOTTextures: boolean;
  28514. /**
  28515. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28516. */
  28517. isFullscreen: boolean;
  28518. /**
  28519. * Gets a boolean indicating if the pointer is currently locked
  28520. */
  28521. isPointerLock: boolean;
  28522. /**
  28523. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28524. */
  28525. cullBackFaces: boolean;
  28526. /**
  28527. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28528. */
  28529. renderEvenInBackground: boolean;
  28530. /**
  28531. * Gets or sets a boolean indicating that cache can be kept between frames
  28532. */
  28533. preventCacheWipeBetweenFrames: boolean;
  28534. /**
  28535. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28536. **/
  28537. enableOfflineSupport: boolean;
  28538. /**
  28539. * 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)
  28540. **/
  28541. disableManifestCheck: boolean;
  28542. /**
  28543. * Gets the list of created scenes
  28544. */
  28545. scenes: Scene[];
  28546. /**
  28547. * Event raised when a new scene is created
  28548. */
  28549. onNewSceneAddedObservable: Observable<Scene>;
  28550. /**
  28551. * Gets the list of created postprocesses
  28552. */
  28553. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28554. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28555. validateShaderPrograms: boolean;
  28556. /**
  28557. * Observable event triggered each time the rendering canvas is resized
  28558. */
  28559. onResizeObservable: Observable<Engine>;
  28560. /**
  28561. * Observable event triggered each time the canvas loses focus
  28562. */
  28563. onCanvasBlurObservable: Observable<Engine>;
  28564. /**
  28565. * Observable event triggered each time the canvas gains focus
  28566. */
  28567. onCanvasFocusObservable: Observable<Engine>;
  28568. /**
  28569. * Observable event triggered each time the canvas receives pointerout event
  28570. */
  28571. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28572. /**
  28573. * Observable event triggered before each texture is initialized
  28574. */
  28575. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28576. /**
  28577. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28578. */
  28579. disableUniformBuffers: boolean;
  28580. /** @hidden */
  28581. _uniformBuffers: UniformBuffer[];
  28582. /**
  28583. * Gets a boolean indicating that the engine supports uniform buffers
  28584. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28585. */
  28586. readonly supportsUniformBuffers: boolean;
  28587. /**
  28588. * Observable raised when the engine begins a new frame
  28589. */
  28590. onBeginFrameObservable: Observable<Engine>;
  28591. /**
  28592. * If set, will be used to request the next animation frame for the render loop
  28593. */
  28594. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28595. /**
  28596. * Observable raised when the engine ends the current frame
  28597. */
  28598. onEndFrameObservable: Observable<Engine>;
  28599. /**
  28600. * Observable raised when the engine is about to compile a shader
  28601. */
  28602. onBeforeShaderCompilationObservable: Observable<Engine>;
  28603. /**
  28604. * Observable raised when the engine has jsut compiled a shader
  28605. */
  28606. onAfterShaderCompilationObservable: Observable<Engine>;
  28607. /** @hidden */
  28608. _gl: WebGLRenderingContext;
  28609. private _renderingCanvas;
  28610. private _windowIsBackground;
  28611. private _webGLVersion;
  28612. protected _highPrecisionShadersAllowed: boolean;
  28613. /** @hidden */
  28614. readonly _shouldUseHighPrecisionShader: boolean;
  28615. /**
  28616. * Gets a boolean indicating that only power of 2 textures are supported
  28617. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28618. */
  28619. readonly needPOTTextures: boolean;
  28620. /** @hidden */
  28621. _badOS: boolean;
  28622. /** @hidden */
  28623. _badDesktopOS: boolean;
  28624. /**
  28625. * Gets the audio engine
  28626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28627. * @ignorenaming
  28628. */
  28629. static audioEngine: IAudioEngine;
  28630. /**
  28631. * Default AudioEngine factory responsible of creating the Audio Engine.
  28632. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28633. */
  28634. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28635. /**
  28636. * Default offline support factory responsible of creating a tool used to store data locally.
  28637. * By default, this will create a Database object if the workload has been embedded.
  28638. */
  28639. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28640. private _onFocus;
  28641. private _onBlur;
  28642. private _onCanvasPointerOut;
  28643. private _onCanvasBlur;
  28644. private _onCanvasFocus;
  28645. private _onFullscreenChange;
  28646. private _onPointerLockChange;
  28647. private _hardwareScalingLevel;
  28648. /** @hidden */
  28649. _caps: EngineCapabilities;
  28650. private _pointerLockRequested;
  28651. private _isStencilEnable;
  28652. private _colorWrite;
  28653. private _loadingScreen;
  28654. /** @hidden */
  28655. _drawCalls: PerfCounter;
  28656. private _glVersion;
  28657. private _glRenderer;
  28658. private _glVendor;
  28659. private _videoTextureSupported;
  28660. private _renderingQueueLaunched;
  28661. private _activeRenderLoops;
  28662. private _deterministicLockstep;
  28663. private _lockstepMaxSteps;
  28664. /**
  28665. * Observable signaled when a context lost event is raised
  28666. */
  28667. onContextLostObservable: Observable<Engine>;
  28668. /**
  28669. * Observable signaled when a context restored event is raised
  28670. */
  28671. onContextRestoredObservable: Observable<Engine>;
  28672. private _onContextLost;
  28673. private _onContextRestored;
  28674. private _contextWasLost;
  28675. /** @hidden */
  28676. _doNotHandleContextLost: boolean;
  28677. /**
  28678. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28680. */
  28681. doNotHandleContextLost: boolean;
  28682. private _performanceMonitor;
  28683. private _fps;
  28684. private _deltaTime;
  28685. /**
  28686. * Turn this value on if you want to pause FPS computation when in background
  28687. */
  28688. disablePerformanceMonitorInBackground: boolean;
  28689. /**
  28690. * Gets the performance monitor attached to this engine
  28691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28692. */
  28693. readonly performanceMonitor: PerformanceMonitor;
  28694. /**
  28695. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28696. */
  28697. disableVertexArrayObjects: boolean;
  28698. /** @hidden */
  28699. protected _depthCullingState: _DepthCullingState;
  28700. /** @hidden */
  28701. protected _stencilState: _StencilState;
  28702. /** @hidden */
  28703. protected _alphaState: _AlphaState;
  28704. /** @hidden */
  28705. protected _alphaMode: number;
  28706. /** @hidden */
  28707. _internalTexturesCache: InternalTexture[];
  28708. /** @hidden */
  28709. protected _activeChannel: number;
  28710. private _currentTextureChannel;
  28711. /** @hidden */
  28712. protected _boundTexturesCache: {
  28713. [key: string]: Nullable<InternalTexture>;
  28714. };
  28715. /** @hidden */
  28716. protected _currentEffect: Nullable<Effect>;
  28717. /** @hidden */
  28718. protected _currentProgram: Nullable<WebGLProgram>;
  28719. private _compiledEffects;
  28720. private _vertexAttribArraysEnabled;
  28721. /** @hidden */
  28722. protected _cachedViewport: Nullable<Viewport>;
  28723. private _cachedVertexArrayObject;
  28724. /** @hidden */
  28725. protected _cachedVertexBuffers: any;
  28726. /** @hidden */
  28727. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28728. /** @hidden */
  28729. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28730. /** @hidden */
  28731. _currentRenderTarget: Nullable<InternalTexture>;
  28732. private _uintIndicesCurrentlySet;
  28733. private _currentBoundBuffer;
  28734. /** @hidden */
  28735. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28736. private _currentBufferPointers;
  28737. private _currentInstanceLocations;
  28738. private _currentInstanceBuffers;
  28739. private _textureUnits;
  28740. /** @hidden */
  28741. _workingCanvas: Nullable<HTMLCanvasElement>;
  28742. /** @hidden */
  28743. _workingContext: Nullable<CanvasRenderingContext2D>;
  28744. private _rescalePostProcess;
  28745. private _dummyFramebuffer;
  28746. private _externalData;
  28747. /** @hidden */
  28748. _bindedRenderFunction: any;
  28749. private _vaoRecordInProgress;
  28750. private _mustWipeVertexAttributes;
  28751. private _emptyTexture;
  28752. private _emptyCubeTexture;
  28753. private _emptyTexture3D;
  28754. /** @hidden */
  28755. _frameHandler: number;
  28756. private _nextFreeTextureSlots;
  28757. private _maxSimultaneousTextures;
  28758. private _activeRequests;
  28759. private _texturesSupported;
  28760. /** @hidden */
  28761. _textureFormatInUse: Nullable<string>;
  28762. /**
  28763. * Gets the list of texture formats supported
  28764. */
  28765. readonly texturesSupported: Array<string>;
  28766. /**
  28767. * Gets the list of texture formats in use
  28768. */
  28769. readonly textureFormatInUse: Nullable<string>;
  28770. /**
  28771. * Gets the current viewport
  28772. */
  28773. readonly currentViewport: Nullable<Viewport>;
  28774. /**
  28775. * Gets the default empty texture
  28776. */
  28777. readonly emptyTexture: InternalTexture;
  28778. /**
  28779. * Gets the default empty 3D texture
  28780. */
  28781. readonly emptyTexture3D: InternalTexture;
  28782. /**
  28783. * Gets the default empty cube texture
  28784. */
  28785. readonly emptyCubeTexture: InternalTexture;
  28786. /**
  28787. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28788. */
  28789. readonly premultipliedAlpha: boolean;
  28790. /**
  28791. * Creates a new engine
  28792. * @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
  28793. * @param antialias defines enable antialiasing (default: false)
  28794. * @param options defines further options to be sent to the getContext() function
  28795. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28796. */
  28797. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28798. /**
  28799. * Initializes a webVR display and starts listening to display change events
  28800. * The onVRDisplayChangedObservable will be notified upon these changes
  28801. * @returns The onVRDisplayChangedObservable
  28802. */
  28803. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28804. /** @hidden */
  28805. _prepareVRComponent(): void;
  28806. /** @hidden */
  28807. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28808. /** @hidden */
  28809. _submitVRFrame(): void;
  28810. /**
  28811. * Call this function to leave webVR mode
  28812. * Will do nothing if webVR is not supported or if there is no webVR device
  28813. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28814. */
  28815. disableVR(): void;
  28816. /**
  28817. * Gets a boolean indicating that the system is in VR mode and is presenting
  28818. * @returns true if VR mode is engaged
  28819. */
  28820. isVRPresenting(): boolean;
  28821. /** @hidden */
  28822. _requestVRFrame(): void;
  28823. private _disableTouchAction;
  28824. private _rebuildInternalTextures;
  28825. private _rebuildEffects;
  28826. /**
  28827. * Gets a boolean indicating if all created effects are ready
  28828. * @returns true if all effects are ready
  28829. */
  28830. areAllEffectsReady(): boolean;
  28831. private _rebuildBuffers;
  28832. private _initGLContext;
  28833. /**
  28834. * Gets version of the current webGL context
  28835. */
  28836. readonly webGLVersion: number;
  28837. /**
  28838. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28839. */
  28840. readonly isStencilEnable: boolean;
  28841. /** @hidden */
  28842. _prepareWorkingCanvas(): void;
  28843. /**
  28844. * Reset the texture cache to empty state
  28845. */
  28846. resetTextureCache(): void;
  28847. /**
  28848. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28849. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28850. * @returns true if engine is in deterministic lock step mode
  28851. */
  28852. isDeterministicLockStep(): boolean;
  28853. /**
  28854. * Gets the max steps when engine is running in deterministic lock step
  28855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28856. * @returns the max steps
  28857. */
  28858. getLockstepMaxSteps(): number;
  28859. /**
  28860. * Gets an object containing information about the current webGL context
  28861. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28862. */
  28863. getGlInfo(): {
  28864. vendor: string;
  28865. renderer: string;
  28866. version: string;
  28867. };
  28868. /**
  28869. * Gets current aspect ratio
  28870. * @param camera defines the camera to use to get the aspect ratio
  28871. * @param useScreen defines if screen size must be used (or the current render target if any)
  28872. * @returns a number defining the aspect ratio
  28873. */
  28874. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28875. /**
  28876. * Gets current screen aspect ratio
  28877. * @returns a number defining the aspect ratio
  28878. */
  28879. getScreenAspectRatio(): number;
  28880. /**
  28881. * Gets the current render width
  28882. * @param useScreen defines if screen size must be used (or the current render target if any)
  28883. * @returns a number defining the current render width
  28884. */
  28885. getRenderWidth(useScreen?: boolean): number;
  28886. /**
  28887. * Gets the current render height
  28888. * @param useScreen defines if screen size must be used (or the current render target if any)
  28889. * @returns a number defining the current render height
  28890. */
  28891. getRenderHeight(useScreen?: boolean): number;
  28892. /**
  28893. * Gets the HTML canvas attached with the current webGL context
  28894. * @returns a HTML canvas
  28895. */
  28896. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28897. /**
  28898. * Gets the client rect of the HTML canvas attached with the current webGL context
  28899. * @returns a client rectanglee
  28900. */
  28901. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28902. /**
  28903. * Defines the hardware scaling level.
  28904. * By default the hardware scaling level is computed from the window device ratio.
  28905. * 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.
  28906. * @param level defines the level to use
  28907. */
  28908. setHardwareScalingLevel(level: number): void;
  28909. /**
  28910. * Gets the current hardware scaling level.
  28911. * By default the hardware scaling level is computed from the window device ratio.
  28912. * 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.
  28913. * @returns a number indicating the current hardware scaling level
  28914. */
  28915. getHardwareScalingLevel(): number;
  28916. /**
  28917. * Gets the list of loaded textures
  28918. * @returns an array containing all loaded textures
  28919. */
  28920. getLoadedTexturesCache(): InternalTexture[];
  28921. /**
  28922. * Gets the object containing all engine capabilities
  28923. * @returns the EngineCapabilities object
  28924. */
  28925. getCaps(): EngineCapabilities;
  28926. /**
  28927. * Gets the current depth function
  28928. * @returns a number defining the depth function
  28929. */
  28930. getDepthFunction(): Nullable<number>;
  28931. /**
  28932. * Sets the current depth function
  28933. * @param depthFunc defines the function to use
  28934. */
  28935. setDepthFunction(depthFunc: number): void;
  28936. /**
  28937. * Sets the current depth function to GREATER
  28938. */
  28939. setDepthFunctionToGreater(): void;
  28940. /**
  28941. * Sets the current depth function to GEQUAL
  28942. */
  28943. setDepthFunctionToGreaterOrEqual(): void;
  28944. /**
  28945. * Sets the current depth function to LESS
  28946. */
  28947. setDepthFunctionToLess(): void;
  28948. private _cachedStencilBuffer;
  28949. private _cachedStencilFunction;
  28950. private _cachedStencilMask;
  28951. private _cachedStencilOperationPass;
  28952. private _cachedStencilOperationFail;
  28953. private _cachedStencilOperationDepthFail;
  28954. private _cachedStencilReference;
  28955. /**
  28956. * Caches the the state of the stencil buffer
  28957. */
  28958. cacheStencilState(): void;
  28959. /**
  28960. * Restores the state of the stencil buffer
  28961. */
  28962. restoreStencilState(): void;
  28963. /**
  28964. * Sets the current depth function to LEQUAL
  28965. */
  28966. setDepthFunctionToLessOrEqual(): void;
  28967. /**
  28968. * Gets a boolean indicating if stencil buffer is enabled
  28969. * @returns the current stencil buffer state
  28970. */
  28971. getStencilBuffer(): boolean;
  28972. /**
  28973. * Enable or disable the stencil buffer
  28974. * @param enable defines if the stencil buffer must be enabled or disabled
  28975. */
  28976. setStencilBuffer(enable: boolean): void;
  28977. /**
  28978. * Gets the current stencil mask
  28979. * @returns a number defining the new stencil mask to use
  28980. */
  28981. getStencilMask(): number;
  28982. /**
  28983. * Sets the current stencil mask
  28984. * @param mask defines the new stencil mask to use
  28985. */
  28986. setStencilMask(mask: number): void;
  28987. /**
  28988. * Gets the current stencil function
  28989. * @returns a number defining the stencil function to use
  28990. */
  28991. getStencilFunction(): number;
  28992. /**
  28993. * Gets the current stencil reference value
  28994. * @returns a number defining the stencil reference value to use
  28995. */
  28996. getStencilFunctionReference(): number;
  28997. /**
  28998. * Gets the current stencil mask
  28999. * @returns a number defining the stencil mask to use
  29000. */
  29001. getStencilFunctionMask(): number;
  29002. /**
  29003. * Sets the current stencil function
  29004. * @param stencilFunc defines the new stencil function to use
  29005. */
  29006. setStencilFunction(stencilFunc: number): void;
  29007. /**
  29008. * Sets the current stencil reference
  29009. * @param reference defines the new stencil reference to use
  29010. */
  29011. setStencilFunctionReference(reference: number): void;
  29012. /**
  29013. * Sets the current stencil mask
  29014. * @param mask defines the new stencil mask to use
  29015. */
  29016. setStencilFunctionMask(mask: number): void;
  29017. /**
  29018. * Gets the current stencil operation when stencil fails
  29019. * @returns a number defining stencil operation to use when stencil fails
  29020. */
  29021. getStencilOperationFail(): number;
  29022. /**
  29023. * Gets the current stencil operation when depth fails
  29024. * @returns a number defining stencil operation to use when depth fails
  29025. */
  29026. getStencilOperationDepthFail(): number;
  29027. /**
  29028. * Gets the current stencil operation when stencil passes
  29029. * @returns a number defining stencil operation to use when stencil passes
  29030. */
  29031. getStencilOperationPass(): number;
  29032. /**
  29033. * Sets the stencil operation to use when stencil fails
  29034. * @param operation defines the stencil operation to use when stencil fails
  29035. */
  29036. setStencilOperationFail(operation: number): void;
  29037. /**
  29038. * Sets the stencil operation to use when depth fails
  29039. * @param operation defines the stencil operation to use when depth fails
  29040. */
  29041. setStencilOperationDepthFail(operation: number): void;
  29042. /**
  29043. * Sets the stencil operation to use when stencil passes
  29044. * @param operation defines the stencil operation to use when stencil passes
  29045. */
  29046. setStencilOperationPass(operation: number): void;
  29047. /**
  29048. * Sets a boolean indicating if the dithering state is enabled or disabled
  29049. * @param value defines the dithering state
  29050. */
  29051. setDitheringState(value: boolean): void;
  29052. /**
  29053. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29054. * @param value defines the rasterizer state
  29055. */
  29056. setRasterizerState(value: boolean): void;
  29057. /**
  29058. * stop executing a render loop function and remove it from the execution array
  29059. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29060. */
  29061. stopRenderLoop(renderFunction?: () => void): void;
  29062. /** @hidden */
  29063. _renderLoop(): void;
  29064. /**
  29065. * Register and execute a render loop. The engine can have more than one render function
  29066. * @param renderFunction defines the function to continuously execute
  29067. */
  29068. runRenderLoop(renderFunction: () => void): void;
  29069. /**
  29070. * Toggle full screen mode
  29071. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29072. */
  29073. switchFullscreen(requestPointerLock: boolean): void;
  29074. /**
  29075. * Enters full screen mode
  29076. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29077. */
  29078. enterFullscreen(requestPointerLock: boolean): void;
  29079. /**
  29080. * Exits full screen mode
  29081. */
  29082. exitFullscreen(): void;
  29083. /**
  29084. * Enters Pointerlock mode
  29085. */
  29086. enterPointerlock(): void;
  29087. /**
  29088. * Exits Pointerlock mode
  29089. */
  29090. exitPointerlock(): void;
  29091. /**
  29092. * Clear the current render buffer or the current render target (if any is set up)
  29093. * @param color defines the color to use
  29094. * @param backBuffer defines if the back buffer must be cleared
  29095. * @param depth defines if the depth buffer must be cleared
  29096. * @param stencil defines if the stencil buffer must be cleared
  29097. */
  29098. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29099. /**
  29100. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29101. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29102. * @param y defines the y-coordinate of the corner of the clear rectangle
  29103. * @param width defines the width of the clear rectangle
  29104. * @param height defines the height of the clear rectangle
  29105. * @param clearColor defines the clear color
  29106. */
  29107. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29108. /**
  29109. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29110. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29111. * @param y defines the y-coordinate of the corner of the clear rectangle
  29112. * @param width defines the width of the clear rectangle
  29113. * @param height defines the height of the clear rectangle
  29114. */
  29115. enableScissor(x: number, y: number, width: number, height: number): void;
  29116. /**
  29117. * Disable previously set scissor test rectangle
  29118. */
  29119. disableScissor(): void;
  29120. private _viewportCached;
  29121. /** @hidden */
  29122. _viewport(x: number, y: number, width: number, height: number): void;
  29123. /**
  29124. * Set the WebGL's viewport
  29125. * @param viewport defines the viewport element to be used
  29126. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29127. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29128. */
  29129. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29130. /**
  29131. * Directly set the WebGL Viewport
  29132. * @param x defines the x coordinate of the viewport (in screen space)
  29133. * @param y defines the y coordinate of the viewport (in screen space)
  29134. * @param width defines the width of the viewport (in screen space)
  29135. * @param height defines the height of the viewport (in screen space)
  29136. * @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
  29137. */
  29138. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29139. /**
  29140. * Begin a new frame
  29141. */
  29142. beginFrame(): void;
  29143. /**
  29144. * Enf the current frame
  29145. */
  29146. endFrame(): void;
  29147. /**
  29148. * Resize the view according to the canvas' size
  29149. */
  29150. resize(): void;
  29151. /**
  29152. * Force a specific size of the canvas
  29153. * @param width defines the new canvas' width
  29154. * @param height defines the new canvas' height
  29155. */
  29156. setSize(width: number, height: number): void;
  29157. /**
  29158. * Binds the frame buffer to the specified texture.
  29159. * @param texture The texture to render to or null for the default canvas
  29160. * @param faceIndex The face of the texture to render to in case of cube texture
  29161. * @param requiredWidth The width of the target to render to
  29162. * @param requiredHeight The height of the target to render to
  29163. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29164. * @param depthStencilTexture The depth stencil texture to use to render
  29165. * @param lodLevel defines le lod level to bind to the frame buffer
  29166. */
  29167. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29168. /** @hidden */
  29169. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29170. /**
  29171. * Unbind the current render target texture from the webGL context
  29172. * @param texture defines the render target texture to unbind
  29173. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29174. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29175. */
  29176. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29177. /**
  29178. * Force the mipmap generation for the given render target texture
  29179. * @param texture defines the render target texture to use
  29180. */
  29181. generateMipMapsForCubemap(texture: InternalTexture): void;
  29182. /**
  29183. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29184. */
  29185. flushFramebuffer(): void;
  29186. /**
  29187. * Unbind the current render target and bind the default framebuffer
  29188. */
  29189. restoreDefaultFramebuffer(): void;
  29190. /**
  29191. * Create an uniform buffer
  29192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29193. * @param elements defines the content of the uniform buffer
  29194. * @returns the webGL uniform buffer
  29195. */
  29196. createUniformBuffer(elements: FloatArray): DataBuffer;
  29197. /**
  29198. * Create a dynamic uniform buffer
  29199. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29200. * @param elements defines the content of the uniform buffer
  29201. * @returns the webGL uniform buffer
  29202. */
  29203. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29204. /**
  29205. * Update an existing uniform buffer
  29206. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29207. * @param uniformBuffer defines the target uniform buffer
  29208. * @param elements defines the content to update
  29209. * @param offset defines the offset in the uniform buffer where update should start
  29210. * @param count defines the size of the data to update
  29211. */
  29212. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29213. private _resetVertexBufferBinding;
  29214. /**
  29215. * Creates a vertex buffer
  29216. * @param data the data for the vertex buffer
  29217. * @returns the new WebGL static buffer
  29218. */
  29219. createVertexBuffer(data: DataArray): DataBuffer;
  29220. /**
  29221. * Creates a dynamic vertex buffer
  29222. * @param data the data for the dynamic vertex buffer
  29223. * @returns the new WebGL dynamic buffer
  29224. */
  29225. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29226. /**
  29227. * Update a dynamic index buffer
  29228. * @param indexBuffer defines the target index buffer
  29229. * @param indices defines the data to update
  29230. * @param offset defines the offset in the target index buffer where update should start
  29231. */
  29232. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29233. /**
  29234. * Updates a dynamic vertex buffer.
  29235. * @param vertexBuffer the vertex buffer to update
  29236. * @param data the data used to update the vertex buffer
  29237. * @param byteOffset the byte offset of the data
  29238. * @param byteLength the byte length of the data
  29239. */
  29240. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29241. private _resetIndexBufferBinding;
  29242. /**
  29243. * Creates a new index buffer
  29244. * @param indices defines the content of the index buffer
  29245. * @param updatable defines if the index buffer must be updatable
  29246. * @returns a new webGL buffer
  29247. */
  29248. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29249. /**
  29250. * Bind a webGL buffer to the webGL context
  29251. * @param buffer defines the buffer to bind
  29252. */
  29253. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29254. /**
  29255. * Bind an uniform buffer to the current webGL context
  29256. * @param buffer defines the buffer to bind
  29257. */
  29258. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29259. /**
  29260. * Bind a buffer to the current webGL context at a given location
  29261. * @param buffer defines the buffer to bind
  29262. * @param location defines the index where to bind the buffer
  29263. */
  29264. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29265. /**
  29266. * Bind a specific block at a given index in a specific shader program
  29267. * @param pipelineContext defines the pipeline context to use
  29268. * @param blockName defines the block name
  29269. * @param index defines the index where to bind the block
  29270. */
  29271. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29272. private bindIndexBuffer;
  29273. private bindBuffer;
  29274. /**
  29275. * update the bound buffer with the given data
  29276. * @param data defines the data to update
  29277. */
  29278. updateArrayBuffer(data: Float32Array): void;
  29279. private _vertexAttribPointer;
  29280. private _bindIndexBufferWithCache;
  29281. private _bindVertexBuffersAttributes;
  29282. /**
  29283. * Records a vertex array object
  29284. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29285. * @param vertexBuffers defines the list of vertex buffers to store
  29286. * @param indexBuffer defines the index buffer to store
  29287. * @param effect defines the effect to store
  29288. * @returns the new vertex array object
  29289. */
  29290. recordVertexArrayObject(vertexBuffers: {
  29291. [key: string]: VertexBuffer;
  29292. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29293. /**
  29294. * Bind a specific vertex array object
  29295. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29296. * @param vertexArrayObject defines the vertex array object to bind
  29297. * @param indexBuffer defines the index buffer to bind
  29298. */
  29299. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29300. /**
  29301. * Bind webGl buffers directly to the webGL context
  29302. * @param vertexBuffer defines the vertex buffer to bind
  29303. * @param indexBuffer defines the index buffer to bind
  29304. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29305. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29306. * @param effect defines the effect associated with the vertex buffer
  29307. */
  29308. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29309. private _unbindVertexArrayObject;
  29310. /**
  29311. * Bind a list of vertex buffers to the webGL context
  29312. * @param vertexBuffers defines the list of vertex buffers to bind
  29313. * @param indexBuffer defines the index buffer to bind
  29314. * @param effect defines the effect associated with the vertex buffers
  29315. */
  29316. bindBuffers(vertexBuffers: {
  29317. [key: string]: Nullable<VertexBuffer>;
  29318. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29319. /**
  29320. * Unbind all instance attributes
  29321. */
  29322. unbindInstanceAttributes(): void;
  29323. /**
  29324. * Release and free the memory of a vertex array object
  29325. * @param vao defines the vertex array object to delete
  29326. */
  29327. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29328. /** @hidden */
  29329. _releaseBuffer(buffer: DataBuffer): boolean;
  29330. /**
  29331. * Creates a webGL buffer to use with instanciation
  29332. * @param capacity defines the size of the buffer
  29333. * @returns the webGL buffer
  29334. */
  29335. createInstancesBuffer(capacity: number): DataBuffer;
  29336. /**
  29337. * Delete a webGL buffer used with instanciation
  29338. * @param buffer defines the webGL buffer to delete
  29339. */
  29340. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29341. /**
  29342. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29343. * @param instancesBuffer defines the webGL buffer to update and bind
  29344. * @param data defines the data to store in the buffer
  29345. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29346. */
  29347. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29348. /**
  29349. * Apply all cached states (depth, culling, stencil and alpha)
  29350. */
  29351. applyStates(): void;
  29352. /**
  29353. * Send a draw order
  29354. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29355. * @param indexStart defines the starting index
  29356. * @param indexCount defines the number of index to draw
  29357. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29358. */
  29359. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29360. /**
  29361. * Draw a list of points
  29362. * @param verticesStart defines the index of first vertex to draw
  29363. * @param verticesCount defines the count of vertices to draw
  29364. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29365. */
  29366. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29367. /**
  29368. * Draw a list of unindexed primitives
  29369. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29370. * @param verticesStart defines the index of first vertex to draw
  29371. * @param verticesCount defines the count of vertices to draw
  29372. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29373. */
  29374. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29375. /**
  29376. * Draw a list of indexed primitives
  29377. * @param fillMode defines the primitive to use
  29378. * @param indexStart defines the starting index
  29379. * @param indexCount defines the number of index to draw
  29380. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29381. */
  29382. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29383. /**
  29384. * Draw a list of unindexed primitives
  29385. * @param fillMode defines the primitive to use
  29386. * @param verticesStart defines the index of first vertex to draw
  29387. * @param verticesCount defines the count of vertices to draw
  29388. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29389. */
  29390. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29391. private _drawMode;
  29392. /** @hidden */
  29393. _releaseEffect(effect: Effect): void;
  29394. /** @hidden */
  29395. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29396. /**
  29397. * Create a new effect (used to store vertex/fragment shaders)
  29398. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29399. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29400. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29401. * @param samplers defines an array of string used to represent textures
  29402. * @param defines defines the string containing the defines to use to compile the shaders
  29403. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29404. * @param onCompiled defines a function to call when the effect creation is successful
  29405. * @param onError defines a function to call when the effect creation has failed
  29406. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29407. * @returns the new Effect
  29408. */
  29409. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29410. private _compileShader;
  29411. private _compileRawShader;
  29412. /**
  29413. * Directly creates a webGL program
  29414. * @param pipelineContext defines the pipeline context to attach to
  29415. * @param vertexCode defines the vertex shader code to use
  29416. * @param fragmentCode defines the fragment shader code to use
  29417. * @param context defines the webGL context to use (if not set, the current one will be used)
  29418. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29419. * @returns the new webGL program
  29420. */
  29421. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29422. /**
  29423. * Creates a webGL program
  29424. * @param pipelineContext defines the pipeline context to attach to
  29425. * @param vertexCode defines the vertex shader code to use
  29426. * @param fragmentCode defines the fragment shader code to use
  29427. * @param defines defines the string containing the defines to use to compile the shaders
  29428. * @param context defines the webGL context to use (if not set, the current one will be used)
  29429. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29430. * @returns the new webGL program
  29431. */
  29432. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29433. /**
  29434. * Creates a new pipeline context
  29435. * @returns the new pipeline
  29436. */
  29437. createPipelineContext(): WebGLPipelineContext;
  29438. private _createShaderProgram;
  29439. private _finalizePipelineContext;
  29440. /** @hidden */
  29441. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29442. /** @hidden */
  29443. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29444. /** @hidden */
  29445. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29446. /**
  29447. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29448. * @param pipelineContext defines the pipeline context to use
  29449. * @param uniformsNames defines the list of uniform names
  29450. * @returns an array of webGL uniform locations
  29451. */
  29452. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29453. /**
  29454. * Gets the lsit of active attributes for a given webGL program
  29455. * @param pipelineContext defines the pipeline context to use
  29456. * @param attributesNames defines the list of attribute names to get
  29457. * @returns an array of indices indicating the offset of each attribute
  29458. */
  29459. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29460. /**
  29461. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29462. * @param effect defines the effect to activate
  29463. */
  29464. enableEffect(effect: Nullable<Effect>): void;
  29465. /**
  29466. * Set the value of an uniform to an array of int32
  29467. * @param uniform defines the webGL uniform location where to store the value
  29468. * @param array defines the array of int32 to store
  29469. */
  29470. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29471. /**
  29472. * Set the value of an uniform to an array of int32 (stored as vec2)
  29473. * @param uniform defines the webGL uniform location where to store the value
  29474. * @param array defines the array of int32 to store
  29475. */
  29476. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29477. /**
  29478. * Set the value of an uniform to an array of int32 (stored as vec3)
  29479. * @param uniform defines the webGL uniform location where to store the value
  29480. * @param array defines the array of int32 to store
  29481. */
  29482. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29483. /**
  29484. * Set the value of an uniform to an array of int32 (stored as vec4)
  29485. * @param uniform defines the webGL uniform location where to store the value
  29486. * @param array defines the array of int32 to store
  29487. */
  29488. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29489. /**
  29490. * Set the value of an uniform to an array of float32
  29491. * @param uniform defines the webGL uniform location where to store the value
  29492. * @param array defines the array of float32 to store
  29493. */
  29494. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29495. /**
  29496. * Set the value of an uniform to an array of float32 (stored as vec2)
  29497. * @param uniform defines the webGL uniform location where to store the value
  29498. * @param array defines the array of float32 to store
  29499. */
  29500. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29501. /**
  29502. * Set the value of an uniform to an array of float32 (stored as vec3)
  29503. * @param uniform defines the webGL uniform location where to store the value
  29504. * @param array defines the array of float32 to store
  29505. */
  29506. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29507. /**
  29508. * Set the value of an uniform to an array of float32 (stored as vec4)
  29509. * @param uniform defines the webGL uniform location where to store the value
  29510. * @param array defines the array of float32 to store
  29511. */
  29512. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29513. /**
  29514. * Set the value of an uniform to an array of number
  29515. * @param uniform defines the webGL uniform location where to store the value
  29516. * @param array defines the array of number to store
  29517. */
  29518. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29519. /**
  29520. * Set the value of an uniform to an array of number (stored as vec2)
  29521. * @param uniform defines the webGL uniform location where to store the value
  29522. * @param array defines the array of number to store
  29523. */
  29524. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29525. /**
  29526. * Set the value of an uniform to an array of number (stored as vec3)
  29527. * @param uniform defines the webGL uniform location where to store the value
  29528. * @param array defines the array of number to store
  29529. */
  29530. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29531. /**
  29532. * Set the value of an uniform to an array of number (stored as vec4)
  29533. * @param uniform defines the webGL uniform location where to store the value
  29534. * @param array defines the array of number to store
  29535. */
  29536. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29537. /**
  29538. * Set the value of an uniform to an array of float32 (stored as matrices)
  29539. * @param uniform defines the webGL uniform location where to store the value
  29540. * @param matrices defines the array of float32 to store
  29541. */
  29542. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29543. /**
  29544. * Set the value of an uniform to a matrix
  29545. * @param uniform defines the webGL uniform location where to store the value
  29546. * @param matrix defines the matrix to store
  29547. */
  29548. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29549. /**
  29550. * Set the value of an uniform to a matrix (3x3)
  29551. * @param uniform defines the webGL uniform location where to store the value
  29552. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29553. */
  29554. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29555. /**
  29556. * Set the value of an uniform to a matrix (2x2)
  29557. * @param uniform defines the webGL uniform location where to store the value
  29558. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29559. */
  29560. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29561. /**
  29562. * Set the value of an uniform to a number (int)
  29563. * @param uniform defines the webGL uniform location where to store the value
  29564. * @param value defines the int number to store
  29565. */
  29566. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29567. /**
  29568. * Set the value of an uniform to a number (float)
  29569. * @param uniform defines the webGL uniform location where to store the value
  29570. * @param value defines the float number to store
  29571. */
  29572. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29573. /**
  29574. * Set the value of an uniform to a vec2
  29575. * @param uniform defines the webGL uniform location where to store the value
  29576. * @param x defines the 1st component of the value
  29577. * @param y defines the 2nd component of the value
  29578. */
  29579. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29580. /**
  29581. * Set the value of an uniform to a vec3
  29582. * @param uniform defines the webGL uniform location where to store the value
  29583. * @param x defines the 1st component of the value
  29584. * @param y defines the 2nd component of the value
  29585. * @param z defines the 3rd component of the value
  29586. */
  29587. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29588. /**
  29589. * Set the value of an uniform to a boolean
  29590. * @param uniform defines the webGL uniform location where to store the value
  29591. * @param bool defines the boolean to store
  29592. */
  29593. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29594. /**
  29595. * Set the value of an uniform to a vec4
  29596. * @param uniform defines the webGL uniform location where to store the value
  29597. * @param x defines the 1st component of the value
  29598. * @param y defines the 2nd component of the value
  29599. * @param z defines the 3rd component of the value
  29600. * @param w defines the 4th component of the value
  29601. */
  29602. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29603. /**
  29604. * Set the value of an uniform to a Color3
  29605. * @param uniform defines the webGL uniform location where to store the value
  29606. * @param color3 defines the color to store
  29607. */
  29608. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29609. /**
  29610. * Set the value of an uniform to a Color3 and an alpha value
  29611. * @param uniform defines the webGL uniform location where to store the value
  29612. * @param color3 defines the color to store
  29613. * @param alpha defines the alpha component to store
  29614. */
  29615. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29616. /**
  29617. * Sets a Color4 on a uniform variable
  29618. * @param uniform defines the uniform location
  29619. * @param color4 defines the value to be set
  29620. */
  29621. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29622. /**
  29623. * Set various states to the webGL context
  29624. * @param culling defines backface culling state
  29625. * @param zOffset defines the value to apply to zOffset (0 by default)
  29626. * @param force defines if states must be applied even if cache is up to date
  29627. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29628. */
  29629. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29630. /**
  29631. * Set the z offset to apply to current rendering
  29632. * @param value defines the offset to apply
  29633. */
  29634. setZOffset(value: number): void;
  29635. /**
  29636. * Gets the current value of the zOffset
  29637. * @returns the current zOffset state
  29638. */
  29639. getZOffset(): number;
  29640. /**
  29641. * Enable or disable depth buffering
  29642. * @param enable defines the state to set
  29643. */
  29644. setDepthBuffer(enable: boolean): void;
  29645. /**
  29646. * Gets a boolean indicating if depth writing is enabled
  29647. * @returns the current depth writing state
  29648. */
  29649. getDepthWrite(): boolean;
  29650. /**
  29651. * Enable or disable depth writing
  29652. * @param enable defines the state to set
  29653. */
  29654. setDepthWrite(enable: boolean): void;
  29655. /**
  29656. * Enable or disable color writing
  29657. * @param enable defines the state to set
  29658. */
  29659. setColorWrite(enable: boolean): void;
  29660. /**
  29661. * Gets a boolean indicating if color writing is enabled
  29662. * @returns the current color writing state
  29663. */
  29664. getColorWrite(): boolean;
  29665. /**
  29666. * Sets alpha constants used by some alpha blending modes
  29667. * @param r defines the red component
  29668. * @param g defines the green component
  29669. * @param b defines the blue component
  29670. * @param a defines the alpha component
  29671. */
  29672. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29673. /**
  29674. * Sets the current alpha mode
  29675. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29676. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29677. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29678. */
  29679. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29680. /**
  29681. * Gets the current alpha mode
  29682. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29683. * @returns the current alpha mode
  29684. */
  29685. getAlphaMode(): number;
  29686. /**
  29687. * Clears the list of texture accessible through engine.
  29688. * This can help preventing texture load conflict due to name collision.
  29689. */
  29690. clearInternalTexturesCache(): void;
  29691. /**
  29692. * Force the entire cache to be cleared
  29693. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29694. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29695. */
  29696. wipeCaches(bruteForce?: boolean): void;
  29697. /**
  29698. * Set the compressed texture format to use, based on the formats you have, and the formats
  29699. * supported by the hardware / browser.
  29700. *
  29701. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29702. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29703. * to API arguments needed to compressed textures. This puts the burden on the container
  29704. * generator to house the arcane code for determining these for current & future formats.
  29705. *
  29706. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29707. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29708. *
  29709. * Note: The result of this call is not taken into account when a texture is base64.
  29710. *
  29711. * @param formatsAvailable defines the list of those format families you have created
  29712. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29713. *
  29714. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29715. * @returns The extension selected.
  29716. */
  29717. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29718. /** @hidden */
  29719. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29720. min: number;
  29721. mag: number;
  29722. };
  29723. /** @hidden */
  29724. _createTexture(): WebGLTexture;
  29725. /**
  29726. * Usually called from Texture.ts.
  29727. * Passed information to create a WebGLTexture
  29728. * @param urlArg defines a value which contains one of the following:
  29729. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29730. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29731. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29733. * @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)
  29734. * @param scene needed for loading to the correct scene
  29735. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29736. * @param onLoad optional callback to be called upon successful completion
  29737. * @param onError optional callback to be called upon failure
  29738. * @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
  29739. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29740. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29741. * @param forcedExtension defines the extension to use to pick the right loader
  29742. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29743. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29744. */
  29745. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29746. /**
  29747. * @hidden
  29748. * Rescales a texture
  29749. * @param source input texutre
  29750. * @param destination destination texture
  29751. * @param scene scene to use to render the resize
  29752. * @param internalFormat format to use when resizing
  29753. * @param onComplete callback to be called when resize has completed
  29754. */
  29755. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29756. private _unpackFlipYCached;
  29757. /**
  29758. * In case you are sharing the context with other applications, it might
  29759. * be interested to not cache the unpack flip y state to ensure a consistent
  29760. * value would be set.
  29761. */
  29762. enableUnpackFlipYCached: boolean;
  29763. /** @hidden */
  29764. _unpackFlipY(value: boolean): void;
  29765. /** @hidden */
  29766. _getUnpackAlignement(): number;
  29767. /**
  29768. * Creates a dynamic texture
  29769. * @param width defines the width of the texture
  29770. * @param height defines the height of the texture
  29771. * @param generateMipMaps defines if the engine should generate the mip levels
  29772. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29773. * @returns the dynamic texture inside an InternalTexture
  29774. */
  29775. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29776. /**
  29777. * Update the sampling mode of a given texture
  29778. * @param samplingMode defines the required sampling mode
  29779. * @param texture defines the texture to update
  29780. */
  29781. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29782. /**
  29783. * Update the content of a dynamic texture
  29784. * @param texture defines the texture to update
  29785. * @param canvas defines the canvas containing the source
  29786. * @param invertY defines if data must be stored with Y axis inverted
  29787. * @param premulAlpha defines if alpha is stored as premultiplied
  29788. * @param format defines the format of the data
  29789. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29790. */
  29791. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29792. /**
  29793. * Update a video texture
  29794. * @param texture defines the texture to update
  29795. * @param video defines the video element to use
  29796. * @param invertY defines if data must be stored with Y axis inverted
  29797. */
  29798. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29799. /**
  29800. * Updates a depth texture Comparison Mode and Function.
  29801. * If the comparison Function is equal to 0, the mode will be set to none.
  29802. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29803. * @param texture The texture to set the comparison function for
  29804. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29805. */
  29806. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29807. /** @hidden */
  29808. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29809. width: number;
  29810. height: number;
  29811. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29812. /**
  29813. * Creates a depth stencil texture.
  29814. * This is only available in WebGL 2 or with the depth texture extension available.
  29815. * @param size The size of face edge in the texture.
  29816. * @param options The options defining the texture.
  29817. * @returns The texture
  29818. */
  29819. createDepthStencilTexture(size: number | {
  29820. width: number;
  29821. height: number;
  29822. }, options: DepthTextureCreationOptions): InternalTexture;
  29823. /**
  29824. * Creates a depth stencil texture.
  29825. * This is only available in WebGL 2 or with the depth texture extension available.
  29826. * @param size The size of face edge in the texture.
  29827. * @param options The options defining the texture.
  29828. * @returns The texture
  29829. */
  29830. private _createDepthStencilTexture;
  29831. /**
  29832. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29833. * @param renderTarget The render target to set the frame buffer for
  29834. */
  29835. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29836. /**
  29837. * Creates a new render target texture
  29838. * @param size defines the size of the texture
  29839. * @param options defines the options used to create the texture
  29840. * @returns a new render target texture stored in an InternalTexture
  29841. */
  29842. createRenderTargetTexture(size: number | {
  29843. width: number;
  29844. height: number;
  29845. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29846. /** @hidden */
  29847. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29848. /**
  29849. * Updates the sample count of a render target texture
  29850. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29851. * @param texture defines the texture to update
  29852. * @param samples defines the sample count to set
  29853. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29854. */
  29855. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29856. /** @hidden */
  29857. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29858. /** @hidden */
  29859. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29860. /** @hidden */
  29861. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29862. /** @hidden */
  29863. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29864. /**
  29865. * @hidden
  29866. */
  29867. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29868. private _prepareWebGLTextureContinuation;
  29869. private _prepareWebGLTexture;
  29870. /** @hidden */
  29871. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29872. /** @hidden */
  29873. _releaseFramebufferObjects(texture: InternalTexture): void;
  29874. /** @hidden */
  29875. _releaseTexture(texture: InternalTexture): void;
  29876. private setProgram;
  29877. private _boundUniforms;
  29878. /**
  29879. * Binds an effect to the webGL context
  29880. * @param effect defines the effect to bind
  29881. */
  29882. bindSamplers(effect: Effect): void;
  29883. private _activateCurrentTexture;
  29884. /** @hidden */
  29885. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29886. /** @hidden */
  29887. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29888. /**
  29889. * Sets a texture to the webGL context from a postprocess
  29890. * @param channel defines the channel to use
  29891. * @param postProcess defines the source postprocess
  29892. */
  29893. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29894. /**
  29895. * Binds the output of the passed in post process to the texture channel specified
  29896. * @param channel The channel the texture should be bound to
  29897. * @param postProcess The post process which's output should be bound
  29898. */
  29899. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29900. /**
  29901. * Unbind all textures from the webGL context
  29902. */
  29903. unbindAllTextures(): void;
  29904. /**
  29905. * Sets a texture to the according uniform.
  29906. * @param channel The texture channel
  29907. * @param uniform The uniform to set
  29908. * @param texture The texture to apply
  29909. */
  29910. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29911. /**
  29912. * Sets a depth stencil texture from a render target to the according uniform.
  29913. * @param channel The texture channel
  29914. * @param uniform The uniform to set
  29915. * @param texture The render target texture containing the depth stencil texture to apply
  29916. */
  29917. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29918. private _bindSamplerUniformToChannel;
  29919. private _getTextureWrapMode;
  29920. private _setTexture;
  29921. /**
  29922. * Sets an array of texture to the webGL context
  29923. * @param channel defines the channel where the texture array must be set
  29924. * @param uniform defines the associated uniform location
  29925. * @param textures defines the array of textures to bind
  29926. */
  29927. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29928. /** @hidden */
  29929. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29930. private _setTextureParameterFloat;
  29931. private _setTextureParameterInteger;
  29932. /**
  29933. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29934. * @param x defines the x coordinate of the rectangle where pixels must be read
  29935. * @param y defines the y coordinate of the rectangle where pixels must be read
  29936. * @param width defines the width of the rectangle where pixels must be read
  29937. * @param height defines the height of the rectangle where pixels must be read
  29938. * @returns a Uint8Array containing RGBA colors
  29939. */
  29940. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29941. /**
  29942. * Add an externaly attached data from its key.
  29943. * This method call will fail and return false, if such key already exists.
  29944. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29945. * @param key the unique key that identifies the data
  29946. * @param data the data object to associate to the key for this Engine instance
  29947. * @return true if no such key were already present and the data was added successfully, false otherwise
  29948. */
  29949. addExternalData<T>(key: string, data: T): boolean;
  29950. /**
  29951. * Get an externaly attached data from its key
  29952. * @param key the unique key that identifies the data
  29953. * @return the associated data, if present (can be null), or undefined if not present
  29954. */
  29955. getExternalData<T>(key: string): T;
  29956. /**
  29957. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29958. * @param key the unique key that identifies the data
  29959. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29960. * @return the associated data, can be null if the factory returned null.
  29961. */
  29962. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29963. /**
  29964. * Remove an externaly attached data from the Engine instance
  29965. * @param key the unique key that identifies the data
  29966. * @return true if the data was successfully removed, false if it doesn't exist
  29967. */
  29968. removeExternalData(key: string): boolean;
  29969. /**
  29970. * Unbind all vertex attributes from the webGL context
  29971. */
  29972. unbindAllAttributes(): void;
  29973. /**
  29974. * 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
  29975. */
  29976. releaseEffects(): void;
  29977. /**
  29978. * Dispose and release all associated resources
  29979. */
  29980. dispose(): void;
  29981. /**
  29982. * Display the loading screen
  29983. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29984. */
  29985. displayLoadingUI(): void;
  29986. /**
  29987. * Hide the loading screen
  29988. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29989. */
  29990. hideLoadingUI(): void;
  29991. /**
  29992. * Gets the current loading screen object
  29993. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29994. */
  29995. /**
  29996. * Sets the current loading screen object
  29997. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29998. */
  29999. loadingScreen: ILoadingScreen;
  30000. /**
  30001. * Sets the current loading screen text
  30002. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30003. */
  30004. loadingUIText: string;
  30005. /**
  30006. * Sets the current loading screen background color
  30007. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30008. */
  30009. loadingUIBackgroundColor: string;
  30010. /**
  30011. * Attach a new callback raised when context lost event is fired
  30012. * @param callback defines the callback to call
  30013. */
  30014. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30015. /**
  30016. * Attach a new callback raised when context restored event is fired
  30017. * @param callback defines the callback to call
  30018. */
  30019. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30020. /**
  30021. * Gets the source code of the vertex shader associated with a specific webGL program
  30022. * @param program defines the program to use
  30023. * @returns a string containing the source code of the vertex shader associated with the program
  30024. */
  30025. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30026. /**
  30027. * Gets the source code of the fragment shader associated with a specific webGL program
  30028. * @param program defines the program to use
  30029. * @returns a string containing the source code of the fragment shader associated with the program
  30030. */
  30031. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30032. /**
  30033. * Get the current error code of the webGL context
  30034. * @returns the error code
  30035. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30036. */
  30037. getError(): number;
  30038. /**
  30039. * Gets the current framerate
  30040. * @returns a number representing the framerate
  30041. */
  30042. getFps(): number;
  30043. /**
  30044. * Gets the time spent between current and previous frame
  30045. * @returns a number representing the delta time in ms
  30046. */
  30047. getDeltaTime(): number;
  30048. private _measureFps;
  30049. /** @hidden */
  30050. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30051. private _canRenderToFloatFramebuffer;
  30052. private _canRenderToHalfFloatFramebuffer;
  30053. private _canRenderToFramebuffer;
  30054. /** @hidden */
  30055. _getWebGLTextureType(type: number): number;
  30056. /** @hidden */
  30057. _getInternalFormat(format: number): number;
  30058. /** @hidden */
  30059. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30060. /** @hidden */
  30061. _getRGBAMultiSampleBufferFormat(type: number): number;
  30062. /** @hidden */
  30063. _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;
  30064. /** @hidden */
  30065. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30066. /**
  30067. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30068. * @returns true if the engine can be created
  30069. * @ignorenaming
  30070. */
  30071. static isSupported(): boolean;
  30072. }
  30073. }
  30074. declare module "babylonjs/Materials/effect" {
  30075. import { Observable } from "babylonjs/Misc/observable";
  30076. import { Nullable } from "babylonjs/types";
  30077. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30078. import { IDisposable } from "babylonjs/scene";
  30079. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30080. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30081. import { Engine } from "babylonjs/Engines/engine";
  30082. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30084. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30085. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30087. /**
  30088. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30089. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30090. */
  30091. export class EffectFallbacks {
  30092. private _defines;
  30093. private _currentRank;
  30094. private _maxRank;
  30095. private _mesh;
  30096. /**
  30097. * Removes the fallback from the bound mesh.
  30098. */
  30099. unBindMesh(): void;
  30100. /**
  30101. * Adds a fallback on the specified property.
  30102. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30103. * @param define The name of the define in the shader
  30104. */
  30105. addFallback(rank: number, define: string): void;
  30106. /**
  30107. * Sets the mesh to use CPU skinning when needing to fallback.
  30108. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30109. * @param mesh The mesh to use the fallbacks.
  30110. */
  30111. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30112. /**
  30113. * Checks to see if more fallbacks are still availible.
  30114. */
  30115. readonly isMoreFallbacks: boolean;
  30116. /**
  30117. * Removes the defines that should be removed when falling back.
  30118. * @param currentDefines defines the current define statements for the shader.
  30119. * @param effect defines the current effect we try to compile
  30120. * @returns The resulting defines with defines of the current rank removed.
  30121. */
  30122. reduce(currentDefines: string, effect: Effect): string;
  30123. }
  30124. /**
  30125. * Options to be used when creating an effect.
  30126. */
  30127. export class EffectCreationOptions {
  30128. /**
  30129. * Atrributes that will be used in the shader.
  30130. */
  30131. attributes: string[];
  30132. /**
  30133. * Uniform varible names that will be set in the shader.
  30134. */
  30135. uniformsNames: string[];
  30136. /**
  30137. * Uniform buffer varible names that will be set in the shader.
  30138. */
  30139. uniformBuffersNames: string[];
  30140. /**
  30141. * Sampler texture variable names that will be set in the shader.
  30142. */
  30143. samplers: string[];
  30144. /**
  30145. * Define statements that will be set in the shader.
  30146. */
  30147. defines: any;
  30148. /**
  30149. * Possible fallbacks for this effect to improve performance when needed.
  30150. */
  30151. fallbacks: Nullable<EffectFallbacks>;
  30152. /**
  30153. * Callback that will be called when the shader is compiled.
  30154. */
  30155. onCompiled: Nullable<(effect: Effect) => void>;
  30156. /**
  30157. * Callback that will be called if an error occurs during shader compilation.
  30158. */
  30159. onError: Nullable<(effect: Effect, errors: string) => void>;
  30160. /**
  30161. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30162. */
  30163. indexParameters: any;
  30164. /**
  30165. * Max number of lights that can be used in the shader.
  30166. */
  30167. maxSimultaneousLights: number;
  30168. /**
  30169. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30170. */
  30171. transformFeedbackVaryings: Nullable<string[]>;
  30172. }
  30173. /**
  30174. * Effect containing vertex and fragment shader that can be executed on an object.
  30175. */
  30176. export class Effect implements IDisposable {
  30177. /**
  30178. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30179. */
  30180. static ShadersRepository: string;
  30181. /**
  30182. * Name of the effect.
  30183. */
  30184. name: any;
  30185. /**
  30186. * String container all the define statements that should be set on the shader.
  30187. */
  30188. defines: string;
  30189. /**
  30190. * Callback that will be called when the shader is compiled.
  30191. */
  30192. onCompiled: Nullable<(effect: Effect) => void>;
  30193. /**
  30194. * Callback that will be called if an error occurs during shader compilation.
  30195. */
  30196. onError: Nullable<(effect: Effect, errors: string) => void>;
  30197. /**
  30198. * Callback that will be called when effect is bound.
  30199. */
  30200. onBind: Nullable<(effect: Effect) => void>;
  30201. /**
  30202. * Unique ID of the effect.
  30203. */
  30204. uniqueId: number;
  30205. /**
  30206. * Observable that will be called when the shader is compiled.
  30207. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30208. */
  30209. onCompileObservable: Observable<Effect>;
  30210. /**
  30211. * Observable that will be called if an error occurs during shader compilation.
  30212. */
  30213. onErrorObservable: Observable<Effect>;
  30214. /** @hidden */
  30215. _onBindObservable: Nullable<Observable<Effect>>;
  30216. /**
  30217. * Observable that will be called when effect is bound.
  30218. */
  30219. readonly onBindObservable: Observable<Effect>;
  30220. /** @hidden */
  30221. _bonesComputationForcedToCPU: boolean;
  30222. private static _uniqueIdSeed;
  30223. private _engine;
  30224. private _uniformBuffersNames;
  30225. private _uniformsNames;
  30226. private _samplerList;
  30227. private _samplers;
  30228. private _isReady;
  30229. private _compilationError;
  30230. private _attributesNames;
  30231. private _attributes;
  30232. private _uniforms;
  30233. /**
  30234. * Key for the effect.
  30235. * @hidden
  30236. */
  30237. _key: string;
  30238. private _indexParameters;
  30239. private _fallbacks;
  30240. private _vertexSourceCode;
  30241. private _fragmentSourceCode;
  30242. private _vertexSourceCodeOverride;
  30243. private _fragmentSourceCodeOverride;
  30244. private _transformFeedbackVaryings;
  30245. /**
  30246. * Compiled shader to webGL program.
  30247. * @hidden
  30248. */
  30249. _pipelineContext: Nullable<IPipelineContext>;
  30250. private _valueCache;
  30251. private static _baseCache;
  30252. /**
  30253. * Instantiates an effect.
  30254. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30255. * @param baseName Name of the effect.
  30256. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30257. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30258. * @param samplers List of sampler variables that will be passed to the shader.
  30259. * @param engine Engine to be used to render the effect
  30260. * @param defines Define statements to be added to the shader.
  30261. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30262. * @param onCompiled Callback that will be called when the shader is compiled.
  30263. * @param onError Callback that will be called if an error occurs during shader compilation.
  30264. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30265. */
  30266. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30267. private _useFinalCode;
  30268. /**
  30269. * Unique key for this effect
  30270. */
  30271. readonly key: string;
  30272. /**
  30273. * If the effect has been compiled and prepared.
  30274. * @returns if the effect is compiled and prepared.
  30275. */
  30276. isReady(): boolean;
  30277. /**
  30278. * The engine the effect was initialized with.
  30279. * @returns the engine.
  30280. */
  30281. getEngine(): Engine;
  30282. /**
  30283. * The pipeline context for this effect
  30284. * @returns the associated pipeline context
  30285. */
  30286. getPipelineContext(): Nullable<IPipelineContext>;
  30287. /**
  30288. * The set of names of attribute variables for the shader.
  30289. * @returns An array of attribute names.
  30290. */
  30291. getAttributesNames(): string[];
  30292. /**
  30293. * Returns the attribute at the given index.
  30294. * @param index The index of the attribute.
  30295. * @returns The location of the attribute.
  30296. */
  30297. getAttributeLocation(index: number): number;
  30298. /**
  30299. * Returns the attribute based on the name of the variable.
  30300. * @param name of the attribute to look up.
  30301. * @returns the attribute location.
  30302. */
  30303. getAttributeLocationByName(name: string): number;
  30304. /**
  30305. * The number of attributes.
  30306. * @returns the numnber of attributes.
  30307. */
  30308. getAttributesCount(): number;
  30309. /**
  30310. * Gets the index of a uniform variable.
  30311. * @param uniformName of the uniform to look up.
  30312. * @returns the index.
  30313. */
  30314. getUniformIndex(uniformName: string): number;
  30315. /**
  30316. * Returns the attribute based on the name of the variable.
  30317. * @param uniformName of the uniform to look up.
  30318. * @returns the location of the uniform.
  30319. */
  30320. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30321. /**
  30322. * Returns an array of sampler variable names
  30323. * @returns The array of sampler variable neames.
  30324. */
  30325. getSamplers(): string[];
  30326. /**
  30327. * The error from the last compilation.
  30328. * @returns the error string.
  30329. */
  30330. getCompilationError(): string;
  30331. /**
  30332. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30333. * @param func The callback to be used.
  30334. */
  30335. executeWhenCompiled(func: (effect: Effect) => void): void;
  30336. private _checkIsReady;
  30337. /** @hidden */
  30338. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30339. /** @hidden */
  30340. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30341. /** @hidden */
  30342. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30343. /**
  30344. * Recompiles the webGL program
  30345. * @param vertexSourceCode The source code for the vertex shader.
  30346. * @param fragmentSourceCode The source code for the fragment shader.
  30347. * @param onCompiled Callback called when completed.
  30348. * @param onError Callback called on error.
  30349. * @hidden
  30350. */
  30351. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30352. /**
  30353. * Prepares the effect
  30354. * @hidden
  30355. */
  30356. _prepareEffect(): void;
  30357. /**
  30358. * Checks if the effect is supported. (Must be called after compilation)
  30359. */
  30360. readonly isSupported: boolean;
  30361. /**
  30362. * Binds a texture to the engine to be used as output of the shader.
  30363. * @param channel Name of the output variable.
  30364. * @param texture Texture to bind.
  30365. * @hidden
  30366. */
  30367. _bindTexture(channel: string, texture: InternalTexture): void;
  30368. /**
  30369. * Sets a texture on the engine to be used in the shader.
  30370. * @param channel Name of the sampler variable.
  30371. * @param texture Texture to set.
  30372. */
  30373. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30374. /**
  30375. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30376. * @param channel Name of the sampler variable.
  30377. * @param texture Texture to set.
  30378. */
  30379. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30380. /**
  30381. * Sets an array of textures on the engine to be used in the shader.
  30382. * @param channel Name of the variable.
  30383. * @param textures Textures to set.
  30384. */
  30385. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30386. /**
  30387. * 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)
  30388. * @param channel Name of the sampler variable.
  30389. * @param postProcess Post process to get the input texture from.
  30390. */
  30391. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30392. /**
  30393. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30394. * 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)
  30395. * @param channel Name of the sampler variable.
  30396. * @param postProcess Post process to get the output texture from.
  30397. */
  30398. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30399. /** @hidden */
  30400. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30401. /** @hidden */
  30402. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30403. /** @hidden */
  30404. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30405. /** @hidden */
  30406. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30407. /**
  30408. * Binds a buffer to a uniform.
  30409. * @param buffer Buffer to bind.
  30410. * @param name Name of the uniform variable to bind to.
  30411. */
  30412. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30413. /**
  30414. * Binds block to a uniform.
  30415. * @param blockName Name of the block to bind.
  30416. * @param index Index to bind.
  30417. */
  30418. bindUniformBlock(blockName: string, index: number): void;
  30419. /**
  30420. * Sets an interger value on a uniform variable.
  30421. * @param uniformName Name of the variable.
  30422. * @param value Value to be set.
  30423. * @returns this effect.
  30424. */
  30425. setInt(uniformName: string, value: number): Effect;
  30426. /**
  30427. * Sets an int array on a uniform variable.
  30428. * @param uniformName Name of the variable.
  30429. * @param array array to be set.
  30430. * @returns this effect.
  30431. */
  30432. setIntArray(uniformName: string, array: Int32Array): Effect;
  30433. /**
  30434. * 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)
  30435. * @param uniformName Name of the variable.
  30436. * @param array array to be set.
  30437. * @returns this effect.
  30438. */
  30439. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30440. /**
  30441. * 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)
  30442. * @param uniformName Name of the variable.
  30443. * @param array array to be set.
  30444. * @returns this effect.
  30445. */
  30446. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30447. /**
  30448. * 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)
  30449. * @param uniformName Name of the variable.
  30450. * @param array array to be set.
  30451. * @returns this effect.
  30452. */
  30453. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30454. /**
  30455. * Sets an float array on a uniform variable.
  30456. * @param uniformName Name of the variable.
  30457. * @param array array to be set.
  30458. * @returns this effect.
  30459. */
  30460. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30461. /**
  30462. * 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)
  30463. * @param uniformName Name of the variable.
  30464. * @param array array to be set.
  30465. * @returns this effect.
  30466. */
  30467. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30468. /**
  30469. * 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)
  30470. * @param uniformName Name of the variable.
  30471. * @param array array to be set.
  30472. * @returns this effect.
  30473. */
  30474. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30475. /**
  30476. * 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)
  30477. * @param uniformName Name of the variable.
  30478. * @param array array to be set.
  30479. * @returns this effect.
  30480. */
  30481. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30482. /**
  30483. * Sets an array on a uniform variable.
  30484. * @param uniformName Name of the variable.
  30485. * @param array array to be set.
  30486. * @returns this effect.
  30487. */
  30488. setArray(uniformName: string, array: number[]): Effect;
  30489. /**
  30490. * 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)
  30491. * @param uniformName Name of the variable.
  30492. * @param array array to be set.
  30493. * @returns this effect.
  30494. */
  30495. setArray2(uniformName: string, array: number[]): Effect;
  30496. /**
  30497. * 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)
  30498. * @param uniformName Name of the variable.
  30499. * @param array array to be set.
  30500. * @returns this effect.
  30501. */
  30502. setArray3(uniformName: string, array: number[]): Effect;
  30503. /**
  30504. * 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)
  30505. * @param uniformName Name of the variable.
  30506. * @param array array to be set.
  30507. * @returns this effect.
  30508. */
  30509. setArray4(uniformName: string, array: number[]): Effect;
  30510. /**
  30511. * Sets matrices on a uniform variable.
  30512. * @param uniformName Name of the variable.
  30513. * @param matrices matrices to be set.
  30514. * @returns this effect.
  30515. */
  30516. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30517. /**
  30518. * Sets matrix on a uniform variable.
  30519. * @param uniformName Name of the variable.
  30520. * @param matrix matrix to be set.
  30521. * @returns this effect.
  30522. */
  30523. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30524. /**
  30525. * 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)
  30526. * @param uniformName Name of the variable.
  30527. * @param matrix matrix to be set.
  30528. * @returns this effect.
  30529. */
  30530. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30531. /**
  30532. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30533. * @param uniformName Name of the variable.
  30534. * @param matrix matrix to be set.
  30535. * @returns this effect.
  30536. */
  30537. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30538. /**
  30539. * Sets a float on a uniform variable.
  30540. * @param uniformName Name of the variable.
  30541. * @param value value to be set.
  30542. * @returns this effect.
  30543. */
  30544. setFloat(uniformName: string, value: number): Effect;
  30545. /**
  30546. * Sets a boolean on a uniform variable.
  30547. * @param uniformName Name of the variable.
  30548. * @param bool value to be set.
  30549. * @returns this effect.
  30550. */
  30551. setBool(uniformName: string, bool: boolean): Effect;
  30552. /**
  30553. * Sets a Vector2 on a uniform variable.
  30554. * @param uniformName Name of the variable.
  30555. * @param vector2 vector2 to be set.
  30556. * @returns this effect.
  30557. */
  30558. setVector2(uniformName: string, vector2: Vector2): Effect;
  30559. /**
  30560. * Sets a float2 on a uniform variable.
  30561. * @param uniformName Name of the variable.
  30562. * @param x First float in float2.
  30563. * @param y Second float in float2.
  30564. * @returns this effect.
  30565. */
  30566. setFloat2(uniformName: string, x: number, y: number): Effect;
  30567. /**
  30568. * Sets a Vector3 on a uniform variable.
  30569. * @param uniformName Name of the variable.
  30570. * @param vector3 Value to be set.
  30571. * @returns this effect.
  30572. */
  30573. setVector3(uniformName: string, vector3: Vector3): Effect;
  30574. /**
  30575. * Sets a float3 on a uniform variable.
  30576. * @param uniformName Name of the variable.
  30577. * @param x First float in float3.
  30578. * @param y Second float in float3.
  30579. * @param z Third float in float3.
  30580. * @returns this effect.
  30581. */
  30582. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30583. /**
  30584. * Sets a Vector4 on a uniform variable.
  30585. * @param uniformName Name of the variable.
  30586. * @param vector4 Value to be set.
  30587. * @returns this effect.
  30588. */
  30589. setVector4(uniformName: string, vector4: Vector4): Effect;
  30590. /**
  30591. * Sets a float4 on a uniform variable.
  30592. * @param uniformName Name of the variable.
  30593. * @param x First float in float4.
  30594. * @param y Second float in float4.
  30595. * @param z Third float in float4.
  30596. * @param w Fourth float in float4.
  30597. * @returns this effect.
  30598. */
  30599. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30600. /**
  30601. * Sets a Color3 on a uniform variable.
  30602. * @param uniformName Name of the variable.
  30603. * @param color3 Value to be set.
  30604. * @returns this effect.
  30605. */
  30606. setColor3(uniformName: string, color3: Color3): Effect;
  30607. /**
  30608. * Sets a Color4 on a uniform variable.
  30609. * @param uniformName Name of the variable.
  30610. * @param color3 Value to be set.
  30611. * @param alpha Alpha value to be set.
  30612. * @returns this effect.
  30613. */
  30614. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30615. /**
  30616. * Sets a Color4 on a uniform variable
  30617. * @param uniformName defines the name of the variable
  30618. * @param color4 defines the value to be set
  30619. * @returns this effect.
  30620. */
  30621. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30622. /** Release all associated resources */
  30623. dispose(): void;
  30624. /**
  30625. * This function will add a new shader to the shader store
  30626. * @param name the name of the shader
  30627. * @param pixelShader optional pixel shader content
  30628. * @param vertexShader optional vertex shader content
  30629. */
  30630. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30631. /**
  30632. * Store of each shader (The can be looked up using effect.key)
  30633. */
  30634. static ShadersStore: {
  30635. [key: string]: string;
  30636. };
  30637. /**
  30638. * Store of each included file for a shader (The can be looked up using effect.key)
  30639. */
  30640. static IncludesShadersStore: {
  30641. [key: string]: string;
  30642. };
  30643. /**
  30644. * Resets the cache of effects.
  30645. */
  30646. static ResetCache(): void;
  30647. }
  30648. }
  30649. declare module "babylonjs/Materials/colorCurves" {
  30650. import { Effect } from "babylonjs/Materials/effect";
  30651. /**
  30652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30654. * 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;
  30655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30656. */
  30657. export class ColorCurves {
  30658. private _dirty;
  30659. private _tempColor;
  30660. private _globalCurve;
  30661. private _highlightsCurve;
  30662. private _midtonesCurve;
  30663. private _shadowsCurve;
  30664. private _positiveCurve;
  30665. private _negativeCurve;
  30666. private _globalHue;
  30667. private _globalDensity;
  30668. private _globalSaturation;
  30669. private _globalExposure;
  30670. /**
  30671. * Gets the global Hue value.
  30672. * 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).
  30673. */
  30674. /**
  30675. * Sets the global Hue value.
  30676. * 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).
  30677. */
  30678. globalHue: number;
  30679. /**
  30680. * Gets the global Density value.
  30681. * 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.
  30682. * Values less than zero provide a filter of opposite hue.
  30683. */
  30684. /**
  30685. * Sets the global Density value.
  30686. * 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.
  30687. * Values less than zero provide a filter of opposite hue.
  30688. */
  30689. globalDensity: number;
  30690. /**
  30691. * Gets the global Saturation value.
  30692. * 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.
  30693. */
  30694. /**
  30695. * Sets the global Saturation value.
  30696. * 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.
  30697. */
  30698. globalSaturation: number;
  30699. /**
  30700. * Gets the global Exposure value.
  30701. * 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.
  30702. */
  30703. /**
  30704. * Sets the global Exposure value.
  30705. * 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.
  30706. */
  30707. globalExposure: number;
  30708. private _highlightsHue;
  30709. private _highlightsDensity;
  30710. private _highlightsSaturation;
  30711. private _highlightsExposure;
  30712. /**
  30713. * Gets the highlights Hue value.
  30714. * 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).
  30715. */
  30716. /**
  30717. * Sets the highlights Hue value.
  30718. * 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).
  30719. */
  30720. highlightsHue: number;
  30721. /**
  30722. * Gets the highlights Density value.
  30723. * 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.
  30724. * Values less than zero provide a filter of opposite hue.
  30725. */
  30726. /**
  30727. * Sets the highlights Density value.
  30728. * 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.
  30729. * Values less than zero provide a filter of opposite hue.
  30730. */
  30731. highlightsDensity: number;
  30732. /**
  30733. * Gets the highlights Saturation value.
  30734. * 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.
  30735. */
  30736. /**
  30737. * Sets the highlights Saturation value.
  30738. * 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.
  30739. */
  30740. highlightsSaturation: number;
  30741. /**
  30742. * Gets the highlights Exposure value.
  30743. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30744. */
  30745. /**
  30746. * Sets the highlights Exposure value.
  30747. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30748. */
  30749. highlightsExposure: number;
  30750. private _midtonesHue;
  30751. private _midtonesDensity;
  30752. private _midtonesSaturation;
  30753. private _midtonesExposure;
  30754. /**
  30755. * Gets the midtones Hue value.
  30756. * 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).
  30757. */
  30758. /**
  30759. * Sets the midtones Hue value.
  30760. * 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).
  30761. */
  30762. midtonesHue: number;
  30763. /**
  30764. * Gets the midtones Density value.
  30765. * 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.
  30766. * Values less than zero provide a filter of opposite hue.
  30767. */
  30768. /**
  30769. * Sets the midtones Density value.
  30770. * 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.
  30771. * Values less than zero provide a filter of opposite hue.
  30772. */
  30773. midtonesDensity: number;
  30774. /**
  30775. * Gets the midtones Saturation value.
  30776. * 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.
  30777. */
  30778. /**
  30779. * Sets the midtones Saturation value.
  30780. * 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.
  30781. */
  30782. midtonesSaturation: number;
  30783. /**
  30784. * Gets the midtones Exposure value.
  30785. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30786. */
  30787. /**
  30788. * Sets the midtones Exposure value.
  30789. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30790. */
  30791. midtonesExposure: number;
  30792. private _shadowsHue;
  30793. private _shadowsDensity;
  30794. private _shadowsSaturation;
  30795. private _shadowsExposure;
  30796. /**
  30797. * Gets the shadows Hue value.
  30798. * 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).
  30799. */
  30800. /**
  30801. * Sets the shadows Hue value.
  30802. * 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).
  30803. */
  30804. shadowsHue: number;
  30805. /**
  30806. * Gets the shadows Density value.
  30807. * 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.
  30808. * Values less than zero provide a filter of opposite hue.
  30809. */
  30810. /**
  30811. * Sets the shadows Density value.
  30812. * 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.
  30813. * Values less than zero provide a filter of opposite hue.
  30814. */
  30815. shadowsDensity: number;
  30816. /**
  30817. * Gets the shadows Saturation value.
  30818. * 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.
  30819. */
  30820. /**
  30821. * Sets the shadows Saturation value.
  30822. * 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.
  30823. */
  30824. shadowsSaturation: number;
  30825. /**
  30826. * Gets the shadows Exposure value.
  30827. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30828. */
  30829. /**
  30830. * Sets the shadows Exposure value.
  30831. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30832. */
  30833. shadowsExposure: number;
  30834. /**
  30835. * Returns the class name
  30836. * @returns The class name
  30837. */
  30838. getClassName(): string;
  30839. /**
  30840. * Binds the color curves to the shader.
  30841. * @param colorCurves The color curve to bind
  30842. * @param effect The effect to bind to
  30843. * @param positiveUniform The positive uniform shader parameter
  30844. * @param neutralUniform The neutral uniform shader parameter
  30845. * @param negativeUniform The negative uniform shader parameter
  30846. */
  30847. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30848. /**
  30849. * Prepare the list of uniforms associated with the ColorCurves effects.
  30850. * @param uniformsList The list of uniforms used in the effect
  30851. */
  30852. static PrepareUniforms(uniformsList: string[]): void;
  30853. /**
  30854. * Returns color grading data based on a hue, density, saturation and exposure value.
  30855. * @param filterHue The hue of the color filter.
  30856. * @param filterDensity The density of the color filter.
  30857. * @param saturation The saturation.
  30858. * @param exposure The exposure.
  30859. * @param result The result data container.
  30860. */
  30861. private getColorGradingDataToRef;
  30862. /**
  30863. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30864. * @param value The input slider value in range [-100,100].
  30865. * @returns Adjusted value.
  30866. */
  30867. private static applyColorGradingSliderNonlinear;
  30868. /**
  30869. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30870. * @param hue The hue (H) input.
  30871. * @param saturation The saturation (S) input.
  30872. * @param brightness The brightness (B) input.
  30873. * @result An RGBA color represented as Vector4.
  30874. */
  30875. private static fromHSBToRef;
  30876. /**
  30877. * Returns a value clamped between min and max
  30878. * @param value The value to clamp
  30879. * @param min The minimum of value
  30880. * @param max The maximum of value
  30881. * @returns The clamped value.
  30882. */
  30883. private static clamp;
  30884. /**
  30885. * Clones the current color curve instance.
  30886. * @return The cloned curves
  30887. */
  30888. clone(): ColorCurves;
  30889. /**
  30890. * Serializes the current color curve instance to a json representation.
  30891. * @return a JSON representation
  30892. */
  30893. serialize(): any;
  30894. /**
  30895. * Parses the color curve from a json representation.
  30896. * @param source the JSON source to parse
  30897. * @return The parsed curves
  30898. */
  30899. static Parse(source: any): ColorCurves;
  30900. }
  30901. }
  30902. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30903. import { Observable } from "babylonjs/Misc/observable";
  30904. import { Nullable } from "babylonjs/types";
  30905. import { Color4 } from "babylonjs/Maths/math";
  30906. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30907. import { Effect } from "babylonjs/Materials/effect";
  30908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30909. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30910. /**
  30911. * Interface to follow in your material defines to integrate easily the
  30912. * Image proccessing functions.
  30913. * @hidden
  30914. */
  30915. export interface IImageProcessingConfigurationDefines {
  30916. IMAGEPROCESSING: boolean;
  30917. VIGNETTE: boolean;
  30918. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30919. VIGNETTEBLENDMODEOPAQUE: boolean;
  30920. TONEMAPPING: boolean;
  30921. TONEMAPPING_ACES: boolean;
  30922. CONTRAST: boolean;
  30923. EXPOSURE: boolean;
  30924. COLORCURVES: boolean;
  30925. COLORGRADING: boolean;
  30926. COLORGRADING3D: boolean;
  30927. SAMPLER3DGREENDEPTH: boolean;
  30928. SAMPLER3DBGRMAP: boolean;
  30929. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30930. }
  30931. /**
  30932. * @hidden
  30933. */
  30934. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30935. IMAGEPROCESSING: boolean;
  30936. VIGNETTE: boolean;
  30937. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30938. VIGNETTEBLENDMODEOPAQUE: boolean;
  30939. TONEMAPPING: boolean;
  30940. TONEMAPPING_ACES: boolean;
  30941. CONTRAST: boolean;
  30942. COLORCURVES: boolean;
  30943. COLORGRADING: boolean;
  30944. COLORGRADING3D: boolean;
  30945. SAMPLER3DGREENDEPTH: boolean;
  30946. SAMPLER3DBGRMAP: boolean;
  30947. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30948. EXPOSURE: boolean;
  30949. constructor();
  30950. }
  30951. /**
  30952. * This groups together the common properties used for image processing either in direct forward pass
  30953. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30954. * or not.
  30955. */
  30956. export class ImageProcessingConfiguration {
  30957. /**
  30958. * Default tone mapping applied in BabylonJS.
  30959. */
  30960. static readonly TONEMAPPING_STANDARD: number;
  30961. /**
  30962. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30963. * to other engines rendering to increase portability.
  30964. */
  30965. static readonly TONEMAPPING_ACES: number;
  30966. /**
  30967. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30968. */
  30969. colorCurves: Nullable<ColorCurves>;
  30970. private _colorCurvesEnabled;
  30971. /**
  30972. * Gets wether the color curves effect is enabled.
  30973. */
  30974. /**
  30975. * Sets wether the color curves effect is enabled.
  30976. */
  30977. colorCurvesEnabled: boolean;
  30978. private _colorGradingTexture;
  30979. /**
  30980. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30981. */
  30982. /**
  30983. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30984. */
  30985. colorGradingTexture: Nullable<BaseTexture>;
  30986. private _colorGradingEnabled;
  30987. /**
  30988. * Gets wether the color grading effect is enabled.
  30989. */
  30990. /**
  30991. * Sets wether the color grading effect is enabled.
  30992. */
  30993. colorGradingEnabled: boolean;
  30994. private _colorGradingWithGreenDepth;
  30995. /**
  30996. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30997. */
  30998. /**
  30999. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31000. */
  31001. colorGradingWithGreenDepth: boolean;
  31002. private _colorGradingBGR;
  31003. /**
  31004. * Gets wether the color grading texture contains BGR values.
  31005. */
  31006. /**
  31007. * Sets wether the color grading texture contains BGR values.
  31008. */
  31009. colorGradingBGR: boolean;
  31010. /** @hidden */
  31011. _exposure: number;
  31012. /**
  31013. * Gets the Exposure used in the effect.
  31014. */
  31015. /**
  31016. * Sets the Exposure used in the effect.
  31017. */
  31018. exposure: number;
  31019. private _toneMappingEnabled;
  31020. /**
  31021. * Gets wether the tone mapping effect is enabled.
  31022. */
  31023. /**
  31024. * Sets wether the tone mapping effect is enabled.
  31025. */
  31026. toneMappingEnabled: boolean;
  31027. private _toneMappingType;
  31028. /**
  31029. * Gets the type of tone mapping effect.
  31030. */
  31031. /**
  31032. * Sets the type of tone mapping effect used in BabylonJS.
  31033. */
  31034. toneMappingType: number;
  31035. protected _contrast: number;
  31036. /**
  31037. * Gets the contrast used in the effect.
  31038. */
  31039. /**
  31040. * Sets the contrast used in the effect.
  31041. */
  31042. contrast: number;
  31043. /**
  31044. * Vignette stretch size.
  31045. */
  31046. vignetteStretch: number;
  31047. /**
  31048. * Vignette centre X Offset.
  31049. */
  31050. vignetteCentreX: number;
  31051. /**
  31052. * Vignette centre Y Offset.
  31053. */
  31054. vignetteCentreY: number;
  31055. /**
  31056. * Vignette weight or intensity of the vignette effect.
  31057. */
  31058. vignetteWeight: number;
  31059. /**
  31060. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31061. * if vignetteEnabled is set to true.
  31062. */
  31063. vignetteColor: Color4;
  31064. /**
  31065. * Camera field of view used by the Vignette effect.
  31066. */
  31067. vignetteCameraFov: number;
  31068. private _vignetteBlendMode;
  31069. /**
  31070. * Gets the vignette blend mode allowing different kind of effect.
  31071. */
  31072. /**
  31073. * Sets the vignette blend mode allowing different kind of effect.
  31074. */
  31075. vignetteBlendMode: number;
  31076. private _vignetteEnabled;
  31077. /**
  31078. * Gets wether the vignette effect is enabled.
  31079. */
  31080. /**
  31081. * Sets wether the vignette effect is enabled.
  31082. */
  31083. vignetteEnabled: boolean;
  31084. private _applyByPostProcess;
  31085. /**
  31086. * Gets wether the image processing is applied through a post process or not.
  31087. */
  31088. /**
  31089. * Sets wether the image processing is applied through a post process or not.
  31090. */
  31091. applyByPostProcess: boolean;
  31092. private _isEnabled;
  31093. /**
  31094. * Gets wether the image processing is enabled or not.
  31095. */
  31096. /**
  31097. * Sets wether the image processing is enabled or not.
  31098. */
  31099. isEnabled: boolean;
  31100. /**
  31101. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31102. */
  31103. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31104. /**
  31105. * Method called each time the image processing information changes requires to recompile the effect.
  31106. */
  31107. protected _updateParameters(): void;
  31108. /**
  31109. * Gets the current class name.
  31110. * @return "ImageProcessingConfiguration"
  31111. */
  31112. getClassName(): string;
  31113. /**
  31114. * Prepare the list of uniforms associated with the Image Processing effects.
  31115. * @param uniforms The list of uniforms used in the effect
  31116. * @param defines the list of defines currently in use
  31117. */
  31118. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31119. /**
  31120. * Prepare the list of samplers associated with the Image Processing effects.
  31121. * @param samplersList The list of uniforms used in the effect
  31122. * @param defines the list of defines currently in use
  31123. */
  31124. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31125. /**
  31126. * Prepare the list of defines associated to the shader.
  31127. * @param defines the list of defines to complete
  31128. * @param forPostProcess Define if we are currently in post process mode or not
  31129. */
  31130. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31131. /**
  31132. * Returns true if all the image processing information are ready.
  31133. * @returns True if ready, otherwise, false
  31134. */
  31135. isReady(): boolean;
  31136. /**
  31137. * Binds the image processing to the shader.
  31138. * @param effect The effect to bind to
  31139. * @param aspectRatio Define the current aspect ratio of the effect
  31140. */
  31141. bind(effect: Effect, aspectRatio?: number): void;
  31142. /**
  31143. * Clones the current image processing instance.
  31144. * @return The cloned image processing
  31145. */
  31146. clone(): ImageProcessingConfiguration;
  31147. /**
  31148. * Serializes the current image processing instance to a json representation.
  31149. * @return a JSON representation
  31150. */
  31151. serialize(): any;
  31152. /**
  31153. * Parses the image processing from a json representation.
  31154. * @param source the JSON source to parse
  31155. * @return The parsed image processing
  31156. */
  31157. static Parse(source: any): ImageProcessingConfiguration;
  31158. private static _VIGNETTEMODE_MULTIPLY;
  31159. private static _VIGNETTEMODE_OPAQUE;
  31160. /**
  31161. * Used to apply the vignette as a mix with the pixel color.
  31162. */
  31163. static readonly VIGNETTEMODE_MULTIPLY: number;
  31164. /**
  31165. * Used to apply the vignette as a replacement of the pixel color.
  31166. */
  31167. static readonly VIGNETTEMODE_OPAQUE: number;
  31168. }
  31169. }
  31170. declare module "babylonjs/Materials/fresnelParameters" {
  31171. import { Color3 } from "babylonjs/Maths/math";
  31172. /**
  31173. * This represents all the required information to add a fresnel effect on a material:
  31174. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31175. */
  31176. export class FresnelParameters {
  31177. private _isEnabled;
  31178. /**
  31179. * Define if the fresnel effect is enable or not.
  31180. */
  31181. isEnabled: boolean;
  31182. /**
  31183. * Define the color used on edges (grazing angle)
  31184. */
  31185. leftColor: Color3;
  31186. /**
  31187. * Define the color used on center
  31188. */
  31189. rightColor: Color3;
  31190. /**
  31191. * Define bias applied to computed fresnel term
  31192. */
  31193. bias: number;
  31194. /**
  31195. * Defined the power exponent applied to fresnel term
  31196. */
  31197. power: number;
  31198. /**
  31199. * Clones the current fresnel and its valuues
  31200. * @returns a clone fresnel configuration
  31201. */
  31202. clone(): FresnelParameters;
  31203. /**
  31204. * Serializes the current fresnel parameters to a JSON representation.
  31205. * @return the JSON serialization
  31206. */
  31207. serialize(): any;
  31208. /**
  31209. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31210. * @param parsedFresnelParameters Define the JSON representation
  31211. * @returns the parsed parameters
  31212. */
  31213. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31214. }
  31215. }
  31216. declare module "babylonjs/Misc/decorators" {
  31217. import { Nullable } from "babylonjs/types";
  31218. import { Scene } from "babylonjs/scene";
  31219. import { IAnimatable } from "babylonjs/Misc/tools";
  31220. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31221. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31222. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31223. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31224. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31225. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31226. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31227. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31228. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31229. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31230. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31231. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31232. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31233. /**
  31234. * Decorator used to define property that can be serialized as reference to a camera
  31235. * @param sourceName defines the name of the property to decorate
  31236. */
  31237. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31238. /**
  31239. * Class used to help serialization objects
  31240. */
  31241. export class SerializationHelper {
  31242. /** @hidden */
  31243. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31244. /** @hidden */
  31245. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31246. /** @hidden */
  31247. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31248. /** @hidden */
  31249. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31250. /**
  31251. * Appends the serialized animations from the source animations
  31252. * @param source Source containing the animations
  31253. * @param destination Target to store the animations
  31254. */
  31255. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31256. /**
  31257. * Static function used to serialized a specific entity
  31258. * @param entity defines the entity to serialize
  31259. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31260. * @returns a JSON compatible object representing the serialization of the entity
  31261. */
  31262. static Serialize<T>(entity: T, serializationObject?: any): any;
  31263. /**
  31264. * Creates a new entity from a serialization data object
  31265. * @param creationFunction defines a function used to instanciated the new entity
  31266. * @param source defines the source serialization data
  31267. * @param scene defines the hosting scene
  31268. * @param rootUrl defines the root url for resources
  31269. * @returns a new entity
  31270. */
  31271. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31272. /**
  31273. * Clones an object
  31274. * @param creationFunction defines the function used to instanciate the new object
  31275. * @param source defines the source object
  31276. * @returns the cloned object
  31277. */
  31278. static Clone<T>(creationFunction: () => T, source: T): T;
  31279. /**
  31280. * Instanciates a new object based on a source one (some data will be shared between both object)
  31281. * @param creationFunction defines the function used to instanciate the new object
  31282. * @param source defines the source object
  31283. * @returns the new object
  31284. */
  31285. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31286. }
  31287. }
  31288. declare module "babylonjs/Cameras/camera" {
  31289. import { SmartArray } from "babylonjs/Misc/smartArray";
  31290. import { Observable } from "babylonjs/Misc/observable";
  31291. import { Nullable } from "babylonjs/types";
  31292. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31293. import { Scene } from "babylonjs/scene";
  31294. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31295. import { Node } from "babylonjs/node";
  31296. import { Mesh } from "babylonjs/Meshes/mesh";
  31297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31298. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31299. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31300. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31301. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31302. import { Ray } from "babylonjs/Culling/ray";
  31303. /**
  31304. * This is the base class of all the camera used in the application.
  31305. * @see http://doc.babylonjs.com/features/cameras
  31306. */
  31307. export class Camera extends Node {
  31308. /** @hidden */
  31309. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31310. /**
  31311. * This is the default projection mode used by the cameras.
  31312. * It helps recreating a feeling of perspective and better appreciate depth.
  31313. * This is the best way to simulate real life cameras.
  31314. */
  31315. static readonly PERSPECTIVE_CAMERA: number;
  31316. /**
  31317. * This helps creating camera with an orthographic mode.
  31318. * 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.
  31319. */
  31320. static readonly ORTHOGRAPHIC_CAMERA: number;
  31321. /**
  31322. * This is the default FOV mode for perspective cameras.
  31323. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31324. */
  31325. static readonly FOVMODE_VERTICAL_FIXED: number;
  31326. /**
  31327. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31328. */
  31329. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31330. /**
  31331. * This specifies ther is no need for a camera rig.
  31332. * Basically only one eye is rendered corresponding to the camera.
  31333. */
  31334. static readonly RIG_MODE_NONE: number;
  31335. /**
  31336. * Simulates a camera Rig with one blue eye and one red eye.
  31337. * This can be use with 3d blue and red glasses.
  31338. */
  31339. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31340. /**
  31341. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31342. */
  31343. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31344. /**
  31345. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31346. */
  31347. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31348. /**
  31349. * Defines that both eyes of the camera will be rendered over under each other.
  31350. */
  31351. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31352. /**
  31353. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31354. */
  31355. static readonly RIG_MODE_VR: number;
  31356. /**
  31357. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31358. */
  31359. static readonly RIG_MODE_WEBVR: number;
  31360. /**
  31361. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31362. */
  31363. static readonly RIG_MODE_CUSTOM: number;
  31364. /**
  31365. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31366. */
  31367. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31368. /**
  31369. * Define the input manager associated with the camera.
  31370. */
  31371. inputs: CameraInputsManager<Camera>;
  31372. /** @hidden */
  31373. _position: Vector3;
  31374. /**
  31375. * Define the current local position of the camera in the scene
  31376. */
  31377. position: Vector3;
  31378. /**
  31379. * The vector the camera should consider as up.
  31380. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31381. */
  31382. upVector: Vector3;
  31383. /**
  31384. * Define the current limit on the left side for an orthographic camera
  31385. * In scene unit
  31386. */
  31387. orthoLeft: Nullable<number>;
  31388. /**
  31389. * Define the current limit on the right side for an orthographic camera
  31390. * In scene unit
  31391. */
  31392. orthoRight: Nullable<number>;
  31393. /**
  31394. * Define the current limit on the bottom side for an orthographic camera
  31395. * In scene unit
  31396. */
  31397. orthoBottom: Nullable<number>;
  31398. /**
  31399. * Define the current limit on the top side for an orthographic camera
  31400. * In scene unit
  31401. */
  31402. orthoTop: Nullable<number>;
  31403. /**
  31404. * Field Of View is set in Radians. (default is 0.8)
  31405. */
  31406. fov: number;
  31407. /**
  31408. * Define the minimum distance the camera can see from.
  31409. * This is important to note that the depth buffer are not infinite and the closer it starts
  31410. * the more your scene might encounter depth fighting issue.
  31411. */
  31412. minZ: number;
  31413. /**
  31414. * Define the maximum distance the camera can see to.
  31415. * This is important to note that the depth buffer are not infinite and the further it end
  31416. * the more your scene might encounter depth fighting issue.
  31417. */
  31418. maxZ: number;
  31419. /**
  31420. * Define the default inertia of the camera.
  31421. * This helps giving a smooth feeling to the camera movement.
  31422. */
  31423. inertia: number;
  31424. /**
  31425. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31426. */
  31427. mode: number;
  31428. /**
  31429. * Define wether the camera is intermediate.
  31430. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31431. */
  31432. isIntermediate: boolean;
  31433. /**
  31434. * Define the viewport of the camera.
  31435. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31436. */
  31437. viewport: Viewport;
  31438. /**
  31439. * Restricts the camera to viewing objects with the same layerMask.
  31440. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31441. */
  31442. layerMask: number;
  31443. /**
  31444. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31445. */
  31446. fovMode: number;
  31447. /**
  31448. * Rig mode of the camera.
  31449. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31450. * This is normally controlled byt the camera themselves as internal use.
  31451. */
  31452. cameraRigMode: number;
  31453. /**
  31454. * Defines the distance between both "eyes" in case of a RIG
  31455. */
  31456. interaxialDistance: number;
  31457. /**
  31458. * Defines if stereoscopic rendering is done side by side or over under.
  31459. */
  31460. isStereoscopicSideBySide: boolean;
  31461. /**
  31462. * 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
  31463. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31464. * else in the scene.
  31465. */
  31466. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31467. /**
  31468. * When set, the camera will render to this render target instead of the default canvas
  31469. */
  31470. outputRenderTarget: Nullable<RenderTargetTexture>;
  31471. /**
  31472. * Observable triggered when the camera view matrix has changed.
  31473. */
  31474. onViewMatrixChangedObservable: Observable<Camera>;
  31475. /**
  31476. * Observable triggered when the camera Projection matrix has changed.
  31477. */
  31478. onProjectionMatrixChangedObservable: Observable<Camera>;
  31479. /**
  31480. * Observable triggered when the inputs have been processed.
  31481. */
  31482. onAfterCheckInputsObservable: Observable<Camera>;
  31483. /**
  31484. * Observable triggered when reset has been called and applied to the camera.
  31485. */
  31486. onRestoreStateObservable: Observable<Camera>;
  31487. /** @hidden */
  31488. _cameraRigParams: any;
  31489. /** @hidden */
  31490. _rigCameras: Camera[];
  31491. /** @hidden */
  31492. _rigPostProcess: Nullable<PostProcess>;
  31493. protected _webvrViewMatrix: Matrix;
  31494. /** @hidden */
  31495. _skipRendering: boolean;
  31496. /** @hidden */
  31497. _projectionMatrix: Matrix;
  31498. /** @hidden */
  31499. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31500. /** @hidden */
  31501. _activeMeshes: SmartArray<AbstractMesh>;
  31502. protected _globalPosition: Vector3;
  31503. /** @hidden */
  31504. _computedViewMatrix: Matrix;
  31505. private _doNotComputeProjectionMatrix;
  31506. private _transformMatrix;
  31507. private _frustumPlanes;
  31508. private _refreshFrustumPlanes;
  31509. private _storedFov;
  31510. private _stateStored;
  31511. /**
  31512. * Instantiates a new camera object.
  31513. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31514. * @see http://doc.babylonjs.com/features/cameras
  31515. * @param name Defines the name of the camera in the scene
  31516. * @param position Defines the position of the camera
  31517. * @param scene Defines the scene the camera belongs too
  31518. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31519. */
  31520. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31521. /**
  31522. * Store current camera state (fov, position, etc..)
  31523. * @returns the camera
  31524. */
  31525. storeState(): Camera;
  31526. /**
  31527. * Restores the camera state values if it has been stored. You must call storeState() first
  31528. */
  31529. protected _restoreStateValues(): boolean;
  31530. /**
  31531. * Restored camera state. You must call storeState() first.
  31532. * @returns true if restored and false otherwise
  31533. */
  31534. restoreState(): boolean;
  31535. /**
  31536. * Gets the class name of the camera.
  31537. * @returns the class name
  31538. */
  31539. getClassName(): string;
  31540. /** @hidden */
  31541. readonly _isCamera: boolean;
  31542. /**
  31543. * Gets a string representation of the camera useful for debug purpose.
  31544. * @param fullDetails Defines that a more verboe level of logging is required
  31545. * @returns the string representation
  31546. */
  31547. toString(fullDetails?: boolean): string;
  31548. /**
  31549. * Gets the current world space position of the camera.
  31550. */
  31551. readonly globalPosition: Vector3;
  31552. /**
  31553. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31554. * @returns the active meshe list
  31555. */
  31556. getActiveMeshes(): SmartArray<AbstractMesh>;
  31557. /**
  31558. * Check wether a mesh is part of the current active mesh list of the camera
  31559. * @param mesh Defines the mesh to check
  31560. * @returns true if active, false otherwise
  31561. */
  31562. isActiveMesh(mesh: Mesh): boolean;
  31563. /**
  31564. * Is this camera ready to be used/rendered
  31565. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31566. * @return true if the camera is ready
  31567. */
  31568. isReady(completeCheck?: boolean): boolean;
  31569. /** @hidden */
  31570. _initCache(): void;
  31571. /** @hidden */
  31572. _updateCache(ignoreParentClass?: boolean): void;
  31573. /** @hidden */
  31574. _isSynchronized(): boolean;
  31575. /** @hidden */
  31576. _isSynchronizedViewMatrix(): boolean;
  31577. /** @hidden */
  31578. _isSynchronizedProjectionMatrix(): boolean;
  31579. /**
  31580. * Attach the input controls to a specific dom element to get the input from.
  31581. * @param element Defines the element the controls should be listened from
  31582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31583. */
  31584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31585. /**
  31586. * Detach the current controls from the specified dom element.
  31587. * @param element Defines the element to stop listening the inputs from
  31588. */
  31589. detachControl(element: HTMLElement): void;
  31590. /**
  31591. * Update the camera state according to the different inputs gathered during the frame.
  31592. */
  31593. update(): void;
  31594. /** @hidden */
  31595. _checkInputs(): void;
  31596. /** @hidden */
  31597. readonly rigCameras: Camera[];
  31598. /**
  31599. * Gets the post process used by the rig cameras
  31600. */
  31601. readonly rigPostProcess: Nullable<PostProcess>;
  31602. /**
  31603. * Internal, gets the first post proces.
  31604. * @returns the first post process to be run on this camera.
  31605. */
  31606. _getFirstPostProcess(): Nullable<PostProcess>;
  31607. private _cascadePostProcessesToRigCams;
  31608. /**
  31609. * Attach a post process to the camera.
  31610. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31611. * @param postProcess The post process to attach to the camera
  31612. * @param insertAt The position of the post process in case several of them are in use in the scene
  31613. * @returns the position the post process has been inserted at
  31614. */
  31615. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31616. /**
  31617. * Detach a post process to the camera.
  31618. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31619. * @param postProcess The post process to detach from the camera
  31620. */
  31621. detachPostProcess(postProcess: PostProcess): void;
  31622. /**
  31623. * Gets the current world matrix of the camera
  31624. */
  31625. getWorldMatrix(): Matrix;
  31626. /** @hidden */
  31627. _getViewMatrix(): Matrix;
  31628. /**
  31629. * Gets the current view matrix of the camera.
  31630. * @param force forces the camera to recompute the matrix without looking at the cached state
  31631. * @returns the view matrix
  31632. */
  31633. getViewMatrix(force?: boolean): Matrix;
  31634. /**
  31635. * Freeze the projection matrix.
  31636. * It will prevent the cache check of the camera projection compute and can speed up perf
  31637. * if no parameter of the camera are meant to change
  31638. * @param projection Defines manually a projection if necessary
  31639. */
  31640. freezeProjectionMatrix(projection?: Matrix): void;
  31641. /**
  31642. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31643. */
  31644. unfreezeProjectionMatrix(): void;
  31645. /**
  31646. * Gets the current projection matrix of the camera.
  31647. * @param force forces the camera to recompute the matrix without looking at the cached state
  31648. * @returns the projection matrix
  31649. */
  31650. getProjectionMatrix(force?: boolean): Matrix;
  31651. /**
  31652. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31653. * @returns a Matrix
  31654. */
  31655. getTransformationMatrix(): Matrix;
  31656. private _updateFrustumPlanes;
  31657. /**
  31658. * Checks if a cullable object (mesh...) is in the camera frustum
  31659. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31660. * @param target The object to check
  31661. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31662. * @returns true if the object is in frustum otherwise false
  31663. */
  31664. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31665. /**
  31666. * Checks if a cullable object (mesh...) is in the camera frustum
  31667. * Unlike isInFrustum this cheks the full bounding box
  31668. * @param target The object to check
  31669. * @returns true if the object is in frustum otherwise false
  31670. */
  31671. isCompletelyInFrustum(target: ICullable): boolean;
  31672. /**
  31673. * Gets a ray in the forward direction from the camera.
  31674. * @param length Defines the length of the ray to create
  31675. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31676. * @param origin Defines the start point of the ray which defaults to the camera position
  31677. * @returns the forward ray
  31678. */
  31679. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31680. /**
  31681. * Releases resources associated with this node.
  31682. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31683. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31684. */
  31685. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31686. /** @hidden */
  31687. _isLeftCamera: boolean;
  31688. /**
  31689. * Gets the left camera of a rig setup in case of Rigged Camera
  31690. */
  31691. readonly isLeftCamera: boolean;
  31692. /** @hidden */
  31693. _isRightCamera: boolean;
  31694. /**
  31695. * Gets the right camera of a rig setup in case of Rigged Camera
  31696. */
  31697. readonly isRightCamera: boolean;
  31698. /**
  31699. * Gets the left camera of a rig setup in case of Rigged Camera
  31700. */
  31701. readonly leftCamera: Nullable<FreeCamera>;
  31702. /**
  31703. * Gets the right camera of a rig setup in case of Rigged Camera
  31704. */
  31705. readonly rightCamera: Nullable<FreeCamera>;
  31706. /**
  31707. * Gets the left camera target of a rig setup in case of Rigged Camera
  31708. * @returns the target position
  31709. */
  31710. getLeftTarget(): Nullable<Vector3>;
  31711. /**
  31712. * Gets the right camera target of a rig setup in case of Rigged Camera
  31713. * @returns the target position
  31714. */
  31715. getRightTarget(): Nullable<Vector3>;
  31716. /**
  31717. * @hidden
  31718. */
  31719. setCameraRigMode(mode: number, rigParams: any): void;
  31720. /** @hidden */
  31721. static _setStereoscopicRigMode(camera: Camera): void;
  31722. /** @hidden */
  31723. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31724. /** @hidden */
  31725. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31726. /** @hidden */
  31727. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31728. /** @hidden */
  31729. _getVRProjectionMatrix(): Matrix;
  31730. protected _updateCameraRotationMatrix(): void;
  31731. protected _updateWebVRCameraRotationMatrix(): void;
  31732. /**
  31733. * This function MUST be overwritten by the different WebVR cameras available.
  31734. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31735. * @hidden
  31736. */
  31737. _getWebVRProjectionMatrix(): Matrix;
  31738. /**
  31739. * This function MUST be overwritten by the different WebVR cameras available.
  31740. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31741. * @hidden
  31742. */
  31743. _getWebVRViewMatrix(): Matrix;
  31744. /** @hidden */
  31745. setCameraRigParameter(name: string, value: any): void;
  31746. /**
  31747. * needs to be overridden by children so sub has required properties to be copied
  31748. * @hidden
  31749. */
  31750. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31751. /**
  31752. * May need to be overridden by children
  31753. * @hidden
  31754. */
  31755. _updateRigCameras(): void;
  31756. /** @hidden */
  31757. _setupInputs(): void;
  31758. /**
  31759. * Serialiaze the camera setup to a json represention
  31760. * @returns the JSON representation
  31761. */
  31762. serialize(): any;
  31763. /**
  31764. * Clones the current camera.
  31765. * @param name The cloned camera name
  31766. * @returns the cloned camera
  31767. */
  31768. clone(name: string): Camera;
  31769. /**
  31770. * Gets the direction of the camera relative to a given local axis.
  31771. * @param localAxis Defines the reference axis to provide a relative direction.
  31772. * @return the direction
  31773. */
  31774. getDirection(localAxis: Vector3): Vector3;
  31775. /**
  31776. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31777. * @param localAxis Defines the reference axis to provide a relative direction.
  31778. * @param result Defines the vector to store the result in
  31779. */
  31780. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31781. /**
  31782. * Gets a camera constructor for a given camera type
  31783. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31784. * @param name The name of the camera the result will be able to instantiate
  31785. * @param scene The scene the result will construct the camera in
  31786. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31787. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31788. * @returns a factory method to construc the camera
  31789. */
  31790. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31791. /**
  31792. * Compute the world matrix of the camera.
  31793. * @returns the camera workd matrix
  31794. */
  31795. computeWorldMatrix(): Matrix;
  31796. /**
  31797. * Parse a JSON and creates the camera from the parsed information
  31798. * @param parsedCamera The JSON to parse
  31799. * @param scene The scene to instantiate the camera in
  31800. * @returns the newly constructed camera
  31801. */
  31802. static Parse(parsedCamera: any, scene: Scene): Camera;
  31803. }
  31804. }
  31805. declare module "babylonjs/Misc/tools" {
  31806. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31807. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31808. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31809. import { Observable } from "babylonjs/Misc/observable";
  31810. import { DomManagement } from "babylonjs/Misc/domManagement";
  31811. import { WebRequest } from "babylonjs/Misc/webRequest";
  31812. import { Camera } from "babylonjs/Cameras/camera";
  31813. import { Engine } from "babylonjs/Engines/engine";
  31814. import { Animation } from "babylonjs/Animations/animation";
  31815. /**
  31816. * Interface for any object that can request an animation frame
  31817. */
  31818. export interface ICustomAnimationFrameRequester {
  31819. /**
  31820. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31821. */
  31822. renderFunction?: Function;
  31823. /**
  31824. * Called to request the next frame to render to
  31825. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31826. */
  31827. requestAnimationFrame: Function;
  31828. /**
  31829. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31830. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31831. */
  31832. requestID?: number;
  31833. }
  31834. /**
  31835. * Interface containing an array of animations
  31836. */
  31837. export interface IAnimatable {
  31838. /**
  31839. * Array of animations
  31840. */
  31841. animations: Nullable<Array<Animation>>;
  31842. }
  31843. /** Interface used by value gradients (color, factor, ...) */
  31844. export interface IValueGradient {
  31845. /**
  31846. * Gets or sets the gradient value (between 0 and 1)
  31847. */
  31848. gradient: number;
  31849. }
  31850. /** Class used to store color4 gradient */
  31851. export class ColorGradient implements IValueGradient {
  31852. /**
  31853. * Gets or sets the gradient value (between 0 and 1)
  31854. */
  31855. gradient: number;
  31856. /**
  31857. * Gets or sets first associated color
  31858. */
  31859. color1: Color4;
  31860. /**
  31861. * Gets or sets second associated color
  31862. */
  31863. color2?: Color4;
  31864. /**
  31865. * Will get a color picked randomly between color1 and color2.
  31866. * If color2 is undefined then color1 will be used
  31867. * @param result defines the target Color4 to store the result in
  31868. */
  31869. getColorToRef(result: Color4): void;
  31870. }
  31871. /** Class used to store color 3 gradient */
  31872. export class Color3Gradient implements IValueGradient {
  31873. /**
  31874. * Gets or sets the gradient value (between 0 and 1)
  31875. */
  31876. gradient: number;
  31877. /**
  31878. * Gets or sets the associated color
  31879. */
  31880. color: Color3;
  31881. }
  31882. /** Class used to store factor gradient */
  31883. export class FactorGradient implements IValueGradient {
  31884. /**
  31885. * Gets or sets the gradient value (between 0 and 1)
  31886. */
  31887. gradient: number;
  31888. /**
  31889. * Gets or sets first associated factor
  31890. */
  31891. factor1: number;
  31892. /**
  31893. * Gets or sets second associated factor
  31894. */
  31895. factor2?: number;
  31896. /**
  31897. * Will get a number picked randomly between factor1 and factor2.
  31898. * If factor2 is undefined then factor1 will be used
  31899. * @returns the picked number
  31900. */
  31901. getFactor(): number;
  31902. }
  31903. /**
  31904. * @ignore
  31905. * Application error to support additional information when loading a file
  31906. */
  31907. export class LoadFileError extends Error {
  31908. /** defines the optional web request */
  31909. request?: WebRequest | undefined;
  31910. private static _setPrototypeOf;
  31911. /**
  31912. * Creates a new LoadFileError
  31913. * @param message defines the message of the error
  31914. * @param request defines the optional web request
  31915. */
  31916. constructor(message: string,
  31917. /** defines the optional web request */
  31918. request?: WebRequest | undefined);
  31919. }
  31920. /**
  31921. * Class used to define a retry strategy when error happens while loading assets
  31922. */
  31923. export class RetryStrategy {
  31924. /**
  31925. * Function used to defines an exponential back off strategy
  31926. * @param maxRetries defines the maximum number of retries (3 by default)
  31927. * @param baseInterval defines the interval between retries
  31928. * @returns the strategy function to use
  31929. */
  31930. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31931. }
  31932. /**
  31933. * File request interface
  31934. */
  31935. export interface IFileRequest {
  31936. /**
  31937. * Raised when the request is complete (success or error).
  31938. */
  31939. onCompleteObservable: Observable<IFileRequest>;
  31940. /**
  31941. * Aborts the request for a file.
  31942. */
  31943. abort: () => void;
  31944. }
  31945. /**
  31946. * Class containing a set of static utilities functions
  31947. */
  31948. export class Tools {
  31949. /**
  31950. * Gets or sets the base URL to use to load assets
  31951. */
  31952. static BaseUrl: string;
  31953. /**
  31954. * Enable/Disable Custom HTTP Request Headers globally.
  31955. * default = false
  31956. * @see CustomRequestHeaders
  31957. */
  31958. static UseCustomRequestHeaders: boolean;
  31959. /**
  31960. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31961. * i.e. when loading files, where the server/service expects an Authorization header
  31962. */
  31963. static CustomRequestHeaders: {
  31964. [key: string]: string;
  31965. };
  31966. /**
  31967. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31968. */
  31969. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31970. /**
  31971. * Default behaviour for cors in the application.
  31972. * It can be a string if the expected behavior is identical in the entire app.
  31973. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31974. */
  31975. static CorsBehavior: string | ((url: string | string[]) => string);
  31976. /**
  31977. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31978. * @ignorenaming
  31979. */
  31980. static UseFallbackTexture: boolean;
  31981. /**
  31982. * Use this object to register external classes like custom textures or material
  31983. * to allow the laoders to instantiate them
  31984. */
  31985. static RegisteredExternalClasses: {
  31986. [key: string]: Object;
  31987. };
  31988. /**
  31989. * Texture content used if a texture cannot loaded
  31990. * @ignorenaming
  31991. */
  31992. static fallbackTexture: string;
  31993. /**
  31994. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31995. * @param u defines the coordinate on X axis
  31996. * @param v defines the coordinate on Y axis
  31997. * @param width defines the width of the source data
  31998. * @param height defines the height of the source data
  31999. * @param pixels defines the source byte array
  32000. * @param color defines the output color
  32001. */
  32002. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32003. /**
  32004. * Interpolates between a and b via alpha
  32005. * @param a The lower value (returned when alpha = 0)
  32006. * @param b The upper value (returned when alpha = 1)
  32007. * @param alpha The interpolation-factor
  32008. * @return The mixed value
  32009. */
  32010. static Mix(a: number, b: number, alpha: number): number;
  32011. /**
  32012. * Tries to instantiate a new object from a given class name
  32013. * @param className defines the class name to instantiate
  32014. * @returns the new object or null if the system was not able to do the instantiation
  32015. */
  32016. static Instantiate(className: string): any;
  32017. /**
  32018. * Provides a slice function that will work even on IE
  32019. * @param data defines the array to slice
  32020. * @param start defines the start of the data (optional)
  32021. * @param end defines the end of the data (optional)
  32022. * @returns the new sliced array
  32023. */
  32024. static Slice<T>(data: T, start?: number, end?: number): T;
  32025. /**
  32026. * Polyfill for setImmediate
  32027. * @param action defines the action to execute after the current execution block
  32028. */
  32029. static SetImmediate(action: () => void): void;
  32030. /**
  32031. * Function indicating if a number is an exponent of 2
  32032. * @param value defines the value to test
  32033. * @returns true if the value is an exponent of 2
  32034. */
  32035. static IsExponentOfTwo(value: number): boolean;
  32036. private static _tmpFloatArray;
  32037. /**
  32038. * Returns the nearest 32-bit single precision float representation of a Number
  32039. * @param value A Number. If the parameter is of a different type, it will get converted
  32040. * to a number or to NaN if it cannot be converted
  32041. * @returns number
  32042. */
  32043. static FloatRound(value: number): number;
  32044. /**
  32045. * Find the next highest power of two.
  32046. * @param x Number to start search from.
  32047. * @return Next highest power of two.
  32048. */
  32049. static CeilingPOT(x: number): number;
  32050. /**
  32051. * Find the next lowest power of two.
  32052. * @param x Number to start search from.
  32053. * @return Next lowest power of two.
  32054. */
  32055. static FloorPOT(x: number): number;
  32056. /**
  32057. * Find the nearest power of two.
  32058. * @param x Number to start search from.
  32059. * @return Next nearest power of two.
  32060. */
  32061. static NearestPOT(x: number): number;
  32062. /**
  32063. * Get the closest exponent of two
  32064. * @param value defines the value to approximate
  32065. * @param max defines the maximum value to return
  32066. * @param mode defines how to define the closest value
  32067. * @returns closest exponent of two of the given value
  32068. */
  32069. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32070. /**
  32071. * Extracts the filename from a path
  32072. * @param path defines the path to use
  32073. * @returns the filename
  32074. */
  32075. static GetFilename(path: string): string;
  32076. /**
  32077. * Extracts the "folder" part of a path (everything before the filename).
  32078. * @param uri The URI to extract the info from
  32079. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32080. * @returns The "folder" part of the path
  32081. */
  32082. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32083. /**
  32084. * Extracts text content from a DOM element hierarchy
  32085. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32086. */
  32087. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32088. /**
  32089. * Convert an angle in radians to degrees
  32090. * @param angle defines the angle to convert
  32091. * @returns the angle in degrees
  32092. */
  32093. static ToDegrees(angle: number): number;
  32094. /**
  32095. * Convert an angle in degrees to radians
  32096. * @param angle defines the angle to convert
  32097. * @returns the angle in radians
  32098. */
  32099. static ToRadians(angle: number): number;
  32100. /**
  32101. * Encode a buffer to a base64 string
  32102. * @param buffer defines the buffer to encode
  32103. * @returns the encoded string
  32104. */
  32105. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32106. /**
  32107. * Extracts minimum and maximum values from a list of indexed positions
  32108. * @param positions defines the positions to use
  32109. * @param indices defines the indices to the positions
  32110. * @param indexStart defines the start index
  32111. * @param indexCount defines the end index
  32112. * @param bias defines bias value to add to the result
  32113. * @return minimum and maximum values
  32114. */
  32115. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32116. minimum: Vector3;
  32117. maximum: Vector3;
  32118. };
  32119. /**
  32120. * Extracts minimum and maximum values from a list of positions
  32121. * @param positions defines the positions to use
  32122. * @param start defines the start index in the positions array
  32123. * @param count defines the number of positions to handle
  32124. * @param bias defines bias value to add to the result
  32125. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32126. * @return minimum and maximum values
  32127. */
  32128. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32129. minimum: Vector3;
  32130. maximum: Vector3;
  32131. };
  32132. /**
  32133. * Returns an array if obj is not an array
  32134. * @param obj defines the object to evaluate as an array
  32135. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32136. * @returns either obj directly if obj is an array or a new array containing obj
  32137. */
  32138. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32139. /**
  32140. * Gets the pointer prefix to use
  32141. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32142. */
  32143. static GetPointerPrefix(): string;
  32144. /**
  32145. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32146. * @param func - the function to be called
  32147. * @param requester - the object that will request the next frame. Falls back to window.
  32148. * @returns frame number
  32149. */
  32150. static QueueNewFrame(func: () => void, requester?: any): number;
  32151. /**
  32152. * Ask the browser to promote the current element to fullscreen rendering mode
  32153. * @param element defines the DOM element to promote
  32154. */
  32155. static RequestFullscreen(element: HTMLElement): void;
  32156. /**
  32157. * Asks the browser to exit fullscreen mode
  32158. */
  32159. static ExitFullscreen(): void;
  32160. /**
  32161. * Ask the browser to promote the current element to pointerlock mode
  32162. * @param element defines the DOM element to promote
  32163. */
  32164. static RequestPointerlock(element: HTMLElement): void;
  32165. /**
  32166. * Asks the browser to exit pointerlock mode
  32167. */
  32168. static ExitPointerlock(): void;
  32169. /**
  32170. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32171. * @param url define the url we are trying
  32172. * @param element define the dom element where to configure the cors policy
  32173. */
  32174. static SetCorsBehavior(url: string | string[], element: {
  32175. crossOrigin: string | null;
  32176. }): void;
  32177. /**
  32178. * Removes unwanted characters from an url
  32179. * @param url defines the url to clean
  32180. * @returns the cleaned url
  32181. */
  32182. static CleanUrl(url: string): string;
  32183. /**
  32184. * Gets or sets a function used to pre-process url before using them to load assets
  32185. */
  32186. static PreprocessUrl: (url: string) => string;
  32187. /**
  32188. * Loads an image as an HTMLImageElement.
  32189. * @param input url string, ArrayBuffer, or Blob to load
  32190. * @param onLoad callback called when the image successfully loads
  32191. * @param onError callback called when the image fails to load
  32192. * @param offlineProvider offline provider for caching
  32193. * @returns the HTMLImageElement of the loaded image
  32194. */
  32195. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32196. /**
  32197. * Loads a file
  32198. * @param url url string, ArrayBuffer, or Blob to load
  32199. * @param onSuccess callback called when the file successfully loads
  32200. * @param onProgress callback called while file is loading (if the server supports this mode)
  32201. * @param offlineProvider defines the offline provider for caching
  32202. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32203. * @param onError callback called when the file fails to load
  32204. * @returns a file request object
  32205. */
  32206. 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;
  32207. /**
  32208. * Loads a file from a url
  32209. * @param url the file url to load
  32210. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32211. */
  32212. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32213. /**
  32214. * Load a script (identified by an url). When the url returns, the
  32215. * content of this file is added into a new script element, attached to the DOM (body element)
  32216. * @param scriptUrl defines the url of the script to laod
  32217. * @param onSuccess defines the callback called when the script is loaded
  32218. * @param onError defines the callback to call if an error occurs
  32219. * @param scriptId defines the id of the script element
  32220. */
  32221. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32222. /**
  32223. * Load an asynchronous script (identified by an url). When the url returns, the
  32224. * content of this file is added into a new script element, attached to the DOM (body element)
  32225. * @param scriptUrl defines the url of the script to laod
  32226. * @param scriptId defines the id of the script element
  32227. * @returns a promise request object
  32228. */
  32229. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32230. /**
  32231. * Loads a file from a blob
  32232. * @param fileToLoad defines the blob to use
  32233. * @param callback defines the callback to call when data is loaded
  32234. * @param progressCallback defines the callback to call during loading process
  32235. * @returns a file request object
  32236. */
  32237. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32238. /**
  32239. * Loads a file
  32240. * @param fileToLoad defines the file to load
  32241. * @param callback defines the callback to call when data is loaded
  32242. * @param progressCallBack defines the callback to call during loading process
  32243. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32244. * @returns a file request object
  32245. */
  32246. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32247. /**
  32248. * Creates a data url from a given string content
  32249. * @param content defines the content to convert
  32250. * @returns the new data url link
  32251. */
  32252. static FileAsURL(content: string): string;
  32253. /**
  32254. * Format the given number to a specific decimal format
  32255. * @param value defines the number to format
  32256. * @param decimals defines the number of decimals to use
  32257. * @returns the formatted string
  32258. */
  32259. static Format(value: number, decimals?: number): string;
  32260. /**
  32261. * Checks if a given vector is inside a specific range
  32262. * @param v defines the vector to test
  32263. * @param min defines the minimum range
  32264. * @param max defines the maximum range
  32265. */
  32266. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32267. /**
  32268. * Tries to copy an object by duplicating every property
  32269. * @param source defines the source object
  32270. * @param destination defines the target object
  32271. * @param doNotCopyList defines a list of properties to avoid
  32272. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32273. */
  32274. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32275. /**
  32276. * Gets a boolean indicating if the given object has no own property
  32277. * @param obj defines the object to test
  32278. * @returns true if object has no own property
  32279. */
  32280. static IsEmpty(obj: any): boolean;
  32281. /**
  32282. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32283. * @param str Source string
  32284. * @param suffix Suffix to search for in the source string
  32285. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32286. */
  32287. static EndsWith(str: string, suffix: string): boolean;
  32288. /**
  32289. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32290. * @param str Source string
  32291. * @param suffix Suffix to search for in the source string
  32292. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32293. */
  32294. static StartsWith(str: string, suffix: string): boolean;
  32295. /**
  32296. * Function used to register events at window level
  32297. * @param events defines the events to register
  32298. */
  32299. static RegisterTopRootEvents(events: {
  32300. name: string;
  32301. handler: Nullable<(e: FocusEvent) => any>;
  32302. }[]): void;
  32303. /**
  32304. * Function used to unregister events from window level
  32305. * @param events defines the events to unregister
  32306. */
  32307. static UnregisterTopRootEvents(events: {
  32308. name: string;
  32309. handler: Nullable<(e: FocusEvent) => any>;
  32310. }[]): void;
  32311. /**
  32312. * @ignore
  32313. */
  32314. static _ScreenshotCanvas: HTMLCanvasElement;
  32315. /**
  32316. * Dumps the current bound framebuffer
  32317. * @param width defines the rendering width
  32318. * @param height defines the rendering height
  32319. * @param engine defines the hosting engine
  32320. * @param successCallback defines the callback triggered once the data are available
  32321. * @param mimeType defines the mime type of the result
  32322. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32323. */
  32324. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32325. /**
  32326. * Converts the canvas data to blob.
  32327. * This acts as a polyfill for browsers not supporting the to blob function.
  32328. * @param canvas Defines the canvas to extract the data from
  32329. * @param successCallback Defines the callback triggered once the data are available
  32330. * @param mimeType Defines the mime type of the result
  32331. */
  32332. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32333. /**
  32334. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32335. * @param successCallback defines the callback triggered once the data are available
  32336. * @param mimeType defines the mime type of the result
  32337. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32338. */
  32339. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32340. /**
  32341. * Downloads a blob in the browser
  32342. * @param blob defines the blob to download
  32343. * @param fileName defines the name of the downloaded file
  32344. */
  32345. static Download(blob: Blob, fileName: string): void;
  32346. /**
  32347. * Captures a screenshot of the current rendering
  32348. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32349. * @param engine defines the rendering engine
  32350. * @param camera defines the source camera
  32351. * @param size This parameter can be set to a single number or to an object with the
  32352. * following (optional) properties: precision, width, height. If a single number is passed,
  32353. * it will be used for both width and height. If an object is passed, the screenshot size
  32354. * will be derived from the parameters. The precision property is a multiplier allowing
  32355. * rendering at a higher or lower resolution
  32356. * @param successCallback defines the callback receives a single parameter which contains the
  32357. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32358. * src parameter of an <img> to display it
  32359. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32360. * Check your browser for supported MIME types
  32361. */
  32362. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32363. /**
  32364. * Generates an image screenshot from the specified camera.
  32365. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32366. * @param engine The engine to use for rendering
  32367. * @param camera The camera to use for rendering
  32368. * @param size This parameter can be set to a single number or to an object with the
  32369. * following (optional) properties: precision, width, height. If a single number is passed,
  32370. * it will be used for both width and height. If an object is passed, the screenshot size
  32371. * will be derived from the parameters. The precision property is a multiplier allowing
  32372. * rendering at a higher or lower resolution
  32373. * @param successCallback The callback receives a single parameter which contains the
  32374. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32375. * src parameter of an <img> to display it
  32376. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32377. * Check your browser for supported MIME types
  32378. * @param samples Texture samples (default: 1)
  32379. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32380. * @param fileName A name for for the downloaded file.
  32381. */
  32382. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32383. /**
  32384. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32385. * Be aware Math.random() could cause collisions, but:
  32386. * "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"
  32387. * @returns a pseudo random id
  32388. */
  32389. static RandomId(): string;
  32390. /**
  32391. * Test if the given uri is a base64 string
  32392. * @param uri The uri to test
  32393. * @return True if the uri is a base64 string or false otherwise
  32394. */
  32395. static IsBase64(uri: string): boolean;
  32396. /**
  32397. * Decode the given base64 uri.
  32398. * @param uri The uri to decode
  32399. * @return The decoded base64 data.
  32400. */
  32401. static DecodeBase64(uri: string): ArrayBuffer;
  32402. /**
  32403. * Gets the absolute url.
  32404. * @param url the input url
  32405. * @return the absolute url
  32406. */
  32407. static GetAbsoluteUrl(url: string): string;
  32408. /**
  32409. * No log
  32410. */
  32411. static readonly NoneLogLevel: number;
  32412. /**
  32413. * Only message logs
  32414. */
  32415. static readonly MessageLogLevel: number;
  32416. /**
  32417. * Only warning logs
  32418. */
  32419. static readonly WarningLogLevel: number;
  32420. /**
  32421. * Only error logs
  32422. */
  32423. static readonly ErrorLogLevel: number;
  32424. /**
  32425. * All logs
  32426. */
  32427. static readonly AllLogLevel: number;
  32428. /**
  32429. * Gets a value indicating the number of loading errors
  32430. * @ignorenaming
  32431. */
  32432. static readonly errorsCount: number;
  32433. /**
  32434. * Callback called when a new log is added
  32435. */
  32436. static OnNewCacheEntry: (entry: string) => void;
  32437. /**
  32438. * Log a message to the console
  32439. * @param message defines the message to log
  32440. */
  32441. static Log(message: string): void;
  32442. /**
  32443. * Write a warning message to the console
  32444. * @param message defines the message to log
  32445. */
  32446. static Warn(message: string): void;
  32447. /**
  32448. * Write an error message to the console
  32449. * @param message defines the message to log
  32450. */
  32451. static Error(message: string): void;
  32452. /**
  32453. * Gets current log cache (list of logs)
  32454. */
  32455. static readonly LogCache: string;
  32456. /**
  32457. * Clears the log cache
  32458. */
  32459. static ClearLogCache(): void;
  32460. /**
  32461. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32462. */
  32463. static LogLevels: number;
  32464. /**
  32465. * Checks if the loaded document was accessed via `file:`-Protocol.
  32466. * @returns boolean
  32467. */
  32468. static IsFileURL(): boolean;
  32469. /**
  32470. * Checks if the window object exists
  32471. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32472. */
  32473. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32474. /**
  32475. * No performance log
  32476. */
  32477. static readonly PerformanceNoneLogLevel: number;
  32478. /**
  32479. * Use user marks to log performance
  32480. */
  32481. static readonly PerformanceUserMarkLogLevel: number;
  32482. /**
  32483. * Log performance to the console
  32484. */
  32485. static readonly PerformanceConsoleLogLevel: number;
  32486. private static _performance;
  32487. /**
  32488. * Sets the current performance log level
  32489. */
  32490. static PerformanceLogLevel: number;
  32491. private static _StartPerformanceCounterDisabled;
  32492. private static _EndPerformanceCounterDisabled;
  32493. private static _StartUserMark;
  32494. private static _EndUserMark;
  32495. private static _StartPerformanceConsole;
  32496. private static _EndPerformanceConsole;
  32497. /**
  32498. * Starts a performance counter
  32499. */
  32500. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32501. /**
  32502. * Ends a specific performance coutner
  32503. */
  32504. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32505. /**
  32506. * Gets either window.performance.now() if supported or Date.now() else
  32507. */
  32508. static readonly Now: number;
  32509. /**
  32510. * This method will return the name of the class used to create the instance of the given object.
  32511. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32512. * @param object the object to get the class name from
  32513. * @param isType defines if the object is actually a type
  32514. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32515. */
  32516. static GetClassName(object: any, isType?: boolean): string;
  32517. /**
  32518. * Gets the first element of an array satisfying a given predicate
  32519. * @param array defines the array to browse
  32520. * @param predicate defines the predicate to use
  32521. * @returns null if not found or the element
  32522. */
  32523. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32524. /**
  32525. * This method will return the name of the full name of the class, including its owning module (if any).
  32526. * 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).
  32527. * @param object the object to get the class name from
  32528. * @param isType defines if the object is actually a type
  32529. * @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.
  32530. * @ignorenaming
  32531. */
  32532. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32533. /**
  32534. * Returns a promise that resolves after the given amount of time.
  32535. * @param delay Number of milliseconds to delay
  32536. * @returns Promise that resolves after the given amount of time
  32537. */
  32538. static DelayAsync(delay: number): Promise<void>;
  32539. /**
  32540. * Gets the current gradient from an array of IValueGradient
  32541. * @param ratio defines the current ratio to get
  32542. * @param gradients defines the array of IValueGradient
  32543. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32544. */
  32545. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32546. }
  32547. /**
  32548. * This class is used to track a performance counter which is number based.
  32549. * The user has access to many properties which give statistics of different nature.
  32550. *
  32551. * The implementer can track two kinds of Performance Counter: time and count.
  32552. * 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.
  32553. * 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.
  32554. */
  32555. export class PerfCounter {
  32556. /**
  32557. * Gets or sets a global boolean to turn on and off all the counters
  32558. */
  32559. static Enabled: boolean;
  32560. /**
  32561. * Returns the smallest value ever
  32562. */
  32563. readonly min: number;
  32564. /**
  32565. * Returns the biggest value ever
  32566. */
  32567. readonly max: number;
  32568. /**
  32569. * Returns the average value since the performance counter is running
  32570. */
  32571. readonly average: number;
  32572. /**
  32573. * Returns the average value of the last second the counter was monitored
  32574. */
  32575. readonly lastSecAverage: number;
  32576. /**
  32577. * Returns the current value
  32578. */
  32579. readonly current: number;
  32580. /**
  32581. * Gets the accumulated total
  32582. */
  32583. readonly total: number;
  32584. /**
  32585. * Gets the total value count
  32586. */
  32587. readonly count: number;
  32588. /**
  32589. * Creates a new counter
  32590. */
  32591. constructor();
  32592. /**
  32593. * Call this method to start monitoring a new frame.
  32594. * 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.
  32595. */
  32596. fetchNewFrame(): void;
  32597. /**
  32598. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32599. * @param newCount the count value to add to the monitored count
  32600. * @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.
  32601. */
  32602. addCount(newCount: number, fetchResult: boolean): void;
  32603. /**
  32604. * Start monitoring this performance counter
  32605. */
  32606. beginMonitoring(): void;
  32607. /**
  32608. * Compute the time lapsed since the previous beginMonitoring() call.
  32609. * @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
  32610. */
  32611. endMonitoring(newFrame?: boolean): void;
  32612. private _fetchResult;
  32613. private _startMonitoringTime;
  32614. private _min;
  32615. private _max;
  32616. private _average;
  32617. private _current;
  32618. private _totalValueCount;
  32619. private _totalAccumulated;
  32620. private _lastSecAverage;
  32621. private _lastSecAccumulated;
  32622. private _lastSecTime;
  32623. private _lastSecValueCount;
  32624. }
  32625. /**
  32626. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32627. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32628. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32629. * @param name The name of the class, case should be preserved
  32630. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32631. */
  32632. export function className(name: string, module?: string): (target: Object) => void;
  32633. /**
  32634. * An implementation of a loop for asynchronous functions.
  32635. */
  32636. export class AsyncLoop {
  32637. /**
  32638. * Defines the number of iterations for the loop
  32639. */
  32640. iterations: number;
  32641. /**
  32642. * Defines the current index of the loop.
  32643. */
  32644. index: number;
  32645. private _done;
  32646. private _fn;
  32647. private _successCallback;
  32648. /**
  32649. * Constructor.
  32650. * @param iterations the number of iterations.
  32651. * @param func the function to run each iteration
  32652. * @param successCallback the callback that will be called upon succesful execution
  32653. * @param offset starting offset.
  32654. */
  32655. constructor(
  32656. /**
  32657. * Defines the number of iterations for the loop
  32658. */
  32659. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32660. /**
  32661. * Execute the next iteration. Must be called after the last iteration was finished.
  32662. */
  32663. executeNext(): void;
  32664. /**
  32665. * Break the loop and run the success callback.
  32666. */
  32667. breakLoop(): void;
  32668. /**
  32669. * Create and run an async loop.
  32670. * @param iterations the number of iterations.
  32671. * @param fn the function to run each iteration
  32672. * @param successCallback the callback that will be called upon succesful execution
  32673. * @param offset starting offset.
  32674. * @returns the created async loop object
  32675. */
  32676. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32677. /**
  32678. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32679. * @param iterations total number of iterations
  32680. * @param syncedIterations number of synchronous iterations in each async iteration.
  32681. * @param fn the function to call each iteration.
  32682. * @param callback a success call back that will be called when iterating stops.
  32683. * @param breakFunction a break condition (optional)
  32684. * @param timeout timeout settings for the setTimeout function. default - 0.
  32685. * @returns the created async loop object
  32686. */
  32687. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32688. }
  32689. }
  32690. declare module "babylonjs/Collisions/collisionCoordinator" {
  32691. import { Nullable } from "babylonjs/types";
  32692. import { Scene } from "babylonjs/scene";
  32693. import { Vector3 } from "babylonjs/Maths/math";
  32694. import { Collider } from "babylonjs/Collisions/collider";
  32695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32696. /** @hidden */
  32697. export interface ICollisionCoordinator {
  32698. createCollider(): Collider;
  32699. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32700. init(scene: Scene): void;
  32701. }
  32702. /** @hidden */
  32703. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32704. private _scene;
  32705. private _scaledPosition;
  32706. private _scaledVelocity;
  32707. private _finalPosition;
  32708. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32709. createCollider(): Collider;
  32710. init(scene: Scene): void;
  32711. private _collideWithWorld;
  32712. }
  32713. }
  32714. declare module "babylonjs/Inputs/scene.inputManager" {
  32715. import { Nullable } from "babylonjs/types";
  32716. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32717. import { Vector2 } from "babylonjs/Maths/math";
  32718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32719. import { Scene } from "babylonjs/scene";
  32720. /**
  32721. * Class used to manage all inputs for the scene.
  32722. */
  32723. export class InputManager {
  32724. /** The distance in pixel that you have to move to prevent some events */
  32725. static DragMovementThreshold: number;
  32726. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32727. static LongPressDelay: number;
  32728. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32729. static DoubleClickDelay: number;
  32730. /** If you need to check double click without raising a single click at first click, enable this flag */
  32731. static ExclusiveDoubleClickMode: boolean;
  32732. private _wheelEventName;
  32733. private _onPointerMove;
  32734. private _onPointerDown;
  32735. private _onPointerUp;
  32736. private _initClickEvent;
  32737. private _initActionManager;
  32738. private _delayedSimpleClick;
  32739. private _delayedSimpleClickTimeout;
  32740. private _previousDelayedSimpleClickTimeout;
  32741. private _meshPickProceed;
  32742. private _previousButtonPressed;
  32743. private _currentPickResult;
  32744. private _previousPickResult;
  32745. private _totalPointersPressed;
  32746. private _doubleClickOccured;
  32747. private _pointerOverMesh;
  32748. private _pickedDownMesh;
  32749. private _pickedUpMesh;
  32750. private _pointerX;
  32751. private _pointerY;
  32752. private _unTranslatedPointerX;
  32753. private _unTranslatedPointerY;
  32754. private _startingPointerPosition;
  32755. private _previousStartingPointerPosition;
  32756. private _startingPointerTime;
  32757. private _previousStartingPointerTime;
  32758. private _pointerCaptures;
  32759. private _onKeyDown;
  32760. private _onKeyUp;
  32761. private _onCanvasFocusObserver;
  32762. private _onCanvasBlurObserver;
  32763. private _scene;
  32764. /**
  32765. * Creates a new InputManager
  32766. * @param scene defines the hosting scene
  32767. */
  32768. constructor(scene: Scene);
  32769. /**
  32770. * Gets the mesh that is currently under the pointer
  32771. */
  32772. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32773. /**
  32774. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32775. */
  32776. readonly unTranslatedPointer: Vector2;
  32777. /**
  32778. * Gets or sets the current on-screen X position of the pointer
  32779. */
  32780. pointerX: number;
  32781. /**
  32782. * Gets or sets the current on-screen Y position of the pointer
  32783. */
  32784. pointerY: number;
  32785. private _updatePointerPosition;
  32786. private _processPointerMove;
  32787. private _setRayOnPointerInfo;
  32788. private _checkPrePointerObservable;
  32789. /**
  32790. * Use this method to simulate a pointer move on a mesh
  32791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32794. */
  32795. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32796. /**
  32797. * Use this method to simulate a pointer down on a mesh
  32798. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32799. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32800. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32801. */
  32802. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32803. private _processPointerDown;
  32804. /** @hidden */
  32805. _isPointerSwiping(): boolean;
  32806. /**
  32807. * Use this method to simulate a pointer up on a mesh
  32808. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32809. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32810. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32811. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32812. */
  32813. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32814. private _processPointerUp;
  32815. /**
  32816. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32817. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32818. * @returns true if the pointer was captured
  32819. */
  32820. isPointerCaptured(pointerId?: number): boolean;
  32821. /**
  32822. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32823. * @param attachUp defines if you want to attach events to pointerup
  32824. * @param attachDown defines if you want to attach events to pointerdown
  32825. * @param attachMove defines if you want to attach events to pointermove
  32826. */
  32827. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32828. /**
  32829. * Detaches all event handlers
  32830. */
  32831. detachControl(): void;
  32832. /**
  32833. * Force the value of meshUnderPointer
  32834. * @param mesh defines the mesh to use
  32835. */
  32836. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32837. /**
  32838. * Gets the mesh under the pointer
  32839. * @returns a Mesh or null if no mesh is under the pointer
  32840. */
  32841. getPointerOverMesh(): Nullable<AbstractMesh>;
  32842. }
  32843. }
  32844. declare module "babylonjs/Animations/animationGroup" {
  32845. import { Animatable } from "babylonjs/Animations/animatable";
  32846. import { Animation } from "babylonjs/Animations/animation";
  32847. import { Scene, IDisposable } from "babylonjs/scene";
  32848. import { Observable } from "babylonjs/Misc/observable";
  32849. import { Nullable } from "babylonjs/types";
  32850. import "babylonjs/Animations/animatable";
  32851. /**
  32852. * This class defines the direct association between an animation and a target
  32853. */
  32854. export class TargetedAnimation {
  32855. /**
  32856. * Animation to perform
  32857. */
  32858. animation: Animation;
  32859. /**
  32860. * Target to animate
  32861. */
  32862. target: any;
  32863. /**
  32864. * Serialize the object
  32865. * @returns the JSON object representing the current entity
  32866. */
  32867. serialize(): any;
  32868. }
  32869. /**
  32870. * Use this class to create coordinated animations on multiple targets
  32871. */
  32872. export class AnimationGroup implements IDisposable {
  32873. /** The name of the animation group */
  32874. name: string;
  32875. private _scene;
  32876. private _targetedAnimations;
  32877. private _animatables;
  32878. private _from;
  32879. private _to;
  32880. private _isStarted;
  32881. private _isPaused;
  32882. private _speedRatio;
  32883. private _loopAnimation;
  32884. /**
  32885. * Gets or sets the unique id of the node
  32886. */
  32887. uniqueId: number;
  32888. /**
  32889. * This observable will notify when one animation have ended
  32890. */
  32891. onAnimationEndObservable: Observable<TargetedAnimation>;
  32892. /**
  32893. * Observer raised when one animation loops
  32894. */
  32895. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32896. /**
  32897. * This observable will notify when all animations have ended.
  32898. */
  32899. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32900. /**
  32901. * This observable will notify when all animations have paused.
  32902. */
  32903. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32904. /**
  32905. * This observable will notify when all animations are playing.
  32906. */
  32907. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32908. /**
  32909. * Gets the first frame
  32910. */
  32911. readonly from: number;
  32912. /**
  32913. * Gets the last frame
  32914. */
  32915. readonly to: number;
  32916. /**
  32917. * Define if the animations are started
  32918. */
  32919. readonly isStarted: boolean;
  32920. /**
  32921. * Gets a value indicating that the current group is playing
  32922. */
  32923. readonly isPlaying: boolean;
  32924. /**
  32925. * Gets or sets the speed ratio to use for all animations
  32926. */
  32927. /**
  32928. * Gets or sets the speed ratio to use for all animations
  32929. */
  32930. speedRatio: number;
  32931. /**
  32932. * Gets or sets if all animations should loop or not
  32933. */
  32934. loopAnimation: boolean;
  32935. /**
  32936. * Gets the targeted animations for this animation group
  32937. */
  32938. readonly targetedAnimations: Array<TargetedAnimation>;
  32939. /**
  32940. * returning the list of animatables controlled by this animation group.
  32941. */
  32942. readonly animatables: Array<Animatable>;
  32943. /**
  32944. * Instantiates a new Animation Group.
  32945. * This helps managing several animations at once.
  32946. * @see http://doc.babylonjs.com/how_to/group
  32947. * @param name Defines the name of the group
  32948. * @param scene Defines the scene the group belongs to
  32949. */
  32950. constructor(
  32951. /** The name of the animation group */
  32952. name: string, scene?: Nullable<Scene>);
  32953. /**
  32954. * Add an animation (with its target) in the group
  32955. * @param animation defines the animation we want to add
  32956. * @param target defines the target of the animation
  32957. * @returns the TargetedAnimation object
  32958. */
  32959. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32960. /**
  32961. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32962. * It can add constant keys at begin or end
  32963. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32964. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32965. * @returns the animation group
  32966. */
  32967. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32968. /**
  32969. * Start all animations on given targets
  32970. * @param loop defines if animations must loop
  32971. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32972. * @param from defines the from key (optional)
  32973. * @param to defines the to key (optional)
  32974. * @returns the current animation group
  32975. */
  32976. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32977. /**
  32978. * Pause all animations
  32979. * @returns the animation group
  32980. */
  32981. pause(): AnimationGroup;
  32982. /**
  32983. * Play all animations to initial state
  32984. * This function will start() the animations if they were not started or will restart() them if they were paused
  32985. * @param loop defines if animations must loop
  32986. * @returns the animation group
  32987. */
  32988. play(loop?: boolean): AnimationGroup;
  32989. /**
  32990. * Reset all animations to initial state
  32991. * @returns the animation group
  32992. */
  32993. reset(): AnimationGroup;
  32994. /**
  32995. * Restart animations from key 0
  32996. * @returns the animation group
  32997. */
  32998. restart(): AnimationGroup;
  32999. /**
  33000. * Stop all animations
  33001. * @returns the animation group
  33002. */
  33003. stop(): AnimationGroup;
  33004. /**
  33005. * Set animation weight for all animatables
  33006. * @param weight defines the weight to use
  33007. * @return the animationGroup
  33008. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33009. */
  33010. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33011. /**
  33012. * Synchronize and normalize all animatables with a source animatable
  33013. * @param root defines the root animatable to synchronize with
  33014. * @return the animationGroup
  33015. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33016. */
  33017. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33018. /**
  33019. * Goes to a specific frame in this animation group
  33020. * @param frame the frame number to go to
  33021. * @return the animationGroup
  33022. */
  33023. goToFrame(frame: number): AnimationGroup;
  33024. /**
  33025. * Dispose all associated resources
  33026. */
  33027. dispose(): void;
  33028. private _checkAnimationGroupEnded;
  33029. /**
  33030. * Clone the current animation group and returns a copy
  33031. * @param newName defines the name of the new group
  33032. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33033. * @returns the new aniamtion group
  33034. */
  33035. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33036. /**
  33037. * Serializes the animationGroup to an object
  33038. * @returns Serialized object
  33039. */
  33040. serialize(): any;
  33041. /**
  33042. * Returns a new AnimationGroup object parsed from the source provided.
  33043. * @param parsedAnimationGroup defines the source
  33044. * @param scene defines the scene that will receive the animationGroup
  33045. * @returns a new AnimationGroup
  33046. */
  33047. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33048. /**
  33049. * Returns the string "AnimationGroup"
  33050. * @returns "AnimationGroup"
  33051. */
  33052. getClassName(): string;
  33053. /**
  33054. * Creates a detailled string about the object
  33055. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33056. * @returns a string representing the object
  33057. */
  33058. toString(fullDetails?: boolean): string;
  33059. }
  33060. }
  33061. declare module "babylonjs/scene" {
  33062. import { Nullable } from "babylonjs/types";
  33063. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33064. import { Observable } from "babylonjs/Misc/observable";
  33065. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33066. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33067. import { Geometry } from "babylonjs/Meshes/geometry";
  33068. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33071. import { Mesh } from "babylonjs/Meshes/mesh";
  33072. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33073. import { Bone } from "babylonjs/Bones/bone";
  33074. import { Skeleton } from "babylonjs/Bones/skeleton";
  33075. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33076. import { Camera } from "babylonjs/Cameras/camera";
  33077. import { AbstractScene } from "babylonjs/abstractScene";
  33078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33080. import { Material } from "babylonjs/Materials/material";
  33081. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33082. import { Effect } from "babylonjs/Materials/effect";
  33083. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33084. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33085. import { Light } from "babylonjs/Lights/light";
  33086. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33087. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33088. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33089. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33090. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33091. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33092. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33093. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33094. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33095. import { Engine } from "babylonjs/Engines/engine";
  33096. import { Node } from "babylonjs/node";
  33097. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33098. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33099. import { WebRequest } from "babylonjs/Misc/webRequest";
  33100. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33101. import { Ray } from "babylonjs/Culling/ray";
  33102. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33103. import { Animation } from "babylonjs/Animations/animation";
  33104. import { Animatable } from "babylonjs/Animations/animatable";
  33105. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33106. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33107. import { Collider } from "babylonjs/Collisions/collider";
  33108. /**
  33109. * Define an interface for all classes that will hold resources
  33110. */
  33111. export interface IDisposable {
  33112. /**
  33113. * Releases all held resources
  33114. */
  33115. dispose(): void;
  33116. }
  33117. /** Interface defining initialization parameters for Scene class */
  33118. export interface SceneOptions {
  33119. /**
  33120. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33121. * It will improve performance when the number of geometries becomes important.
  33122. */
  33123. useGeometryUniqueIdsMap?: boolean;
  33124. /**
  33125. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33126. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33127. */
  33128. useMaterialMeshMap?: boolean;
  33129. /**
  33130. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33131. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33132. */
  33133. useClonedMeshhMap?: boolean;
  33134. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33135. virtual?: boolean;
  33136. }
  33137. /**
  33138. * Represents a scene to be rendered by the engine.
  33139. * @see http://doc.babylonjs.com/features/scene
  33140. */
  33141. export class Scene extends AbstractScene implements IAnimatable {
  33142. private static _uniqueIdCounter;
  33143. /** The fog is deactivated */
  33144. static readonly FOGMODE_NONE: number;
  33145. /** The fog density is following an exponential function */
  33146. static readonly FOGMODE_EXP: number;
  33147. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33148. static readonly FOGMODE_EXP2: number;
  33149. /** The fog density is following a linear function. */
  33150. static readonly FOGMODE_LINEAR: number;
  33151. /**
  33152. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33153. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33154. */
  33155. static MinDeltaTime: number;
  33156. /**
  33157. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33158. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33159. */
  33160. static MaxDeltaTime: number;
  33161. /**
  33162. * Factory used to create the default material.
  33163. * @param name The name of the material to create
  33164. * @param scene The scene to create the material for
  33165. * @returns The default material
  33166. */
  33167. static DefaultMaterialFactory(scene: Scene): Material;
  33168. /**
  33169. * Factory used to create the a collision coordinator.
  33170. * @returns The collision coordinator
  33171. */
  33172. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33173. /** @hidden */
  33174. _inputManager: InputManager;
  33175. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33176. cameraToUseForPointers: Nullable<Camera>;
  33177. /** @hidden */
  33178. readonly _isScene: boolean;
  33179. /**
  33180. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33181. */
  33182. autoClear: boolean;
  33183. /**
  33184. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33185. */
  33186. autoClearDepthAndStencil: boolean;
  33187. /**
  33188. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33189. */
  33190. clearColor: Color4;
  33191. /**
  33192. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33193. */
  33194. ambientColor: Color3;
  33195. /**
  33196. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33197. * It should only be one of the following (if not the default embedded one):
  33198. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33199. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33200. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33201. * The material properties need to be setup according to the type of texture in use.
  33202. */
  33203. environmentBRDFTexture: BaseTexture;
  33204. /** @hidden */
  33205. protected _environmentTexture: Nullable<BaseTexture>;
  33206. /**
  33207. * Texture used in all pbr material as the reflection texture.
  33208. * As in the majority of the scene they are the same (exception for multi room and so on),
  33209. * this is easier to reference from here than from all the materials.
  33210. */
  33211. /**
  33212. * Texture used in all pbr material as the reflection texture.
  33213. * As in the majority of the scene they are the same (exception for multi room and so on),
  33214. * this is easier to set here than in all the materials.
  33215. */
  33216. environmentTexture: Nullable<BaseTexture>;
  33217. /** @hidden */
  33218. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33219. /**
  33220. * Default image processing configuration used either in the rendering
  33221. * Forward main pass or through the imageProcessingPostProcess if present.
  33222. * As in the majority of the scene they are the same (exception for multi camera),
  33223. * this is easier to reference from here than from all the materials and post process.
  33224. *
  33225. * No setter as we it is a shared configuration, you can set the values instead.
  33226. */
  33227. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33228. private _forceWireframe;
  33229. /**
  33230. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33231. */
  33232. forceWireframe: boolean;
  33233. private _forcePointsCloud;
  33234. /**
  33235. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33236. */
  33237. forcePointsCloud: boolean;
  33238. /**
  33239. * Gets or sets the active clipplane 1
  33240. */
  33241. clipPlane: Nullable<Plane>;
  33242. /**
  33243. * Gets or sets the active clipplane 2
  33244. */
  33245. clipPlane2: Nullable<Plane>;
  33246. /**
  33247. * Gets or sets the active clipplane 3
  33248. */
  33249. clipPlane3: Nullable<Plane>;
  33250. /**
  33251. * Gets or sets the active clipplane 4
  33252. */
  33253. clipPlane4: Nullable<Plane>;
  33254. /**
  33255. * Gets or sets a boolean indicating if animations are enabled
  33256. */
  33257. animationsEnabled: boolean;
  33258. private _animationPropertiesOverride;
  33259. /**
  33260. * Gets or sets the animation properties override
  33261. */
  33262. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33263. /**
  33264. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33265. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33266. */
  33267. useConstantAnimationDeltaTime: boolean;
  33268. /**
  33269. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33270. * Please note that it requires to run a ray cast through the scene on every frame
  33271. */
  33272. constantlyUpdateMeshUnderPointer: boolean;
  33273. /**
  33274. * Defines the HTML cursor to use when hovering over interactive elements
  33275. */
  33276. hoverCursor: string;
  33277. /**
  33278. * Defines the HTML default cursor to use (empty by default)
  33279. */
  33280. defaultCursor: string;
  33281. /**
  33282. * This is used to call preventDefault() on pointer down
  33283. * in order to block unwanted artifacts like system double clicks
  33284. */
  33285. preventDefaultOnPointerDown: boolean;
  33286. /**
  33287. * This is used to call preventDefault() on pointer up
  33288. * in order to block unwanted artifacts like system double clicks
  33289. */
  33290. preventDefaultOnPointerUp: boolean;
  33291. /**
  33292. * Gets or sets user defined metadata
  33293. */
  33294. metadata: any;
  33295. /**
  33296. * For internal use only. Please do not use.
  33297. */
  33298. reservedDataStore: any;
  33299. /**
  33300. * Gets the name of the plugin used to load this scene (null by default)
  33301. */
  33302. loadingPluginName: string;
  33303. /**
  33304. * Use this array to add regular expressions used to disable offline support for specific urls
  33305. */
  33306. disableOfflineSupportExceptionRules: RegExp[];
  33307. /**
  33308. * An event triggered when the scene is disposed.
  33309. */
  33310. onDisposeObservable: Observable<Scene>;
  33311. private _onDisposeObserver;
  33312. /** Sets a function to be executed when this scene is disposed. */
  33313. onDispose: () => void;
  33314. /**
  33315. * An event triggered before rendering the scene (right after animations and physics)
  33316. */
  33317. onBeforeRenderObservable: Observable<Scene>;
  33318. private _onBeforeRenderObserver;
  33319. /** Sets a function to be executed before rendering this scene */
  33320. beforeRender: Nullable<() => void>;
  33321. /**
  33322. * An event triggered after rendering the scene
  33323. */
  33324. onAfterRenderObservable: Observable<Scene>;
  33325. /**
  33326. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33327. */
  33328. onAfterRenderCameraObservable: Observable<Camera>;
  33329. private _onAfterRenderObserver;
  33330. /** Sets a function to be executed after rendering this scene */
  33331. afterRender: Nullable<() => void>;
  33332. /**
  33333. * An event triggered before animating the scene
  33334. */
  33335. onBeforeAnimationsObservable: Observable<Scene>;
  33336. /**
  33337. * An event triggered after animations processing
  33338. */
  33339. onAfterAnimationsObservable: Observable<Scene>;
  33340. /**
  33341. * An event triggered before draw calls are ready to be sent
  33342. */
  33343. onBeforeDrawPhaseObservable: Observable<Scene>;
  33344. /**
  33345. * An event triggered after draw calls have been sent
  33346. */
  33347. onAfterDrawPhaseObservable: Observable<Scene>;
  33348. /**
  33349. * An event triggered when the scene is ready
  33350. */
  33351. onReadyObservable: Observable<Scene>;
  33352. /**
  33353. * An event triggered before rendering a camera
  33354. */
  33355. onBeforeCameraRenderObservable: Observable<Camera>;
  33356. private _onBeforeCameraRenderObserver;
  33357. /** Sets a function to be executed before rendering a camera*/
  33358. beforeCameraRender: () => void;
  33359. /**
  33360. * An event triggered after rendering a camera
  33361. */
  33362. onAfterCameraRenderObservable: Observable<Camera>;
  33363. private _onAfterCameraRenderObserver;
  33364. /** Sets a function to be executed after rendering a camera*/
  33365. afterCameraRender: () => void;
  33366. /**
  33367. * An event triggered when active meshes evaluation is about to start
  33368. */
  33369. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33370. /**
  33371. * An event triggered when active meshes evaluation is done
  33372. */
  33373. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33374. /**
  33375. * An event triggered when particles rendering is about to start
  33376. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33377. */
  33378. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33379. /**
  33380. * An event triggered when particles rendering is done
  33381. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33382. */
  33383. onAfterParticlesRenderingObservable: Observable<Scene>;
  33384. /**
  33385. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33386. */
  33387. onDataLoadedObservable: Observable<Scene>;
  33388. /**
  33389. * An event triggered when a camera is created
  33390. */
  33391. onNewCameraAddedObservable: Observable<Camera>;
  33392. /**
  33393. * An event triggered when a camera is removed
  33394. */
  33395. onCameraRemovedObservable: Observable<Camera>;
  33396. /**
  33397. * An event triggered when a light is created
  33398. */
  33399. onNewLightAddedObservable: Observable<Light>;
  33400. /**
  33401. * An event triggered when a light is removed
  33402. */
  33403. onLightRemovedObservable: Observable<Light>;
  33404. /**
  33405. * An event triggered when a geometry is created
  33406. */
  33407. onNewGeometryAddedObservable: Observable<Geometry>;
  33408. /**
  33409. * An event triggered when a geometry is removed
  33410. */
  33411. onGeometryRemovedObservable: Observable<Geometry>;
  33412. /**
  33413. * An event triggered when a transform node is created
  33414. */
  33415. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33416. /**
  33417. * An event triggered when a transform node is removed
  33418. */
  33419. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33420. /**
  33421. * An event triggered when a mesh is created
  33422. */
  33423. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33424. /**
  33425. * An event triggered when a mesh is removed
  33426. */
  33427. onMeshRemovedObservable: Observable<AbstractMesh>;
  33428. /**
  33429. * An event triggered when a skeleton is created
  33430. */
  33431. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33432. /**
  33433. * An event triggered when a skeleton is removed
  33434. */
  33435. onSkeletonRemovedObservable: Observable<Skeleton>;
  33436. /**
  33437. * An event triggered when a material is created
  33438. */
  33439. onNewMaterialAddedObservable: Observable<Material>;
  33440. /**
  33441. * An event triggered when a material is removed
  33442. */
  33443. onMaterialRemovedObservable: Observable<Material>;
  33444. /**
  33445. * An event triggered when a texture is created
  33446. */
  33447. onNewTextureAddedObservable: Observable<BaseTexture>;
  33448. /**
  33449. * An event triggered when a texture is removed
  33450. */
  33451. onTextureRemovedObservable: Observable<BaseTexture>;
  33452. /**
  33453. * An event triggered when render targets are about to be rendered
  33454. * Can happen multiple times per frame.
  33455. */
  33456. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33457. /**
  33458. * An event triggered when render targets were rendered.
  33459. * Can happen multiple times per frame.
  33460. */
  33461. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33462. /**
  33463. * An event triggered before calculating deterministic simulation step
  33464. */
  33465. onBeforeStepObservable: Observable<Scene>;
  33466. /**
  33467. * An event triggered after calculating deterministic simulation step
  33468. */
  33469. onAfterStepObservable: Observable<Scene>;
  33470. /**
  33471. * An event triggered when the activeCamera property is updated
  33472. */
  33473. onActiveCameraChanged: Observable<Scene>;
  33474. /**
  33475. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33476. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33477. * 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)
  33478. */
  33479. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33480. /**
  33481. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33482. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33483. * 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)
  33484. */
  33485. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33486. /**
  33487. * This Observable will when a mesh has been imported into the scene.
  33488. */
  33489. onMeshImportedObservable: Observable<AbstractMesh>;
  33490. /**
  33491. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33492. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33493. */
  33494. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33495. /** @hidden */
  33496. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33497. /**
  33498. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33499. */
  33500. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33501. /**
  33502. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33503. */
  33504. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33505. /**
  33506. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33507. */
  33508. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33509. /** Callback called when a pointer move is detected */
  33510. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33511. /** Callback called when a pointer down is detected */
  33512. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33513. /** Callback called when a pointer up is detected */
  33514. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33515. /** Callback called when a pointer pick is detected */
  33516. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33517. /**
  33518. * 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).
  33519. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33520. */
  33521. onPrePointerObservable: Observable<PointerInfoPre>;
  33522. /**
  33523. * Observable event triggered each time an input event is received from the rendering canvas
  33524. */
  33525. onPointerObservable: Observable<PointerInfo>;
  33526. /**
  33527. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33528. */
  33529. readonly unTranslatedPointer: Vector2;
  33530. /**
  33531. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33532. */
  33533. static DragMovementThreshold: number;
  33534. /**
  33535. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33536. */
  33537. static LongPressDelay: number;
  33538. /**
  33539. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33540. */
  33541. static DoubleClickDelay: number;
  33542. /** If you need to check double click without raising a single click at first click, enable this flag */
  33543. static ExclusiveDoubleClickMode: boolean;
  33544. /** @hidden */
  33545. _mirroredCameraPosition: Nullable<Vector3>;
  33546. /**
  33547. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33548. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33549. */
  33550. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33551. /**
  33552. * Observable event triggered each time an keyboard event is received from the hosting window
  33553. */
  33554. onKeyboardObservable: Observable<KeyboardInfo>;
  33555. private _useRightHandedSystem;
  33556. /**
  33557. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33558. */
  33559. useRightHandedSystem: boolean;
  33560. private _timeAccumulator;
  33561. private _currentStepId;
  33562. private _currentInternalStep;
  33563. /**
  33564. * Sets the step Id used by deterministic lock step
  33565. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33566. * @param newStepId defines the step Id
  33567. */
  33568. setStepId(newStepId: number): void;
  33569. /**
  33570. * Gets the step Id used by deterministic lock step
  33571. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33572. * @returns the step Id
  33573. */
  33574. getStepId(): number;
  33575. /**
  33576. * Gets the internal step used by deterministic lock step
  33577. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33578. * @returns the internal step
  33579. */
  33580. getInternalStep(): number;
  33581. private _fogEnabled;
  33582. /**
  33583. * Gets or sets a boolean indicating if fog is enabled on this scene
  33584. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33585. * (Default is true)
  33586. */
  33587. fogEnabled: boolean;
  33588. private _fogMode;
  33589. /**
  33590. * Gets or sets the fog mode to use
  33591. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33592. * | mode | value |
  33593. * | --- | --- |
  33594. * | FOGMODE_NONE | 0 |
  33595. * | FOGMODE_EXP | 1 |
  33596. * | FOGMODE_EXP2 | 2 |
  33597. * | FOGMODE_LINEAR | 3 |
  33598. */
  33599. fogMode: number;
  33600. /**
  33601. * Gets or sets the fog color to use
  33602. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33603. * (Default is Color3(0.2, 0.2, 0.3))
  33604. */
  33605. fogColor: Color3;
  33606. /**
  33607. * Gets or sets the fog density to use
  33608. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33609. * (Default is 0.1)
  33610. */
  33611. fogDensity: number;
  33612. /**
  33613. * Gets or sets the fog start distance to use
  33614. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33615. * (Default is 0)
  33616. */
  33617. fogStart: number;
  33618. /**
  33619. * Gets or sets the fog end distance to use
  33620. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33621. * (Default is 1000)
  33622. */
  33623. fogEnd: number;
  33624. private _shadowsEnabled;
  33625. /**
  33626. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33627. */
  33628. shadowsEnabled: boolean;
  33629. private _lightsEnabled;
  33630. /**
  33631. * Gets or sets a boolean indicating if lights are enabled on this scene
  33632. */
  33633. lightsEnabled: boolean;
  33634. /** All of the active cameras added to this scene. */
  33635. activeCameras: Camera[];
  33636. /** @hidden */
  33637. _activeCamera: Nullable<Camera>;
  33638. /** Gets or sets the current active camera */
  33639. activeCamera: Nullable<Camera>;
  33640. private _defaultMaterial;
  33641. /** The default material used on meshes when no material is affected */
  33642. /** The default material used on meshes when no material is affected */
  33643. defaultMaterial: Material;
  33644. private _texturesEnabled;
  33645. /**
  33646. * Gets or sets a boolean indicating if textures are enabled on this scene
  33647. */
  33648. texturesEnabled: boolean;
  33649. /**
  33650. * Gets or sets a boolean indicating if particles are enabled on this scene
  33651. */
  33652. particlesEnabled: boolean;
  33653. /**
  33654. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33655. */
  33656. spritesEnabled: boolean;
  33657. private _skeletonsEnabled;
  33658. /**
  33659. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33660. */
  33661. skeletonsEnabled: boolean;
  33662. /**
  33663. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33664. */
  33665. lensFlaresEnabled: boolean;
  33666. /**
  33667. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33668. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33669. */
  33670. collisionsEnabled: boolean;
  33671. private _collisionCoordinator;
  33672. /** @hidden */
  33673. readonly collisionCoordinator: ICollisionCoordinator;
  33674. /**
  33675. * Defines the gravity applied to this scene (used only for collisions)
  33676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33677. */
  33678. gravity: Vector3;
  33679. /**
  33680. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33681. */
  33682. postProcessesEnabled: boolean;
  33683. /**
  33684. * The list of postprocesses added to the scene
  33685. */
  33686. postProcesses: PostProcess[];
  33687. /**
  33688. * Gets the current postprocess manager
  33689. */
  33690. postProcessManager: PostProcessManager;
  33691. /**
  33692. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33693. */
  33694. renderTargetsEnabled: boolean;
  33695. /**
  33696. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33697. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33698. */
  33699. dumpNextRenderTargets: boolean;
  33700. /**
  33701. * The list of user defined render targets added to the scene
  33702. */
  33703. customRenderTargets: RenderTargetTexture[];
  33704. /**
  33705. * Defines if texture loading must be delayed
  33706. * If true, textures will only be loaded when they need to be rendered
  33707. */
  33708. useDelayedTextureLoading: boolean;
  33709. /**
  33710. * Gets the list of meshes imported to the scene through SceneLoader
  33711. */
  33712. importedMeshesFiles: String[];
  33713. /**
  33714. * Gets or sets a boolean indicating if probes are enabled on this scene
  33715. */
  33716. probesEnabled: boolean;
  33717. /**
  33718. * Gets or sets the current offline provider to use to store scene data
  33719. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33720. */
  33721. offlineProvider: IOfflineProvider;
  33722. /**
  33723. * Gets or sets the action manager associated with the scene
  33724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33725. */
  33726. actionManager: AbstractActionManager;
  33727. private _meshesForIntersections;
  33728. /**
  33729. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33730. */
  33731. proceduralTexturesEnabled: boolean;
  33732. private _engine;
  33733. private _totalVertices;
  33734. /** @hidden */
  33735. _activeIndices: PerfCounter;
  33736. /** @hidden */
  33737. _activeParticles: PerfCounter;
  33738. /** @hidden */
  33739. _activeBones: PerfCounter;
  33740. private _animationRatio;
  33741. /** @hidden */
  33742. _animationTimeLast: number;
  33743. /** @hidden */
  33744. _animationTime: number;
  33745. /**
  33746. * Gets or sets a general scale for animation speed
  33747. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33748. */
  33749. animationTimeScale: number;
  33750. /** @hidden */
  33751. _cachedMaterial: Nullable<Material>;
  33752. /** @hidden */
  33753. _cachedEffect: Nullable<Effect>;
  33754. /** @hidden */
  33755. _cachedVisibility: Nullable<number>;
  33756. private _renderId;
  33757. private _frameId;
  33758. private _executeWhenReadyTimeoutId;
  33759. private _intermediateRendering;
  33760. private _viewUpdateFlag;
  33761. private _projectionUpdateFlag;
  33762. /** @hidden */
  33763. _toBeDisposed: Nullable<IDisposable>[];
  33764. private _activeRequests;
  33765. /** @hidden */
  33766. _pendingData: any[];
  33767. private _isDisposed;
  33768. /**
  33769. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33770. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33771. */
  33772. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33773. private _activeMeshes;
  33774. private _processedMaterials;
  33775. private _renderTargets;
  33776. /** @hidden */
  33777. _activeParticleSystems: SmartArray<IParticleSystem>;
  33778. private _activeSkeletons;
  33779. private _softwareSkinnedMeshes;
  33780. private _renderingManager;
  33781. /** @hidden */
  33782. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33783. private _transformMatrix;
  33784. private _sceneUbo;
  33785. /** @hidden */
  33786. _viewMatrix: Matrix;
  33787. private _projectionMatrix;
  33788. /** @hidden */
  33789. _forcedViewPosition: Nullable<Vector3>;
  33790. /** @hidden */
  33791. _frustumPlanes: Plane[];
  33792. /**
  33793. * Gets the list of frustum planes (built from the active camera)
  33794. */
  33795. readonly frustumPlanes: Plane[];
  33796. /**
  33797. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33798. * This is useful if there are more lights that the maximum simulteanous authorized
  33799. */
  33800. requireLightSorting: boolean;
  33801. /** @hidden */
  33802. readonly useMaterialMeshMap: boolean;
  33803. /** @hidden */
  33804. readonly useClonedMeshhMap: boolean;
  33805. private _externalData;
  33806. private _uid;
  33807. /**
  33808. * @hidden
  33809. * Backing store of defined scene components.
  33810. */
  33811. _components: ISceneComponent[];
  33812. /**
  33813. * @hidden
  33814. * Backing store of defined scene components.
  33815. */
  33816. _serializableComponents: ISceneSerializableComponent[];
  33817. /**
  33818. * List of components to register on the next registration step.
  33819. */
  33820. private _transientComponents;
  33821. /**
  33822. * Registers the transient components if needed.
  33823. */
  33824. private _registerTransientComponents;
  33825. /**
  33826. * @hidden
  33827. * Add a component to the scene.
  33828. * Note that the ccomponent could be registered on th next frame if this is called after
  33829. * the register component stage.
  33830. * @param component Defines the component to add to the scene
  33831. */
  33832. _addComponent(component: ISceneComponent): void;
  33833. /**
  33834. * @hidden
  33835. * Gets a component from the scene.
  33836. * @param name defines the name of the component to retrieve
  33837. * @returns the component or null if not present
  33838. */
  33839. _getComponent(name: string): Nullable<ISceneComponent>;
  33840. /**
  33841. * @hidden
  33842. * Defines the actions happening before camera updates.
  33843. */
  33844. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33845. /**
  33846. * @hidden
  33847. * Defines the actions happening before clear the canvas.
  33848. */
  33849. _beforeClearStage: Stage<SimpleStageAction>;
  33850. /**
  33851. * @hidden
  33852. * Defines the actions when collecting render targets for the frame.
  33853. */
  33854. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33855. /**
  33856. * @hidden
  33857. * Defines the actions happening for one camera in the frame.
  33858. */
  33859. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33860. /**
  33861. * @hidden
  33862. * Defines the actions happening during the per mesh ready checks.
  33863. */
  33864. _isReadyForMeshStage: Stage<MeshStageAction>;
  33865. /**
  33866. * @hidden
  33867. * Defines the actions happening before evaluate active mesh checks.
  33868. */
  33869. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33870. /**
  33871. * @hidden
  33872. * Defines the actions happening during the evaluate sub mesh checks.
  33873. */
  33874. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33875. /**
  33876. * @hidden
  33877. * Defines the actions happening during the active mesh stage.
  33878. */
  33879. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33880. /**
  33881. * @hidden
  33882. * Defines the actions happening during the per camera render target step.
  33883. */
  33884. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33885. /**
  33886. * @hidden
  33887. * Defines the actions happening just before the active camera is drawing.
  33888. */
  33889. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33890. /**
  33891. * @hidden
  33892. * Defines the actions happening just before a render target is drawing.
  33893. */
  33894. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33895. /**
  33896. * @hidden
  33897. * Defines the actions happening just before a rendering group is drawing.
  33898. */
  33899. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33900. /**
  33901. * @hidden
  33902. * Defines the actions happening just before a mesh is drawing.
  33903. */
  33904. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33905. /**
  33906. * @hidden
  33907. * Defines the actions happening just after a mesh has been drawn.
  33908. */
  33909. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33910. /**
  33911. * @hidden
  33912. * Defines the actions happening just after a rendering group has been drawn.
  33913. */
  33914. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33915. /**
  33916. * @hidden
  33917. * Defines the actions happening just after the active camera has been drawn.
  33918. */
  33919. _afterCameraDrawStage: Stage<CameraStageAction>;
  33920. /**
  33921. * @hidden
  33922. * Defines the actions happening just after a render target has been drawn.
  33923. */
  33924. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33925. /**
  33926. * @hidden
  33927. * Defines the actions happening just after rendering all cameras and computing intersections.
  33928. */
  33929. _afterRenderStage: Stage<SimpleStageAction>;
  33930. /**
  33931. * @hidden
  33932. * Defines the actions happening when a pointer move event happens.
  33933. */
  33934. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33935. /**
  33936. * @hidden
  33937. * Defines the actions happening when a pointer down event happens.
  33938. */
  33939. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33940. /**
  33941. * @hidden
  33942. * Defines the actions happening when a pointer up event happens.
  33943. */
  33944. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33945. /**
  33946. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33947. */
  33948. private geometriesByUniqueId;
  33949. /**
  33950. * Creates a new Scene
  33951. * @param engine defines the engine to use to render this scene
  33952. * @param options defines the scene options
  33953. */
  33954. constructor(engine: Engine, options?: SceneOptions);
  33955. /**
  33956. * Gets a string idenfifying the name of the class
  33957. * @returns "Scene" string
  33958. */
  33959. getClassName(): string;
  33960. private _defaultMeshCandidates;
  33961. /**
  33962. * @hidden
  33963. */
  33964. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33965. private _defaultSubMeshCandidates;
  33966. /**
  33967. * @hidden
  33968. */
  33969. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33970. /**
  33971. * Sets the default candidate providers for the scene.
  33972. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33973. * and getCollidingSubMeshCandidates to their default function
  33974. */
  33975. setDefaultCandidateProviders(): void;
  33976. /**
  33977. * Gets the mesh that is currently under the pointer
  33978. */
  33979. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33980. /**
  33981. * Gets or sets the current on-screen X position of the pointer
  33982. */
  33983. pointerX: number;
  33984. /**
  33985. * Gets or sets the current on-screen Y position of the pointer
  33986. */
  33987. pointerY: number;
  33988. /**
  33989. * Gets the cached material (ie. the latest rendered one)
  33990. * @returns the cached material
  33991. */
  33992. getCachedMaterial(): Nullable<Material>;
  33993. /**
  33994. * Gets the cached effect (ie. the latest rendered one)
  33995. * @returns the cached effect
  33996. */
  33997. getCachedEffect(): Nullable<Effect>;
  33998. /**
  33999. * Gets the cached visibility state (ie. the latest rendered one)
  34000. * @returns the cached visibility state
  34001. */
  34002. getCachedVisibility(): Nullable<number>;
  34003. /**
  34004. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34005. * @param material defines the current material
  34006. * @param effect defines the current effect
  34007. * @param visibility defines the current visibility state
  34008. * @returns true if one parameter is not cached
  34009. */
  34010. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34011. /**
  34012. * Gets the engine associated with the scene
  34013. * @returns an Engine
  34014. */
  34015. getEngine(): Engine;
  34016. /**
  34017. * Gets the total number of vertices rendered per frame
  34018. * @returns the total number of vertices rendered per frame
  34019. */
  34020. getTotalVertices(): number;
  34021. /**
  34022. * Gets the performance counter for total vertices
  34023. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34024. */
  34025. readonly totalVerticesPerfCounter: PerfCounter;
  34026. /**
  34027. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34028. * @returns the total number of active indices rendered per frame
  34029. */
  34030. getActiveIndices(): number;
  34031. /**
  34032. * Gets the performance counter for active indices
  34033. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34034. */
  34035. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34036. /**
  34037. * Gets the total number of active particles rendered per frame
  34038. * @returns the total number of active particles rendered per frame
  34039. */
  34040. getActiveParticles(): number;
  34041. /**
  34042. * Gets the performance counter for active particles
  34043. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34044. */
  34045. readonly activeParticlesPerfCounter: PerfCounter;
  34046. /**
  34047. * Gets the total number of active bones rendered per frame
  34048. * @returns the total number of active bones rendered per frame
  34049. */
  34050. getActiveBones(): number;
  34051. /**
  34052. * Gets the performance counter for active bones
  34053. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34054. */
  34055. readonly activeBonesPerfCounter: PerfCounter;
  34056. /**
  34057. * Gets the array of active meshes
  34058. * @returns an array of AbstractMesh
  34059. */
  34060. getActiveMeshes(): SmartArray<AbstractMesh>;
  34061. /**
  34062. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34063. * @returns a number
  34064. */
  34065. getAnimationRatio(): number;
  34066. /**
  34067. * Gets an unique Id for the current render phase
  34068. * @returns a number
  34069. */
  34070. getRenderId(): number;
  34071. /**
  34072. * Gets an unique Id for the current frame
  34073. * @returns a number
  34074. */
  34075. getFrameId(): number;
  34076. /** Call this function if you want to manually increment the render Id*/
  34077. incrementRenderId(): void;
  34078. private _createUbo;
  34079. /**
  34080. * Use this method to simulate a pointer move on a mesh
  34081. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34082. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34083. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34084. * @returns the current scene
  34085. */
  34086. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34087. /**
  34088. * Use this method to simulate a pointer down on a mesh
  34089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34092. * @returns the current scene
  34093. */
  34094. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34095. /**
  34096. * Use this method to simulate a pointer up on a mesh
  34097. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34098. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34099. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34100. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34101. * @returns the current scene
  34102. */
  34103. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34104. /**
  34105. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34106. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34107. * @returns true if the pointer was captured
  34108. */
  34109. isPointerCaptured(pointerId?: number): boolean;
  34110. /**
  34111. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34112. * @param attachUp defines if you want to attach events to pointerup
  34113. * @param attachDown defines if you want to attach events to pointerdown
  34114. * @param attachMove defines if you want to attach events to pointermove
  34115. */
  34116. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34117. /** Detaches all event handlers*/
  34118. detachControl(): void;
  34119. /**
  34120. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34121. * Delay loaded resources are not taking in account
  34122. * @return true if all required resources are ready
  34123. */
  34124. isReady(): boolean;
  34125. /** Resets all cached information relative to material (including effect and visibility) */
  34126. resetCachedMaterial(): void;
  34127. /**
  34128. * Registers a function to be called before every frame render
  34129. * @param func defines the function to register
  34130. */
  34131. registerBeforeRender(func: () => void): void;
  34132. /**
  34133. * Unregisters a function called before every frame render
  34134. * @param func defines the function to unregister
  34135. */
  34136. unregisterBeforeRender(func: () => void): void;
  34137. /**
  34138. * Registers a function to be called after every frame render
  34139. * @param func defines the function to register
  34140. */
  34141. registerAfterRender(func: () => void): void;
  34142. /**
  34143. * Unregisters a function called after every frame render
  34144. * @param func defines the function to unregister
  34145. */
  34146. unregisterAfterRender(func: () => void): void;
  34147. private _executeOnceBeforeRender;
  34148. /**
  34149. * The provided function will run before render once and will be disposed afterwards.
  34150. * A timeout delay can be provided so that the function will be executed in N ms.
  34151. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34152. * @param func The function to be executed.
  34153. * @param timeout optional delay in ms
  34154. */
  34155. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34156. /** @hidden */
  34157. _addPendingData(data: any): void;
  34158. /** @hidden */
  34159. _removePendingData(data: any): void;
  34160. /**
  34161. * Returns the number of items waiting to be loaded
  34162. * @returns the number of items waiting to be loaded
  34163. */
  34164. getWaitingItemsCount(): number;
  34165. /**
  34166. * Returns a boolean indicating if the scene is still loading data
  34167. */
  34168. readonly isLoading: boolean;
  34169. /**
  34170. * Registers a function to be executed when the scene is ready
  34171. * @param {Function} func - the function to be executed
  34172. */
  34173. executeWhenReady(func: () => void): void;
  34174. /**
  34175. * Returns a promise that resolves when the scene is ready
  34176. * @returns A promise that resolves when the scene is ready
  34177. */
  34178. whenReadyAsync(): Promise<void>;
  34179. /** @hidden */
  34180. _checkIsReady(): void;
  34181. /**
  34182. * Gets all animatable attached to the scene
  34183. */
  34184. readonly animatables: Animatable[];
  34185. /**
  34186. * Resets the last animation time frame.
  34187. * Useful to override when animations start running when loading a scene for the first time.
  34188. */
  34189. resetLastAnimationTimeFrame(): void;
  34190. /**
  34191. * Gets the current view matrix
  34192. * @returns a Matrix
  34193. */
  34194. getViewMatrix(): Matrix;
  34195. /**
  34196. * Gets the current projection matrix
  34197. * @returns a Matrix
  34198. */
  34199. getProjectionMatrix(): Matrix;
  34200. /**
  34201. * Gets the current transform matrix
  34202. * @returns a Matrix made of View * Projection
  34203. */
  34204. getTransformMatrix(): Matrix;
  34205. /**
  34206. * Sets the current transform matrix
  34207. * @param viewL defines the View matrix to use
  34208. * @param projectionL defines the Projection matrix to use
  34209. * @param viewR defines the right View matrix to use (if provided)
  34210. * @param projectionR defines the right Projection matrix to use (if provided)
  34211. */
  34212. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34213. /**
  34214. * Gets the uniform buffer used to store scene data
  34215. * @returns a UniformBuffer
  34216. */
  34217. getSceneUniformBuffer(): UniformBuffer;
  34218. /**
  34219. * Gets an unique (relatively to the current scene) Id
  34220. * @returns an unique number for the scene
  34221. */
  34222. getUniqueId(): number;
  34223. /**
  34224. * Add a mesh to the list of scene's meshes
  34225. * @param newMesh defines the mesh to add
  34226. * @param recursive if all child meshes should also be added to the scene
  34227. */
  34228. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34229. /**
  34230. * Remove a mesh for the list of scene's meshes
  34231. * @param toRemove defines the mesh to remove
  34232. * @param recursive if all child meshes should also be removed from the scene
  34233. * @returns the index where the mesh was in the mesh list
  34234. */
  34235. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34236. /**
  34237. * Add a transform node to the list of scene's transform nodes
  34238. * @param newTransformNode defines the transform node to add
  34239. */
  34240. addTransformNode(newTransformNode: TransformNode): void;
  34241. /**
  34242. * Remove a transform node for the list of scene's transform nodes
  34243. * @param toRemove defines the transform node to remove
  34244. * @returns the index where the transform node was in the transform node list
  34245. */
  34246. removeTransformNode(toRemove: TransformNode): number;
  34247. /**
  34248. * Remove a skeleton for the list of scene's skeletons
  34249. * @param toRemove defines the skeleton to remove
  34250. * @returns the index where the skeleton was in the skeleton list
  34251. */
  34252. removeSkeleton(toRemove: Skeleton): number;
  34253. /**
  34254. * Remove a morph target for the list of scene's morph targets
  34255. * @param toRemove defines the morph target to remove
  34256. * @returns the index where the morph target was in the morph target list
  34257. */
  34258. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34259. /**
  34260. * Remove a light for the list of scene's lights
  34261. * @param toRemove defines the light to remove
  34262. * @returns the index where the light was in the light list
  34263. */
  34264. removeLight(toRemove: Light): number;
  34265. /**
  34266. * Remove a camera for the list of scene's cameras
  34267. * @param toRemove defines the camera to remove
  34268. * @returns the index where the camera was in the camera list
  34269. */
  34270. removeCamera(toRemove: Camera): number;
  34271. /**
  34272. * Remove a particle system for the list of scene's particle systems
  34273. * @param toRemove defines the particle system to remove
  34274. * @returns the index where the particle system was in the particle system list
  34275. */
  34276. removeParticleSystem(toRemove: IParticleSystem): number;
  34277. /**
  34278. * Remove a animation for the list of scene's animations
  34279. * @param toRemove defines the animation to remove
  34280. * @returns the index where the animation was in the animation list
  34281. */
  34282. removeAnimation(toRemove: Animation): number;
  34283. /**
  34284. * Will stop the animation of the given target
  34285. * @param target - the target
  34286. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34287. * @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)
  34288. */
  34289. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34290. /**
  34291. * Removes the given animation group from this scene.
  34292. * @param toRemove The animation group to remove
  34293. * @returns The index of the removed animation group
  34294. */
  34295. removeAnimationGroup(toRemove: AnimationGroup): number;
  34296. /**
  34297. * Removes the given multi-material from this scene.
  34298. * @param toRemove The multi-material to remove
  34299. * @returns The index of the removed multi-material
  34300. */
  34301. removeMultiMaterial(toRemove: MultiMaterial): number;
  34302. /**
  34303. * Removes the given material from this scene.
  34304. * @param toRemove The material to remove
  34305. * @returns The index of the removed material
  34306. */
  34307. removeMaterial(toRemove: Material): number;
  34308. /**
  34309. * Removes the given action manager from this scene.
  34310. * @param toRemove The action manager to remove
  34311. * @returns The index of the removed action manager
  34312. */
  34313. removeActionManager(toRemove: AbstractActionManager): number;
  34314. /**
  34315. * Removes the given texture from this scene.
  34316. * @param toRemove The texture to remove
  34317. * @returns The index of the removed texture
  34318. */
  34319. removeTexture(toRemove: BaseTexture): number;
  34320. /**
  34321. * Adds the given light to this scene
  34322. * @param newLight The light to add
  34323. */
  34324. addLight(newLight: Light): void;
  34325. /**
  34326. * Sorts the list list based on light priorities
  34327. */
  34328. sortLightsByPriority(): void;
  34329. /**
  34330. * Adds the given camera to this scene
  34331. * @param newCamera The camera to add
  34332. */
  34333. addCamera(newCamera: Camera): void;
  34334. /**
  34335. * Adds the given skeleton to this scene
  34336. * @param newSkeleton The skeleton to add
  34337. */
  34338. addSkeleton(newSkeleton: Skeleton): void;
  34339. /**
  34340. * Adds the given particle system to this scene
  34341. * @param newParticleSystem The particle system to add
  34342. */
  34343. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34344. /**
  34345. * Adds the given animation to this scene
  34346. * @param newAnimation The animation to add
  34347. */
  34348. addAnimation(newAnimation: Animation): void;
  34349. /**
  34350. * Adds the given animation group to this scene.
  34351. * @param newAnimationGroup The animation group to add
  34352. */
  34353. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34354. /**
  34355. * Adds the given multi-material to this scene
  34356. * @param newMultiMaterial The multi-material to add
  34357. */
  34358. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34359. /**
  34360. * Adds the given material to this scene
  34361. * @param newMaterial The material to add
  34362. */
  34363. addMaterial(newMaterial: Material): void;
  34364. /**
  34365. * Adds the given morph target to this scene
  34366. * @param newMorphTargetManager The morph target to add
  34367. */
  34368. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34369. /**
  34370. * Adds the given geometry to this scene
  34371. * @param newGeometry The geometry to add
  34372. */
  34373. addGeometry(newGeometry: Geometry): void;
  34374. /**
  34375. * Adds the given action manager to this scene
  34376. * @param newActionManager The action manager to add
  34377. */
  34378. addActionManager(newActionManager: AbstractActionManager): void;
  34379. /**
  34380. * Adds the given texture to this scene.
  34381. * @param newTexture The texture to add
  34382. */
  34383. addTexture(newTexture: BaseTexture): void;
  34384. /**
  34385. * Switch active camera
  34386. * @param newCamera defines the new active camera
  34387. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34388. */
  34389. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34390. /**
  34391. * sets the active camera of the scene using its ID
  34392. * @param id defines the camera's ID
  34393. * @return the new active camera or null if none found.
  34394. */
  34395. setActiveCameraByID(id: string): Nullable<Camera>;
  34396. /**
  34397. * sets the active camera of the scene using its name
  34398. * @param name defines the camera's name
  34399. * @returns the new active camera or null if none found.
  34400. */
  34401. setActiveCameraByName(name: string): Nullable<Camera>;
  34402. /**
  34403. * get an animation group using its name
  34404. * @param name defines the material's name
  34405. * @return the animation group or null if none found.
  34406. */
  34407. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34408. /**
  34409. * Get a material using its unique id
  34410. * @param uniqueId defines the material's unique id
  34411. * @return the material or null if none found.
  34412. */
  34413. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34414. /**
  34415. * get a material using its id
  34416. * @param id defines the material's ID
  34417. * @return the material or null if none found.
  34418. */
  34419. getMaterialByID(id: string): Nullable<Material>;
  34420. /**
  34421. * Gets a material using its name
  34422. * @param name defines the material's name
  34423. * @return the material or null if none found.
  34424. */
  34425. getMaterialByName(name: string): Nullable<Material>;
  34426. /**
  34427. * Gets a camera using its id
  34428. * @param id defines the id to look for
  34429. * @returns the camera or null if not found
  34430. */
  34431. getCameraByID(id: string): Nullable<Camera>;
  34432. /**
  34433. * Gets a camera using its unique id
  34434. * @param uniqueId defines the unique id to look for
  34435. * @returns the camera or null if not found
  34436. */
  34437. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34438. /**
  34439. * Gets a camera using its name
  34440. * @param name defines the camera's name
  34441. * @return the camera or null if none found.
  34442. */
  34443. getCameraByName(name: string): Nullable<Camera>;
  34444. /**
  34445. * Gets a bone using its id
  34446. * @param id defines the bone's id
  34447. * @return the bone or null if not found
  34448. */
  34449. getBoneByID(id: string): Nullable<Bone>;
  34450. /**
  34451. * Gets a bone using its id
  34452. * @param name defines the bone's name
  34453. * @return the bone or null if not found
  34454. */
  34455. getBoneByName(name: string): Nullable<Bone>;
  34456. /**
  34457. * Gets a light node using its name
  34458. * @param name defines the the light's name
  34459. * @return the light or null if none found.
  34460. */
  34461. getLightByName(name: string): Nullable<Light>;
  34462. /**
  34463. * Gets a light node using its id
  34464. * @param id defines the light's id
  34465. * @return the light or null if none found.
  34466. */
  34467. getLightByID(id: string): Nullable<Light>;
  34468. /**
  34469. * Gets a light node using its scene-generated unique ID
  34470. * @param uniqueId defines the light's unique id
  34471. * @return the light or null if none found.
  34472. */
  34473. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34474. /**
  34475. * Gets a particle system by id
  34476. * @param id defines the particle system id
  34477. * @return the corresponding system or null if none found
  34478. */
  34479. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34480. /**
  34481. * Gets a geometry using its ID
  34482. * @param id defines the geometry's id
  34483. * @return the geometry or null if none found.
  34484. */
  34485. getGeometryByID(id: string): Nullable<Geometry>;
  34486. private _getGeometryByUniqueID;
  34487. /**
  34488. * Add a new geometry to this scene
  34489. * @param geometry defines the geometry to be added to the scene.
  34490. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34491. * @return a boolean defining if the geometry was added or not
  34492. */
  34493. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34494. /**
  34495. * Removes an existing geometry
  34496. * @param geometry defines the geometry to be removed from the scene
  34497. * @return a boolean defining if the geometry was removed or not
  34498. */
  34499. removeGeometry(geometry: Geometry): boolean;
  34500. /**
  34501. * Gets the list of geometries attached to the scene
  34502. * @returns an array of Geometry
  34503. */
  34504. getGeometries(): Geometry[];
  34505. /**
  34506. * Gets the first added mesh found of a given ID
  34507. * @param id defines the id to search for
  34508. * @return the mesh found or null if not found at all
  34509. */
  34510. getMeshByID(id: string): Nullable<AbstractMesh>;
  34511. /**
  34512. * Gets a list of meshes using their id
  34513. * @param id defines the id to search for
  34514. * @returns a list of meshes
  34515. */
  34516. getMeshesByID(id: string): Array<AbstractMesh>;
  34517. /**
  34518. * Gets the first added transform node found of a given ID
  34519. * @param id defines the id to search for
  34520. * @return the found transform node or null if not found at all.
  34521. */
  34522. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34523. /**
  34524. * Gets a transform node with its auto-generated unique id
  34525. * @param uniqueId efines the unique id to search for
  34526. * @return the found transform node or null if not found at all.
  34527. */
  34528. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34529. /**
  34530. * Gets a list of transform nodes using their id
  34531. * @param id defines the id to search for
  34532. * @returns a list of transform nodes
  34533. */
  34534. getTransformNodesByID(id: string): Array<TransformNode>;
  34535. /**
  34536. * Gets a mesh with its auto-generated unique id
  34537. * @param uniqueId defines the unique id to search for
  34538. * @return the found mesh or null if not found at all.
  34539. */
  34540. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34541. /**
  34542. * Gets a the last added mesh using a given id
  34543. * @param id defines the id to search for
  34544. * @return the found mesh or null if not found at all.
  34545. */
  34546. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34547. /**
  34548. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34549. * @param id defines the id to search for
  34550. * @return the found node or null if not found at all
  34551. */
  34552. getLastEntryByID(id: string): Nullable<Node>;
  34553. /**
  34554. * Gets a node (Mesh, Camera, Light) using a given id
  34555. * @param id defines the id to search for
  34556. * @return the found node or null if not found at all
  34557. */
  34558. getNodeByID(id: string): Nullable<Node>;
  34559. /**
  34560. * Gets a node (Mesh, Camera, Light) using a given name
  34561. * @param name defines the name to search for
  34562. * @return the found node or null if not found at all.
  34563. */
  34564. getNodeByName(name: string): Nullable<Node>;
  34565. /**
  34566. * Gets a mesh using a given name
  34567. * @param name defines the name to search for
  34568. * @return the found mesh or null if not found at all.
  34569. */
  34570. getMeshByName(name: string): Nullable<AbstractMesh>;
  34571. /**
  34572. * Gets a transform node using a given name
  34573. * @param name defines the name to search for
  34574. * @return the found transform node or null if not found at all.
  34575. */
  34576. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34577. /**
  34578. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34579. * @param id defines the id to search for
  34580. * @return the found skeleton or null if not found at all.
  34581. */
  34582. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34583. /**
  34584. * Gets a skeleton using a given auto generated unique id
  34585. * @param uniqueId defines the unique id to search for
  34586. * @return the found skeleton or null if not found at all.
  34587. */
  34588. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34589. /**
  34590. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34591. * @param id defines the id to search for
  34592. * @return the found skeleton or null if not found at all.
  34593. */
  34594. getSkeletonById(id: string): Nullable<Skeleton>;
  34595. /**
  34596. * Gets a skeleton using a given name
  34597. * @param name defines the name to search for
  34598. * @return the found skeleton or null if not found at all.
  34599. */
  34600. getSkeletonByName(name: string): Nullable<Skeleton>;
  34601. /**
  34602. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34603. * @param id defines the id to search for
  34604. * @return the found morph target manager or null if not found at all.
  34605. */
  34606. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34607. /**
  34608. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34609. * @param id defines the id to search for
  34610. * @return the found morph target or null if not found at all.
  34611. */
  34612. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34613. /**
  34614. * Gets a boolean indicating if the given mesh is active
  34615. * @param mesh defines the mesh to look for
  34616. * @returns true if the mesh is in the active list
  34617. */
  34618. isActiveMesh(mesh: AbstractMesh): boolean;
  34619. /**
  34620. * Return a unique id as a string which can serve as an identifier for the scene
  34621. */
  34622. readonly uid: string;
  34623. /**
  34624. * Add an externaly attached data from its key.
  34625. * This method call will fail and return false, if such key already exists.
  34626. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34627. * @param key the unique key that identifies the data
  34628. * @param data the data object to associate to the key for this Engine instance
  34629. * @return true if no such key were already present and the data was added successfully, false otherwise
  34630. */
  34631. addExternalData<T>(key: string, data: T): boolean;
  34632. /**
  34633. * Get an externaly attached data from its key
  34634. * @param key the unique key that identifies the data
  34635. * @return the associated data, if present (can be null), or undefined if not present
  34636. */
  34637. getExternalData<T>(key: string): Nullable<T>;
  34638. /**
  34639. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34640. * @param key the unique key that identifies the data
  34641. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34642. * @return the associated data, can be null if the factory returned null.
  34643. */
  34644. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34645. /**
  34646. * Remove an externaly attached data from the Engine instance
  34647. * @param key the unique key that identifies the data
  34648. * @return true if the data was successfully removed, false if it doesn't exist
  34649. */
  34650. removeExternalData(key: string): boolean;
  34651. private _evaluateSubMesh;
  34652. /**
  34653. * Clear the processed materials smart array preventing retention point in material dispose.
  34654. */
  34655. freeProcessedMaterials(): void;
  34656. private _preventFreeActiveMeshesAndRenderingGroups;
  34657. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34658. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34659. * when disposing several meshes in a row or a hierarchy of meshes.
  34660. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34661. */
  34662. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34663. /**
  34664. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34665. */
  34666. freeActiveMeshes(): void;
  34667. /**
  34668. * Clear the info related to rendering groups preventing retention points during dispose.
  34669. */
  34670. freeRenderingGroups(): void;
  34671. /** @hidden */
  34672. _isInIntermediateRendering(): boolean;
  34673. /**
  34674. * Lambda returning the list of potentially active meshes.
  34675. */
  34676. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34677. /**
  34678. * Lambda returning the list of potentially active sub meshes.
  34679. */
  34680. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34681. /**
  34682. * Lambda returning the list of potentially intersecting sub meshes.
  34683. */
  34684. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34685. /**
  34686. * Lambda returning the list of potentially colliding sub meshes.
  34687. */
  34688. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34689. private _activeMeshesFrozen;
  34690. /**
  34691. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34692. * @returns the current scene
  34693. */
  34694. freezeActiveMeshes(): Scene;
  34695. /**
  34696. * Use this function to restart evaluating active meshes on every frame
  34697. * @returns the current scene
  34698. */
  34699. unfreezeActiveMeshes(): Scene;
  34700. private _evaluateActiveMeshes;
  34701. private _activeMesh;
  34702. /**
  34703. * Update the transform matrix to update from the current active camera
  34704. * @param force defines a boolean used to force the update even if cache is up to date
  34705. */
  34706. updateTransformMatrix(force?: boolean): void;
  34707. private _bindFrameBuffer;
  34708. /** @hidden */
  34709. _allowPostProcessClearColor: boolean;
  34710. /** @hidden */
  34711. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34712. private _processSubCameras;
  34713. private _checkIntersections;
  34714. /** @hidden */
  34715. _advancePhysicsEngineStep(step: number): void;
  34716. /**
  34717. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34718. */
  34719. getDeterministicFrameTime: () => number;
  34720. /** @hidden */
  34721. _animate(): void;
  34722. /** Execute all animations (for a frame) */
  34723. animate(): void;
  34724. /**
  34725. * Render the scene
  34726. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34727. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34728. */
  34729. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34730. /**
  34731. * Freeze all materials
  34732. * A frozen material will not be updatable but should be faster to render
  34733. */
  34734. freezeMaterials(): void;
  34735. /**
  34736. * Unfreeze all materials
  34737. * A frozen material will not be updatable but should be faster to render
  34738. */
  34739. unfreezeMaterials(): void;
  34740. /**
  34741. * Releases all held ressources
  34742. */
  34743. dispose(): void;
  34744. /**
  34745. * Gets if the scene is already disposed
  34746. */
  34747. readonly isDisposed: boolean;
  34748. /**
  34749. * Call this function to reduce memory footprint of the scene.
  34750. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34751. */
  34752. clearCachedVertexData(): void;
  34753. /**
  34754. * This function will remove the local cached buffer data from texture.
  34755. * It will save memory but will prevent the texture from being rebuilt
  34756. */
  34757. cleanCachedTextureBuffer(): void;
  34758. /**
  34759. * Get the world extend vectors with an optional filter
  34760. *
  34761. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34762. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34763. */
  34764. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34765. min: Vector3;
  34766. max: Vector3;
  34767. };
  34768. /**
  34769. * Creates a ray that can be used to pick in the scene
  34770. * @param x defines the x coordinate of the origin (on-screen)
  34771. * @param y defines the y coordinate of the origin (on-screen)
  34772. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34773. * @param camera defines the camera to use for the picking
  34774. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34775. * @returns a Ray
  34776. */
  34777. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34778. /**
  34779. * Creates a ray that can be used to pick in the scene
  34780. * @param x defines the x coordinate of the origin (on-screen)
  34781. * @param y defines the y coordinate of the origin (on-screen)
  34782. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34783. * @param result defines the ray where to store the picking ray
  34784. * @param camera defines the camera to use for the picking
  34785. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34786. * @returns the current scene
  34787. */
  34788. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34789. /**
  34790. * Creates a ray that can be used to pick in the scene
  34791. * @param x defines the x coordinate of the origin (on-screen)
  34792. * @param y defines the y coordinate of the origin (on-screen)
  34793. * @param camera defines the camera to use for the picking
  34794. * @returns a Ray
  34795. */
  34796. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34797. /**
  34798. * Creates a ray that can be used to pick in the scene
  34799. * @param x defines the x coordinate of the origin (on-screen)
  34800. * @param y defines the y coordinate of the origin (on-screen)
  34801. * @param result defines the ray where to store the picking ray
  34802. * @param camera defines the camera to use for the picking
  34803. * @returns the current scene
  34804. */
  34805. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34806. /** Launch a ray to try to pick a mesh in the scene
  34807. * @param x position on screen
  34808. * @param y position on screen
  34809. * @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
  34810. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34811. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34812. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34813. * @returns a PickingInfo
  34814. */
  34815. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34816. /** Use the given ray to pick a mesh in the scene
  34817. * @param ray The ray to use to pick meshes
  34818. * @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
  34819. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34820. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34821. * @returns a PickingInfo
  34822. */
  34823. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34824. /**
  34825. * Launch a ray to try to pick a mesh in the scene
  34826. * @param x X position on screen
  34827. * @param y Y position on screen
  34828. * @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
  34829. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34830. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34831. * @returns an array of PickingInfo
  34832. */
  34833. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34834. /**
  34835. * Launch a ray to try to pick a mesh in the scene
  34836. * @param ray Ray to use
  34837. * @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
  34838. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34839. * @returns an array of PickingInfo
  34840. */
  34841. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34842. /**
  34843. * Force the value of meshUnderPointer
  34844. * @param mesh defines the mesh to use
  34845. */
  34846. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34847. /**
  34848. * Gets the mesh under the pointer
  34849. * @returns a Mesh or null if no mesh is under the pointer
  34850. */
  34851. getPointerOverMesh(): Nullable<AbstractMesh>;
  34852. /** @hidden */
  34853. _rebuildGeometries(): void;
  34854. /** @hidden */
  34855. _rebuildTextures(): void;
  34856. private _getByTags;
  34857. /**
  34858. * Get a list of meshes by tags
  34859. * @param tagsQuery defines the tags query to use
  34860. * @param forEach defines a predicate used to filter results
  34861. * @returns an array of Mesh
  34862. */
  34863. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34864. /**
  34865. * Get a list of cameras by tags
  34866. * @param tagsQuery defines the tags query to use
  34867. * @param forEach defines a predicate used to filter results
  34868. * @returns an array of Camera
  34869. */
  34870. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34871. /**
  34872. * Get a list of lights by tags
  34873. * @param tagsQuery defines the tags query to use
  34874. * @param forEach defines a predicate used to filter results
  34875. * @returns an array of Light
  34876. */
  34877. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34878. /**
  34879. * Get a list of materials by tags
  34880. * @param tagsQuery defines the tags query to use
  34881. * @param forEach defines a predicate used to filter results
  34882. * @returns an array of Material
  34883. */
  34884. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34885. /**
  34886. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34887. * This allowed control for front to back rendering or reversly depending of the special needs.
  34888. *
  34889. * @param renderingGroupId The rendering group id corresponding to its index
  34890. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34891. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34892. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34893. */
  34894. 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;
  34895. /**
  34896. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34897. *
  34898. * @param renderingGroupId The rendering group id corresponding to its index
  34899. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34900. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34901. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34902. */
  34903. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34904. /**
  34905. * Gets the current auto clear configuration for one rendering group of the rendering
  34906. * manager.
  34907. * @param index the rendering group index to get the information for
  34908. * @returns The auto clear setup for the requested rendering group
  34909. */
  34910. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34911. private _blockMaterialDirtyMechanism;
  34912. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34913. blockMaterialDirtyMechanism: boolean;
  34914. /**
  34915. * Will flag all materials as dirty to trigger new shader compilation
  34916. * @param flag defines the flag used to specify which material part must be marked as dirty
  34917. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34918. */
  34919. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34920. /** @hidden */
  34921. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34922. /** @hidden */
  34923. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34924. }
  34925. }
  34926. declare module "babylonjs/assetContainer" {
  34927. import { AbstractScene } from "babylonjs/abstractScene";
  34928. import { Scene } from "babylonjs/scene";
  34929. import { Mesh } from "babylonjs/Meshes/mesh";
  34930. /**
  34931. * Set of assets to keep when moving a scene into an asset container.
  34932. */
  34933. export class KeepAssets extends AbstractScene {
  34934. }
  34935. /**
  34936. * Container with a set of assets that can be added or removed from a scene.
  34937. */
  34938. export class AssetContainer extends AbstractScene {
  34939. /**
  34940. * The scene the AssetContainer belongs to.
  34941. */
  34942. scene: Scene;
  34943. /**
  34944. * Instantiates an AssetContainer.
  34945. * @param scene The scene the AssetContainer belongs to.
  34946. */
  34947. constructor(scene: Scene);
  34948. /**
  34949. * Adds all the assets from the container to the scene.
  34950. */
  34951. addAllToScene(): void;
  34952. /**
  34953. * Removes all the assets in the container from the scene
  34954. */
  34955. removeAllFromScene(): void;
  34956. /**
  34957. * Disposes all the assets in the container
  34958. */
  34959. dispose(): void;
  34960. private _moveAssets;
  34961. /**
  34962. * Removes all the assets contained in the scene and adds them to the container.
  34963. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34964. */
  34965. moveAllFromScene(keepAssets?: KeepAssets): void;
  34966. /**
  34967. * 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.
  34968. * @returns the root mesh
  34969. */
  34970. createRootMesh(): Mesh;
  34971. }
  34972. }
  34973. declare module "babylonjs/abstractScene" {
  34974. import { Scene } from "babylonjs/scene";
  34975. import { Nullable } from "babylonjs/types";
  34976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34978. import { Geometry } from "babylonjs/Meshes/geometry";
  34979. import { Skeleton } from "babylonjs/Bones/skeleton";
  34980. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34981. import { AssetContainer } from "babylonjs/assetContainer";
  34982. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34983. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34985. import { Material } from "babylonjs/Materials/material";
  34986. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34987. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34988. import { Camera } from "babylonjs/Cameras/camera";
  34989. import { Light } from "babylonjs/Lights/light";
  34990. import { Node } from "babylonjs/node";
  34991. import { Animation } from "babylonjs/Animations/animation";
  34992. /**
  34993. * Defines how the parser contract is defined.
  34994. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34995. */
  34996. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34997. /**
  34998. * Defines how the individual parser contract is defined.
  34999. * These parser can parse an individual asset
  35000. */
  35001. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35002. /**
  35003. * Base class of the scene acting as a container for the different elements composing a scene.
  35004. * This class is dynamically extended by the different components of the scene increasing
  35005. * flexibility and reducing coupling
  35006. */
  35007. export abstract class AbstractScene {
  35008. /**
  35009. * Stores the list of available parsers in the application.
  35010. */
  35011. private static _BabylonFileParsers;
  35012. /**
  35013. * Stores the list of available individual parsers in the application.
  35014. */
  35015. private static _IndividualBabylonFileParsers;
  35016. /**
  35017. * Adds a parser in the list of available ones
  35018. * @param name Defines the name of the parser
  35019. * @param parser Defines the parser to add
  35020. */
  35021. static AddParser(name: string, parser: BabylonFileParser): void;
  35022. /**
  35023. * Gets a general parser from the list of avaialble ones
  35024. * @param name Defines the name of the parser
  35025. * @returns the requested parser or null
  35026. */
  35027. static GetParser(name: string): Nullable<BabylonFileParser>;
  35028. /**
  35029. * Adds n individual parser in the list of available ones
  35030. * @param name Defines the name of the parser
  35031. * @param parser Defines the parser to add
  35032. */
  35033. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35034. /**
  35035. * Gets an individual parser from the list of avaialble ones
  35036. * @param name Defines the name of the parser
  35037. * @returns the requested parser or null
  35038. */
  35039. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35040. /**
  35041. * Parser json data and populate both a scene and its associated container object
  35042. * @param jsonData Defines the data to parse
  35043. * @param scene Defines the scene to parse the data for
  35044. * @param container Defines the container attached to the parsing sequence
  35045. * @param rootUrl Defines the root url of the data
  35046. */
  35047. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35048. /**
  35049. * Gets the list of root nodes (ie. nodes with no parent)
  35050. */
  35051. rootNodes: Node[];
  35052. /** All of the cameras added to this scene
  35053. * @see http://doc.babylonjs.com/babylon101/cameras
  35054. */
  35055. cameras: Camera[];
  35056. /**
  35057. * All of the lights added to this scene
  35058. * @see http://doc.babylonjs.com/babylon101/lights
  35059. */
  35060. lights: Light[];
  35061. /**
  35062. * All of the (abstract) meshes added to this scene
  35063. */
  35064. meshes: AbstractMesh[];
  35065. /**
  35066. * The list of skeletons added to the scene
  35067. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35068. */
  35069. skeletons: Skeleton[];
  35070. /**
  35071. * All of the particle systems added to this scene
  35072. * @see http://doc.babylonjs.com/babylon101/particles
  35073. */
  35074. particleSystems: IParticleSystem[];
  35075. /**
  35076. * Gets a list of Animations associated with the scene
  35077. */
  35078. animations: Animation[];
  35079. /**
  35080. * All of the animation groups added to this scene
  35081. * @see http://doc.babylonjs.com/how_to/group
  35082. */
  35083. animationGroups: AnimationGroup[];
  35084. /**
  35085. * All of the multi-materials added to this scene
  35086. * @see http://doc.babylonjs.com/how_to/multi_materials
  35087. */
  35088. multiMaterials: MultiMaterial[];
  35089. /**
  35090. * All of the materials added to this scene
  35091. * In the context of a Scene, it is not supposed to be modified manually.
  35092. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35093. * Note also that the order of the Material wihin the array is not significant and might change.
  35094. * @see http://doc.babylonjs.com/babylon101/materials
  35095. */
  35096. materials: Material[];
  35097. /**
  35098. * The list of morph target managers added to the scene
  35099. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35100. */
  35101. morphTargetManagers: MorphTargetManager[];
  35102. /**
  35103. * The list of geometries used in the scene.
  35104. */
  35105. geometries: Geometry[];
  35106. /**
  35107. * All of the tranform nodes added to this scene
  35108. * In the context of a Scene, it is not supposed to be modified manually.
  35109. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35110. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35111. * @see http://doc.babylonjs.com/how_to/transformnode
  35112. */
  35113. transformNodes: TransformNode[];
  35114. /**
  35115. * ActionManagers available on the scene.
  35116. */
  35117. actionManagers: AbstractActionManager[];
  35118. /**
  35119. * Textures to keep.
  35120. */
  35121. textures: BaseTexture[];
  35122. /**
  35123. * Environment texture for the scene
  35124. */
  35125. environmentTexture: Nullable<BaseTexture>;
  35126. }
  35127. }
  35128. declare module "babylonjs/Audio/sound" {
  35129. import { Observable } from "babylonjs/Misc/observable";
  35130. import { Vector3 } from "babylonjs/Maths/math";
  35131. import { Nullable } from "babylonjs/types";
  35132. import { Scene } from "babylonjs/scene";
  35133. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35134. /**
  35135. * Interface used to define options for Sound class
  35136. */
  35137. export interface ISoundOptions {
  35138. /**
  35139. * Does the sound autoplay once loaded.
  35140. */
  35141. autoplay?: boolean;
  35142. /**
  35143. * Does the sound loop after it finishes playing once.
  35144. */
  35145. loop?: boolean;
  35146. /**
  35147. * Sound's volume
  35148. */
  35149. volume?: number;
  35150. /**
  35151. * Is it a spatial sound?
  35152. */
  35153. spatialSound?: boolean;
  35154. /**
  35155. * Maximum distance to hear that sound
  35156. */
  35157. maxDistance?: number;
  35158. /**
  35159. * Uses user defined attenuation function
  35160. */
  35161. useCustomAttenuation?: boolean;
  35162. /**
  35163. * Define the roll off factor of spatial sounds.
  35164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35165. */
  35166. rolloffFactor?: number;
  35167. /**
  35168. * Define the reference distance the sound should be heard perfectly.
  35169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35170. */
  35171. refDistance?: number;
  35172. /**
  35173. * Define the distance attenuation model the sound will follow.
  35174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35175. */
  35176. distanceModel?: string;
  35177. /**
  35178. * Defines the playback speed (1 by default)
  35179. */
  35180. playbackRate?: number;
  35181. /**
  35182. * Defines if the sound is from a streaming source
  35183. */
  35184. streaming?: boolean;
  35185. /**
  35186. * Defines an optional length (in ms) inside the sound file
  35187. */
  35188. length?: number;
  35189. /**
  35190. * Defines an optional offset (in ms) inside the sound file
  35191. */
  35192. offset?: number;
  35193. }
  35194. /**
  35195. * Defines a sound that can be played in the application.
  35196. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35198. */
  35199. export class Sound {
  35200. /**
  35201. * The name of the sound in the scene.
  35202. */
  35203. name: string;
  35204. /**
  35205. * Does the sound autoplay once loaded.
  35206. */
  35207. autoplay: boolean;
  35208. /**
  35209. * Does the sound loop after it finishes playing once.
  35210. */
  35211. loop: boolean;
  35212. /**
  35213. * Does the sound use a custom attenuation curve to simulate the falloff
  35214. * happening when the source gets further away from the camera.
  35215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35216. */
  35217. useCustomAttenuation: boolean;
  35218. /**
  35219. * The sound track id this sound belongs to.
  35220. */
  35221. soundTrackId: number;
  35222. /**
  35223. * Is this sound currently played.
  35224. */
  35225. isPlaying: boolean;
  35226. /**
  35227. * Is this sound currently paused.
  35228. */
  35229. isPaused: boolean;
  35230. /**
  35231. * Does this sound enables spatial sound.
  35232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35233. */
  35234. spatialSound: boolean;
  35235. /**
  35236. * Define the reference distance the sound should be heard perfectly.
  35237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35238. */
  35239. refDistance: number;
  35240. /**
  35241. * Define the roll off factor of spatial sounds.
  35242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35243. */
  35244. rolloffFactor: number;
  35245. /**
  35246. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35248. */
  35249. maxDistance: number;
  35250. /**
  35251. * Define the distance attenuation model the sound will follow.
  35252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35253. */
  35254. distanceModel: string;
  35255. /**
  35256. * @hidden
  35257. * Back Compat
  35258. **/
  35259. onended: () => any;
  35260. /**
  35261. * Observable event when the current playing sound finishes.
  35262. */
  35263. onEndedObservable: Observable<Sound>;
  35264. private _panningModel;
  35265. private _playbackRate;
  35266. private _streaming;
  35267. private _startTime;
  35268. private _startOffset;
  35269. private _position;
  35270. /** @hidden */
  35271. _positionInEmitterSpace: boolean;
  35272. private _localDirection;
  35273. private _volume;
  35274. private _isReadyToPlay;
  35275. private _isDirectional;
  35276. private _readyToPlayCallback;
  35277. private _audioBuffer;
  35278. private _soundSource;
  35279. private _streamingSource;
  35280. private _soundPanner;
  35281. private _soundGain;
  35282. private _inputAudioNode;
  35283. private _outputAudioNode;
  35284. private _coneInnerAngle;
  35285. private _coneOuterAngle;
  35286. private _coneOuterGain;
  35287. private _scene;
  35288. private _connectedTransformNode;
  35289. private _customAttenuationFunction;
  35290. private _registerFunc;
  35291. private _isOutputConnected;
  35292. private _htmlAudioElement;
  35293. private _urlType;
  35294. private _length?;
  35295. private _offset?;
  35296. /** @hidden */
  35297. static _SceneComponentInitialization: (scene: Scene) => void;
  35298. /**
  35299. * Create a sound and attach it to a scene
  35300. * @param name Name of your sound
  35301. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35302. * @param scene defines the scene the sound belongs to
  35303. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35304. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35305. */
  35306. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35307. /**
  35308. * Release the sound and its associated resources
  35309. */
  35310. dispose(): void;
  35311. /**
  35312. * Gets if the sounds is ready to be played or not.
  35313. * @returns true if ready, otherwise false
  35314. */
  35315. isReady(): boolean;
  35316. private _soundLoaded;
  35317. /**
  35318. * Sets the data of the sound from an audiobuffer
  35319. * @param audioBuffer The audioBuffer containing the data
  35320. */
  35321. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35322. /**
  35323. * Updates the current sounds options such as maxdistance, loop...
  35324. * @param options A JSON object containing values named as the object properties
  35325. */
  35326. updateOptions(options: ISoundOptions): void;
  35327. private _createSpatialParameters;
  35328. private _updateSpatialParameters;
  35329. /**
  35330. * Switch the panning model to HRTF:
  35331. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35333. */
  35334. switchPanningModelToHRTF(): void;
  35335. /**
  35336. * Switch the panning model to Equal Power:
  35337. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35339. */
  35340. switchPanningModelToEqualPower(): void;
  35341. private _switchPanningModel;
  35342. /**
  35343. * Connect this sound to a sound track audio node like gain...
  35344. * @param soundTrackAudioNode the sound track audio node to connect to
  35345. */
  35346. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35347. /**
  35348. * Transform this sound into a directional source
  35349. * @param coneInnerAngle Size of the inner cone in degree
  35350. * @param coneOuterAngle Size of the outer cone in degree
  35351. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35352. */
  35353. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35354. /**
  35355. * Gets or sets the inner angle for the directional cone.
  35356. */
  35357. /**
  35358. * Gets or sets the inner angle for the directional cone.
  35359. */
  35360. directionalConeInnerAngle: number;
  35361. /**
  35362. * Gets or sets the outer angle for the directional cone.
  35363. */
  35364. /**
  35365. * Gets or sets the outer angle for the directional cone.
  35366. */
  35367. directionalConeOuterAngle: number;
  35368. /**
  35369. * Sets the position of the emitter if spatial sound is enabled
  35370. * @param newPosition Defines the new posisiton
  35371. */
  35372. setPosition(newPosition: Vector3): void;
  35373. /**
  35374. * Sets the local direction of the emitter if spatial sound is enabled
  35375. * @param newLocalDirection Defines the new local direction
  35376. */
  35377. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35378. private _updateDirection;
  35379. /** @hidden */
  35380. updateDistanceFromListener(): void;
  35381. /**
  35382. * Sets a new custom attenuation function for the sound.
  35383. * @param callback Defines the function used for the attenuation
  35384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35385. */
  35386. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35387. /**
  35388. * Play the sound
  35389. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35390. * @param offset (optional) Start the sound at a specific time in seconds
  35391. * @param length (optional) Sound duration (in seconds)
  35392. */
  35393. play(time?: number, offset?: number, length?: number): void;
  35394. private _onended;
  35395. /**
  35396. * Stop the sound
  35397. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35398. */
  35399. stop(time?: number): void;
  35400. /**
  35401. * Put the sound in pause
  35402. */
  35403. pause(): void;
  35404. /**
  35405. * Sets a dedicated volume for this sounds
  35406. * @param newVolume Define the new volume of the sound
  35407. * @param time Define time for gradual change to new volume
  35408. */
  35409. setVolume(newVolume: number, time?: number): void;
  35410. /**
  35411. * Set the sound play back rate
  35412. * @param newPlaybackRate Define the playback rate the sound should be played at
  35413. */
  35414. setPlaybackRate(newPlaybackRate: number): void;
  35415. /**
  35416. * Gets the volume of the sound.
  35417. * @returns the volume of the sound
  35418. */
  35419. getVolume(): number;
  35420. /**
  35421. * Attach the sound to a dedicated mesh
  35422. * @param transformNode The transform node to connect the sound with
  35423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35424. */
  35425. attachToMesh(transformNode: TransformNode): void;
  35426. /**
  35427. * Detach the sound from the previously attached mesh
  35428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35429. */
  35430. detachFromMesh(): void;
  35431. private _onRegisterAfterWorldMatrixUpdate;
  35432. /**
  35433. * Clone the current sound in the scene.
  35434. * @returns the new sound clone
  35435. */
  35436. clone(): Nullable<Sound>;
  35437. /**
  35438. * Gets the current underlying audio buffer containing the data
  35439. * @returns the audio buffer
  35440. */
  35441. getAudioBuffer(): Nullable<AudioBuffer>;
  35442. /**
  35443. * Serializes the Sound in a JSON representation
  35444. * @returns the JSON representation of the sound
  35445. */
  35446. serialize(): any;
  35447. /**
  35448. * Parse a JSON representation of a sound to innstantiate in a given scene
  35449. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35450. * @param scene Define the scene the new parsed sound should be created in
  35451. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35452. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35453. * @returns the newly parsed sound
  35454. */
  35455. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35456. }
  35457. }
  35458. declare module "babylonjs/Actions/directAudioActions" {
  35459. import { Action } from "babylonjs/Actions/action";
  35460. import { Condition } from "babylonjs/Actions/condition";
  35461. import { Sound } from "babylonjs/Audio/sound";
  35462. /**
  35463. * This defines an action helpful to play a defined sound on a triggered action.
  35464. */
  35465. export class PlaySoundAction extends Action {
  35466. private _sound;
  35467. /**
  35468. * Instantiate the action
  35469. * @param triggerOptions defines the trigger options
  35470. * @param sound defines the sound to play
  35471. * @param condition defines the trigger related conditions
  35472. */
  35473. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35474. /** @hidden */
  35475. _prepare(): void;
  35476. /**
  35477. * Execute the action and play the sound.
  35478. */
  35479. execute(): void;
  35480. /**
  35481. * Serializes the actions and its related information.
  35482. * @param parent defines the object to serialize in
  35483. * @returns the serialized object
  35484. */
  35485. serialize(parent: any): any;
  35486. }
  35487. /**
  35488. * This defines an action helpful to stop a defined sound on a triggered action.
  35489. */
  35490. export class StopSoundAction extends Action {
  35491. private _sound;
  35492. /**
  35493. * Instantiate the action
  35494. * @param triggerOptions defines the trigger options
  35495. * @param sound defines the sound to stop
  35496. * @param condition defines the trigger related conditions
  35497. */
  35498. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35499. /** @hidden */
  35500. _prepare(): void;
  35501. /**
  35502. * Execute the action and stop the sound.
  35503. */
  35504. execute(): void;
  35505. /**
  35506. * Serializes the actions and its related information.
  35507. * @param parent defines the object to serialize in
  35508. * @returns the serialized object
  35509. */
  35510. serialize(parent: any): any;
  35511. }
  35512. }
  35513. declare module "babylonjs/Actions/interpolateValueAction" {
  35514. import { Action } from "babylonjs/Actions/action";
  35515. import { Condition } from "babylonjs/Actions/condition";
  35516. import { Observable } from "babylonjs/Misc/observable";
  35517. /**
  35518. * This defines an action responsible to change the value of a property
  35519. * by interpolating between its current value and the newly set one once triggered.
  35520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35521. */
  35522. export class InterpolateValueAction extends Action {
  35523. /**
  35524. * Defines the path of the property where the value should be interpolated
  35525. */
  35526. propertyPath: string;
  35527. /**
  35528. * Defines the target value at the end of the interpolation.
  35529. */
  35530. value: any;
  35531. /**
  35532. * Defines the time it will take for the property to interpolate to the value.
  35533. */
  35534. duration: number;
  35535. /**
  35536. * Defines if the other scene animations should be stopped when the action has been triggered
  35537. */
  35538. stopOtherAnimations?: boolean;
  35539. /**
  35540. * Defines a callback raised once the interpolation animation has been done.
  35541. */
  35542. onInterpolationDone?: () => void;
  35543. /**
  35544. * Observable triggered once the interpolation animation has been done.
  35545. */
  35546. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35547. private _target;
  35548. private _effectiveTarget;
  35549. private _property;
  35550. /**
  35551. * Instantiate the action
  35552. * @param triggerOptions defines the trigger options
  35553. * @param target defines the object containing the value to interpolate
  35554. * @param propertyPath defines the path to the property in the target object
  35555. * @param value defines the target value at the end of the interpolation
  35556. * @param duration deines the time it will take for the property to interpolate to the value.
  35557. * @param condition defines the trigger related conditions
  35558. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35559. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35560. */
  35561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35562. /** @hidden */
  35563. _prepare(): void;
  35564. /**
  35565. * Execute the action starts the value interpolation.
  35566. */
  35567. execute(): void;
  35568. /**
  35569. * Serializes the actions and its related information.
  35570. * @param parent defines the object to serialize in
  35571. * @returns the serialized object
  35572. */
  35573. serialize(parent: any): any;
  35574. }
  35575. }
  35576. declare module "babylonjs/Actions/index" {
  35577. export * from "babylonjs/Actions/action";
  35578. export * from "babylonjs/Actions/actionEvent";
  35579. export * from "babylonjs/Actions/actionManager";
  35580. export * from "babylonjs/Actions/condition";
  35581. export * from "babylonjs/Actions/directActions";
  35582. export * from "babylonjs/Actions/directAudioActions";
  35583. export * from "babylonjs/Actions/interpolateValueAction";
  35584. }
  35585. declare module "babylonjs/Animations/index" {
  35586. export * from "babylonjs/Animations/animatable";
  35587. export * from "babylonjs/Animations/animation";
  35588. export * from "babylonjs/Animations/animationGroup";
  35589. export * from "babylonjs/Animations/animationPropertiesOverride";
  35590. export * from "babylonjs/Animations/easing";
  35591. export * from "babylonjs/Animations/runtimeAnimation";
  35592. export * from "babylonjs/Animations/animationEvent";
  35593. export * from "babylonjs/Animations/animationGroup";
  35594. export * from "babylonjs/Animations/animationKey";
  35595. export * from "babylonjs/Animations/animationRange";
  35596. }
  35597. declare module "babylonjs/Audio/soundTrack" {
  35598. import { Sound } from "babylonjs/Audio/sound";
  35599. import { Analyser } from "babylonjs/Audio/analyser";
  35600. import { Scene } from "babylonjs/scene";
  35601. /**
  35602. * Options allowed during the creation of a sound track.
  35603. */
  35604. export interface ISoundTrackOptions {
  35605. /**
  35606. * The volume the sound track should take during creation
  35607. */
  35608. volume?: number;
  35609. /**
  35610. * Define if the sound track is the main sound track of the scene
  35611. */
  35612. mainTrack?: boolean;
  35613. }
  35614. /**
  35615. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35616. * It will be also used in a future release to apply effects on a specific track.
  35617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35618. */
  35619. export class SoundTrack {
  35620. /**
  35621. * The unique identifier of the sound track in the scene.
  35622. */
  35623. id: number;
  35624. /**
  35625. * The list of sounds included in the sound track.
  35626. */
  35627. soundCollection: Array<Sound>;
  35628. private _outputAudioNode;
  35629. private _scene;
  35630. private _isMainTrack;
  35631. private _connectedAnalyser;
  35632. private _options;
  35633. private _isInitialized;
  35634. /**
  35635. * Creates a new sound track.
  35636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35637. * @param scene Define the scene the sound track belongs to
  35638. * @param options
  35639. */
  35640. constructor(scene: Scene, options?: ISoundTrackOptions);
  35641. private _initializeSoundTrackAudioGraph;
  35642. /**
  35643. * Release the sound track and its associated resources
  35644. */
  35645. dispose(): void;
  35646. /**
  35647. * Adds a sound to this sound track
  35648. * @param sound define the cound to add
  35649. * @ignoreNaming
  35650. */
  35651. AddSound(sound: Sound): void;
  35652. /**
  35653. * Removes a sound to this sound track
  35654. * @param sound define the cound to remove
  35655. * @ignoreNaming
  35656. */
  35657. RemoveSound(sound: Sound): void;
  35658. /**
  35659. * Set a global volume for the full sound track.
  35660. * @param newVolume Define the new volume of the sound track
  35661. */
  35662. setVolume(newVolume: number): void;
  35663. /**
  35664. * Switch the panning model to HRTF:
  35665. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35667. */
  35668. switchPanningModelToHRTF(): void;
  35669. /**
  35670. * Switch the panning model to Equal Power:
  35671. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35673. */
  35674. switchPanningModelToEqualPower(): void;
  35675. /**
  35676. * Connect the sound track to an audio analyser allowing some amazing
  35677. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35679. * @param analyser The analyser to connect to the engine
  35680. */
  35681. connectToAnalyser(analyser: Analyser): void;
  35682. }
  35683. }
  35684. declare module "babylonjs/Audio/audioSceneComponent" {
  35685. import { Sound } from "babylonjs/Audio/sound";
  35686. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35687. import { Nullable } from "babylonjs/types";
  35688. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35689. import { Scene } from "babylonjs/scene";
  35690. import { AbstractScene } from "babylonjs/abstractScene";
  35691. module "babylonjs/abstractScene" {
  35692. interface AbstractScene {
  35693. /**
  35694. * The list of sounds used in the scene.
  35695. */
  35696. sounds: Nullable<Array<Sound>>;
  35697. }
  35698. }
  35699. module "babylonjs/scene" {
  35700. interface Scene {
  35701. /**
  35702. * @hidden
  35703. * Backing field
  35704. */
  35705. _mainSoundTrack: SoundTrack;
  35706. /**
  35707. * The main sound track played by the scene.
  35708. * It cotains your primary collection of sounds.
  35709. */
  35710. mainSoundTrack: SoundTrack;
  35711. /**
  35712. * The list of sound tracks added to the scene
  35713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35714. */
  35715. soundTracks: Nullable<Array<SoundTrack>>;
  35716. /**
  35717. * Gets a sound using a given name
  35718. * @param name defines the name to search for
  35719. * @return the found sound or null if not found at all.
  35720. */
  35721. getSoundByName(name: string): Nullable<Sound>;
  35722. /**
  35723. * Gets or sets if audio support is enabled
  35724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35725. */
  35726. audioEnabled: boolean;
  35727. /**
  35728. * Gets or sets if audio will be output to headphones
  35729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35730. */
  35731. headphone: boolean;
  35732. }
  35733. }
  35734. /**
  35735. * Defines the sound scene component responsible to manage any sounds
  35736. * in a given scene.
  35737. */
  35738. export class AudioSceneComponent implements ISceneSerializableComponent {
  35739. /**
  35740. * The component name helpfull to identify the component in the list of scene components.
  35741. */
  35742. readonly name: string;
  35743. /**
  35744. * The scene the component belongs to.
  35745. */
  35746. scene: Scene;
  35747. private _audioEnabled;
  35748. /**
  35749. * Gets whether audio is enabled or not.
  35750. * Please use related enable/disable method to switch state.
  35751. */
  35752. readonly audioEnabled: boolean;
  35753. private _headphone;
  35754. /**
  35755. * Gets whether audio is outputing to headphone or not.
  35756. * Please use the according Switch methods to change output.
  35757. */
  35758. readonly headphone: boolean;
  35759. /**
  35760. * Creates a new instance of the component for the given scene
  35761. * @param scene Defines the scene to register the component in
  35762. */
  35763. constructor(scene: Scene);
  35764. /**
  35765. * Registers the component in a given scene
  35766. */
  35767. register(): void;
  35768. /**
  35769. * Rebuilds the elements related to this component in case of
  35770. * context lost for instance.
  35771. */
  35772. rebuild(): void;
  35773. /**
  35774. * Serializes the component data to the specified json object
  35775. * @param serializationObject The object to serialize to
  35776. */
  35777. serialize(serializationObject: any): void;
  35778. /**
  35779. * Adds all the elements from the container to the scene
  35780. * @param container the container holding the elements
  35781. */
  35782. addFromContainer(container: AbstractScene): void;
  35783. /**
  35784. * Removes all the elements in the container from the scene
  35785. * @param container contains the elements to remove
  35786. * @param dispose if the removed element should be disposed (default: false)
  35787. */
  35788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35789. /**
  35790. * Disposes the component and the associated ressources.
  35791. */
  35792. dispose(): void;
  35793. /**
  35794. * Disables audio in the associated scene.
  35795. */
  35796. disableAudio(): void;
  35797. /**
  35798. * Enables audio in the associated scene.
  35799. */
  35800. enableAudio(): void;
  35801. /**
  35802. * Switch audio to headphone output.
  35803. */
  35804. switchAudioModeForHeadphones(): void;
  35805. /**
  35806. * Switch audio to normal speakers.
  35807. */
  35808. switchAudioModeForNormalSpeakers(): void;
  35809. private _afterRender;
  35810. }
  35811. }
  35812. declare module "babylonjs/Audio/weightedsound" {
  35813. import { Sound } from "babylonjs/Audio/sound";
  35814. /**
  35815. * Wraps one or more Sound objects and selects one with random weight for playback.
  35816. */
  35817. export class WeightedSound {
  35818. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35819. loop: boolean;
  35820. private _coneInnerAngle;
  35821. private _coneOuterAngle;
  35822. private _volume;
  35823. /** A Sound is currently playing. */
  35824. isPlaying: boolean;
  35825. /** A Sound is currently paused. */
  35826. isPaused: boolean;
  35827. private _sounds;
  35828. private _weights;
  35829. private _currentIndex?;
  35830. /**
  35831. * Creates a new WeightedSound from the list of sounds given.
  35832. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35833. * @param sounds Array of Sounds that will be selected from.
  35834. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35835. */
  35836. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35837. /**
  35838. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35839. */
  35840. /**
  35841. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35842. */
  35843. directionalConeInnerAngle: number;
  35844. /**
  35845. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35846. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35847. */
  35848. /**
  35849. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35850. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35851. */
  35852. directionalConeOuterAngle: number;
  35853. /**
  35854. * Playback volume.
  35855. */
  35856. /**
  35857. * Playback volume.
  35858. */
  35859. volume: number;
  35860. private _onended;
  35861. /**
  35862. * Suspend playback
  35863. */
  35864. pause(): void;
  35865. /**
  35866. * Stop playback
  35867. */
  35868. stop(): void;
  35869. /**
  35870. * Start playback.
  35871. * @param startOffset Position the clip head at a specific time in seconds.
  35872. */
  35873. play(startOffset?: number): void;
  35874. }
  35875. }
  35876. declare module "babylonjs/Audio/index" {
  35877. export * from "babylonjs/Audio/analyser";
  35878. export * from "babylonjs/Audio/audioEngine";
  35879. export * from "babylonjs/Audio/audioSceneComponent";
  35880. export * from "babylonjs/Audio/sound";
  35881. export * from "babylonjs/Audio/soundTrack";
  35882. export * from "babylonjs/Audio/weightedsound";
  35883. }
  35884. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35885. import { Behavior } from "babylonjs/Behaviors/behavior";
  35886. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35887. import { BackEase } from "babylonjs/Animations/easing";
  35888. /**
  35889. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35890. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35891. */
  35892. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35893. /**
  35894. * Gets the name of the behavior.
  35895. */
  35896. readonly name: string;
  35897. /**
  35898. * The easing function used by animations
  35899. */
  35900. static EasingFunction: BackEase;
  35901. /**
  35902. * The easing mode used by animations
  35903. */
  35904. static EasingMode: number;
  35905. /**
  35906. * The duration of the animation, in milliseconds
  35907. */
  35908. transitionDuration: number;
  35909. /**
  35910. * Length of the distance animated by the transition when lower radius is reached
  35911. */
  35912. lowerRadiusTransitionRange: number;
  35913. /**
  35914. * Length of the distance animated by the transition when upper radius is reached
  35915. */
  35916. upperRadiusTransitionRange: number;
  35917. private _autoTransitionRange;
  35918. /**
  35919. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35920. */
  35921. /**
  35922. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35923. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35924. */
  35925. autoTransitionRange: boolean;
  35926. private _attachedCamera;
  35927. private _onAfterCheckInputsObserver;
  35928. private _onMeshTargetChangedObserver;
  35929. /**
  35930. * Initializes the behavior.
  35931. */
  35932. init(): void;
  35933. /**
  35934. * Attaches the behavior to its arc rotate camera.
  35935. * @param camera Defines the camera to attach the behavior to
  35936. */
  35937. attach(camera: ArcRotateCamera): void;
  35938. /**
  35939. * Detaches the behavior from its current arc rotate camera.
  35940. */
  35941. detach(): void;
  35942. private _radiusIsAnimating;
  35943. private _radiusBounceTransition;
  35944. private _animatables;
  35945. private _cachedWheelPrecision;
  35946. /**
  35947. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35948. * @param radiusLimit The limit to check against.
  35949. * @return Bool to indicate if at limit.
  35950. */
  35951. private _isRadiusAtLimit;
  35952. /**
  35953. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35954. * @param radiusDelta The delta by which to animate to. Can be negative.
  35955. */
  35956. private _applyBoundRadiusAnimation;
  35957. /**
  35958. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35959. */
  35960. protected _clearAnimationLocks(): void;
  35961. /**
  35962. * Stops and removes all animations that have been applied to the camera
  35963. */
  35964. stopAllAnimations(): void;
  35965. }
  35966. }
  35967. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35968. import { Behavior } from "babylonjs/Behaviors/behavior";
  35969. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35970. import { ExponentialEase } from "babylonjs/Animations/easing";
  35971. import { Nullable } from "babylonjs/types";
  35972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35973. import { Vector3 } from "babylonjs/Maths/math";
  35974. /**
  35975. * 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.
  35976. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35977. */
  35978. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35979. /**
  35980. * Gets the name of the behavior.
  35981. */
  35982. readonly name: string;
  35983. private _mode;
  35984. private _radiusScale;
  35985. private _positionScale;
  35986. private _defaultElevation;
  35987. private _elevationReturnTime;
  35988. private _elevationReturnWaitTime;
  35989. private _zoomStopsAnimation;
  35990. private _framingTime;
  35991. /**
  35992. * The easing function used by animations
  35993. */
  35994. static EasingFunction: ExponentialEase;
  35995. /**
  35996. * The easing mode used by animations
  35997. */
  35998. static EasingMode: number;
  35999. /**
  36000. * Sets the current mode used by the behavior
  36001. */
  36002. /**
  36003. * Gets current mode used by the behavior.
  36004. */
  36005. mode: number;
  36006. /**
  36007. * Sets the scale applied to the radius (1 by default)
  36008. */
  36009. /**
  36010. * Gets the scale applied to the radius
  36011. */
  36012. radiusScale: number;
  36013. /**
  36014. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36015. */
  36016. /**
  36017. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36018. */
  36019. positionScale: number;
  36020. /**
  36021. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36022. * behaviour is triggered, in radians.
  36023. */
  36024. /**
  36025. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36026. * behaviour is triggered, in radians.
  36027. */
  36028. defaultElevation: number;
  36029. /**
  36030. * Sets the time (in milliseconds) taken to return to the default beta position.
  36031. * Negative value indicates camera should not return to default.
  36032. */
  36033. /**
  36034. * Gets the time (in milliseconds) taken to return to the default beta position.
  36035. * Negative value indicates camera should not return to default.
  36036. */
  36037. elevationReturnTime: number;
  36038. /**
  36039. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36040. */
  36041. /**
  36042. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36043. */
  36044. elevationReturnWaitTime: number;
  36045. /**
  36046. * Sets the flag that indicates if user zooming should stop animation.
  36047. */
  36048. /**
  36049. * Gets the flag that indicates if user zooming should stop animation.
  36050. */
  36051. zoomStopsAnimation: boolean;
  36052. /**
  36053. * Sets the transition time when framing the mesh, in milliseconds
  36054. */
  36055. /**
  36056. * Gets the transition time when framing the mesh, in milliseconds
  36057. */
  36058. framingTime: number;
  36059. /**
  36060. * Define if the behavior should automatically change the configured
  36061. * camera limits and sensibilities.
  36062. */
  36063. autoCorrectCameraLimitsAndSensibility: boolean;
  36064. private _onPrePointerObservableObserver;
  36065. private _onAfterCheckInputsObserver;
  36066. private _onMeshTargetChangedObserver;
  36067. private _attachedCamera;
  36068. private _isPointerDown;
  36069. private _lastInteractionTime;
  36070. /**
  36071. * Initializes the behavior.
  36072. */
  36073. init(): void;
  36074. /**
  36075. * Attaches the behavior to its arc rotate camera.
  36076. * @param camera Defines the camera to attach the behavior to
  36077. */
  36078. attach(camera: ArcRotateCamera): void;
  36079. /**
  36080. * Detaches the behavior from its current arc rotate camera.
  36081. */
  36082. detach(): void;
  36083. private _animatables;
  36084. private _betaIsAnimating;
  36085. private _betaTransition;
  36086. private _radiusTransition;
  36087. private _vectorTransition;
  36088. /**
  36089. * Targets the given mesh and updates zoom level accordingly.
  36090. * @param mesh The mesh to target.
  36091. * @param radius Optional. If a cached radius position already exists, overrides default.
  36092. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36095. */
  36096. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36097. /**
  36098. * Targets the given mesh with its children and updates zoom level accordingly.
  36099. * @param mesh The mesh to target.
  36100. * @param radius Optional. If a cached radius position already exists, overrides default.
  36101. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36102. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36103. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36104. */
  36105. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36106. /**
  36107. * Targets the given meshes with their children and updates zoom level accordingly.
  36108. * @param meshes The mesh to target.
  36109. * @param radius Optional. If a cached radius position already exists, overrides default.
  36110. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36111. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36112. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36113. */
  36114. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36115. /**
  36116. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36117. * @param minimumWorld Determines the smaller position of the bounding box extend
  36118. * @param maximumWorld Determines the bigger position of the bounding box extend
  36119. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36120. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36121. */
  36122. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36123. /**
  36124. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36125. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36126. * frustum width.
  36127. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36128. * to fully enclose the mesh in the viewing frustum.
  36129. */
  36130. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36131. /**
  36132. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36133. * is automatically returned to its default position (expected to be above ground plane).
  36134. */
  36135. private _maintainCameraAboveGround;
  36136. /**
  36137. * Returns the frustum slope based on the canvas ratio and camera FOV
  36138. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36139. */
  36140. private _getFrustumSlope;
  36141. /**
  36142. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36143. */
  36144. private _clearAnimationLocks;
  36145. /**
  36146. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36147. */
  36148. private _applyUserInteraction;
  36149. /**
  36150. * Stops and removes all animations that have been applied to the camera
  36151. */
  36152. stopAllAnimations(): void;
  36153. /**
  36154. * Gets a value indicating if the user is moving the camera
  36155. */
  36156. readonly isUserIsMoving: boolean;
  36157. /**
  36158. * The camera can move all the way towards the mesh.
  36159. */
  36160. static IgnoreBoundsSizeMode: number;
  36161. /**
  36162. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36163. */
  36164. static FitFrustumSidesMode: number;
  36165. }
  36166. }
  36167. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36168. import { Nullable } from "babylonjs/types";
  36169. import { Camera } from "babylonjs/Cameras/camera";
  36170. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36171. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36172. /**
  36173. * Base class for Camera Pointer Inputs.
  36174. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36175. * for example usage.
  36176. */
  36177. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36178. /**
  36179. * Defines the camera the input is attached to.
  36180. */
  36181. abstract camera: Camera;
  36182. /**
  36183. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36184. */
  36185. protected _altKey: boolean;
  36186. protected _ctrlKey: boolean;
  36187. protected _metaKey: boolean;
  36188. protected _shiftKey: boolean;
  36189. /**
  36190. * Which mouse buttons were pressed at time of last mouse event.
  36191. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36192. */
  36193. protected _buttonsPressed: number;
  36194. /**
  36195. * Defines the buttons associated with the input to handle camera move.
  36196. */
  36197. buttons: number[];
  36198. /**
  36199. * Attach the input controls to a specific dom element to get the input from.
  36200. * @param element Defines the element the controls should be listened from
  36201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36202. */
  36203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36204. /**
  36205. * Detach the current controls from the specified dom element.
  36206. * @param element Defines the element to stop listening the inputs from
  36207. */
  36208. detachControl(element: Nullable<HTMLElement>): void;
  36209. /**
  36210. * Gets the class name of the current input.
  36211. * @returns the class name
  36212. */
  36213. getClassName(): string;
  36214. /**
  36215. * Get the friendly name associated with the input class.
  36216. * @returns the input friendly name
  36217. */
  36218. getSimpleName(): string;
  36219. /**
  36220. * Called on pointer POINTERDOUBLETAP event.
  36221. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36222. */
  36223. protected onDoubleTap(type: string): void;
  36224. /**
  36225. * Called on pointer POINTERMOVE event if only a single touch is active.
  36226. * Override this method to provide functionality.
  36227. */
  36228. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36229. /**
  36230. * Called on pointer POINTERMOVE event if multiple touches are active.
  36231. * Override this method to provide functionality.
  36232. */
  36233. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36234. /**
  36235. * Called on JS contextmenu event.
  36236. * Override this method to provide functionality.
  36237. */
  36238. protected onContextMenu(evt: PointerEvent): void;
  36239. /**
  36240. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36241. * press.
  36242. * Override this method to provide functionality.
  36243. */
  36244. protected onButtonDown(evt: PointerEvent): void;
  36245. /**
  36246. * Called each time a new POINTERUP event occurs. Ie, for each button
  36247. * release.
  36248. * Override this method to provide functionality.
  36249. */
  36250. protected onButtonUp(evt: PointerEvent): void;
  36251. /**
  36252. * Called when window becomes inactive.
  36253. * Override this method to provide functionality.
  36254. */
  36255. protected onLostFocus(): void;
  36256. private _pointerInput;
  36257. private _observer;
  36258. private _onLostFocus;
  36259. private pointA;
  36260. private pointB;
  36261. }
  36262. }
  36263. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36264. import { Nullable } from "babylonjs/types";
  36265. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36266. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36267. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36268. /**
  36269. * Manage the pointers inputs to control an arc rotate camera.
  36270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36271. */
  36272. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36273. /**
  36274. * Defines the camera the input is attached to.
  36275. */
  36276. camera: ArcRotateCamera;
  36277. /**
  36278. * Gets the class name of the current input.
  36279. * @returns the class name
  36280. */
  36281. getClassName(): string;
  36282. /**
  36283. * Defines the buttons associated with the input to handle camera move.
  36284. */
  36285. buttons: number[];
  36286. /**
  36287. * Defines the pointer angular sensibility along the X axis or how fast is
  36288. * the camera rotating.
  36289. */
  36290. angularSensibilityX: number;
  36291. /**
  36292. * Defines the pointer angular sensibility along the Y axis or how fast is
  36293. * the camera rotating.
  36294. */
  36295. angularSensibilityY: number;
  36296. /**
  36297. * Defines the pointer pinch precision or how fast is the camera zooming.
  36298. */
  36299. pinchPrecision: number;
  36300. /**
  36301. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36302. * from 0.
  36303. * It defines the percentage of current camera.radius to use as delta when
  36304. * pinch zoom is used.
  36305. */
  36306. pinchDeltaPercentage: number;
  36307. /**
  36308. * Defines the pointer panning sensibility or how fast is the camera moving.
  36309. */
  36310. panningSensibility: number;
  36311. /**
  36312. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36313. */
  36314. multiTouchPanning: boolean;
  36315. /**
  36316. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36317. * zoom (pinch) through multitouch.
  36318. */
  36319. multiTouchPanAndZoom: boolean;
  36320. /**
  36321. * Revers pinch action direction.
  36322. */
  36323. pinchInwards: boolean;
  36324. private _isPanClick;
  36325. private _twoFingerActivityCount;
  36326. private _isPinching;
  36327. /**
  36328. * Called on pointer POINTERMOVE event if only a single touch is active.
  36329. */
  36330. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36331. /**
  36332. * Called on pointer POINTERDOUBLETAP event.
  36333. */
  36334. protected onDoubleTap(type: string): void;
  36335. /**
  36336. * Called on pointer POINTERMOVE event if multiple touches are active.
  36337. */
  36338. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36339. /**
  36340. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36341. * press.
  36342. */
  36343. protected onButtonDown(evt: PointerEvent): void;
  36344. /**
  36345. * Called each time a new POINTERUP event occurs. Ie, for each button
  36346. * release.
  36347. */
  36348. protected onButtonUp(evt: PointerEvent): void;
  36349. /**
  36350. * Called when window becomes inactive.
  36351. */
  36352. protected onLostFocus(): void;
  36353. }
  36354. }
  36355. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36356. import { Nullable } from "babylonjs/types";
  36357. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36358. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36359. /**
  36360. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36362. */
  36363. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36364. /**
  36365. * Defines the camera the input is attached to.
  36366. */
  36367. camera: ArcRotateCamera;
  36368. /**
  36369. * Defines the list of key codes associated with the up action (increase alpha)
  36370. */
  36371. keysUp: number[];
  36372. /**
  36373. * Defines the list of key codes associated with the down action (decrease alpha)
  36374. */
  36375. keysDown: number[];
  36376. /**
  36377. * Defines the list of key codes associated with the left action (increase beta)
  36378. */
  36379. keysLeft: number[];
  36380. /**
  36381. * Defines the list of key codes associated with the right action (decrease beta)
  36382. */
  36383. keysRight: number[];
  36384. /**
  36385. * Defines the list of key codes associated with the reset action.
  36386. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36387. */
  36388. keysReset: number[];
  36389. /**
  36390. * Defines the panning sensibility of the inputs.
  36391. * (How fast is the camera paning)
  36392. */
  36393. panningSensibility: number;
  36394. /**
  36395. * Defines the zooming sensibility of the inputs.
  36396. * (How fast is the camera zooming)
  36397. */
  36398. zoomingSensibility: number;
  36399. /**
  36400. * Defines wether maintaining the alt key down switch the movement mode from
  36401. * orientation to zoom.
  36402. */
  36403. useAltToZoom: boolean;
  36404. /**
  36405. * Rotation speed of the camera
  36406. */
  36407. angularSpeed: number;
  36408. private _keys;
  36409. private _ctrlPressed;
  36410. private _altPressed;
  36411. private _onCanvasBlurObserver;
  36412. private _onKeyboardObserver;
  36413. private _engine;
  36414. private _scene;
  36415. /**
  36416. * Attach the input controls to a specific dom element to get the input from.
  36417. * @param element Defines the element the controls should be listened from
  36418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36419. */
  36420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36421. /**
  36422. * Detach the current controls from the specified dom element.
  36423. * @param element Defines the element to stop listening the inputs from
  36424. */
  36425. detachControl(element: Nullable<HTMLElement>): void;
  36426. /**
  36427. * Update the current camera state depending on the inputs that have been used this frame.
  36428. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36429. */
  36430. checkInputs(): void;
  36431. /**
  36432. * Gets the class name of the current intput.
  36433. * @returns the class name
  36434. */
  36435. getClassName(): string;
  36436. /**
  36437. * Get the friendly name associated with the input class.
  36438. * @returns the input friendly name
  36439. */
  36440. getSimpleName(): string;
  36441. }
  36442. }
  36443. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36444. import { Nullable } from "babylonjs/types";
  36445. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36446. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36447. /**
  36448. * Manage the mouse wheel inputs to control an arc rotate camera.
  36449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36450. */
  36451. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36452. /**
  36453. * Defines the camera the input is attached to.
  36454. */
  36455. camera: ArcRotateCamera;
  36456. /**
  36457. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36458. */
  36459. wheelPrecision: number;
  36460. /**
  36461. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36462. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36463. */
  36464. wheelDeltaPercentage: number;
  36465. private _wheel;
  36466. private _observer;
  36467. private computeDeltaFromMouseWheelLegacyEvent;
  36468. /**
  36469. * Attach the input controls to a specific dom element to get the input from.
  36470. * @param element Defines the element the controls should be listened from
  36471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36472. */
  36473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36474. /**
  36475. * Detach the current controls from the specified dom element.
  36476. * @param element Defines the element to stop listening the inputs from
  36477. */
  36478. detachControl(element: Nullable<HTMLElement>): void;
  36479. /**
  36480. * Gets the class name of the current intput.
  36481. * @returns the class name
  36482. */
  36483. getClassName(): string;
  36484. /**
  36485. * Get the friendly name associated with the input class.
  36486. * @returns the input friendly name
  36487. */
  36488. getSimpleName(): string;
  36489. }
  36490. }
  36491. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36492. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36493. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36494. /**
  36495. * Default Inputs manager for the ArcRotateCamera.
  36496. * It groups all the default supported inputs for ease of use.
  36497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36498. */
  36499. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36500. /**
  36501. * Instantiates a new ArcRotateCameraInputsManager.
  36502. * @param camera Defines the camera the inputs belong to
  36503. */
  36504. constructor(camera: ArcRotateCamera);
  36505. /**
  36506. * Add mouse wheel input support to the input manager.
  36507. * @returns the current input manager
  36508. */
  36509. addMouseWheel(): ArcRotateCameraInputsManager;
  36510. /**
  36511. * Add pointers input support to the input manager.
  36512. * @returns the current input manager
  36513. */
  36514. addPointers(): ArcRotateCameraInputsManager;
  36515. /**
  36516. * Add keyboard input support to the input manager.
  36517. * @returns the current input manager
  36518. */
  36519. addKeyboard(): ArcRotateCameraInputsManager;
  36520. }
  36521. }
  36522. declare module "babylonjs/Cameras/arcRotateCamera" {
  36523. import { Observable } from "babylonjs/Misc/observable";
  36524. import { Nullable } from "babylonjs/types";
  36525. import { Scene } from "babylonjs/scene";
  36526. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36528. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36529. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36530. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36531. import { Camera } from "babylonjs/Cameras/camera";
  36532. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36533. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36534. import { Collider } from "babylonjs/Collisions/collider";
  36535. /**
  36536. * This represents an orbital type of camera.
  36537. *
  36538. * 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.
  36539. * 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.
  36540. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36541. */
  36542. export class ArcRotateCamera extends TargetCamera {
  36543. /**
  36544. * Defines the rotation angle of the camera along the longitudinal axis.
  36545. */
  36546. alpha: number;
  36547. /**
  36548. * Defines the rotation angle of the camera along the latitudinal axis.
  36549. */
  36550. beta: number;
  36551. /**
  36552. * Defines the radius of the camera from it s target point.
  36553. */
  36554. radius: number;
  36555. protected _target: Vector3;
  36556. protected _targetHost: Nullable<AbstractMesh>;
  36557. /**
  36558. * Defines the target point of the camera.
  36559. * The camera looks towards it form the radius distance.
  36560. */
  36561. target: Vector3;
  36562. /**
  36563. * Define the current local position of the camera in the scene
  36564. */
  36565. position: Vector3;
  36566. protected _upVector: Vector3;
  36567. protected _upToYMatrix: Matrix;
  36568. protected _YToUpMatrix: Matrix;
  36569. /**
  36570. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36571. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36572. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36573. */
  36574. upVector: Vector3;
  36575. /**
  36576. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36577. */
  36578. setMatUp(): void;
  36579. /**
  36580. * Current inertia value on the longitudinal axis.
  36581. * The bigger this number the longer it will take for the camera to stop.
  36582. */
  36583. inertialAlphaOffset: number;
  36584. /**
  36585. * Current inertia value on the latitudinal axis.
  36586. * The bigger this number the longer it will take for the camera to stop.
  36587. */
  36588. inertialBetaOffset: number;
  36589. /**
  36590. * Current inertia value on the radius axis.
  36591. * The bigger this number the longer it will take for the camera to stop.
  36592. */
  36593. inertialRadiusOffset: number;
  36594. /**
  36595. * Minimum allowed angle on the longitudinal axis.
  36596. * This can help limiting how the Camera is able to move in the scene.
  36597. */
  36598. lowerAlphaLimit: Nullable<number>;
  36599. /**
  36600. * Maximum allowed angle on the longitudinal axis.
  36601. * This can help limiting how the Camera is able to move in the scene.
  36602. */
  36603. upperAlphaLimit: Nullable<number>;
  36604. /**
  36605. * Minimum allowed angle on the latitudinal axis.
  36606. * This can help limiting how the Camera is able to move in the scene.
  36607. */
  36608. lowerBetaLimit: number;
  36609. /**
  36610. * Maximum allowed angle on the latitudinal axis.
  36611. * This can help limiting how the Camera is able to move in the scene.
  36612. */
  36613. upperBetaLimit: number;
  36614. /**
  36615. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36616. * This can help limiting how the Camera is able to move in the scene.
  36617. */
  36618. lowerRadiusLimit: Nullable<number>;
  36619. /**
  36620. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36621. * This can help limiting how the Camera is able to move in the scene.
  36622. */
  36623. upperRadiusLimit: Nullable<number>;
  36624. /**
  36625. * Defines the current inertia value used during panning of the camera along the X axis.
  36626. */
  36627. inertialPanningX: number;
  36628. /**
  36629. * Defines the current inertia value used during panning of the camera along the Y axis.
  36630. */
  36631. inertialPanningY: number;
  36632. /**
  36633. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36634. * Basically if your fingers moves away from more than this distance you will be considered
  36635. * in pinch mode.
  36636. */
  36637. pinchToPanMaxDistance: number;
  36638. /**
  36639. * Defines the maximum distance the camera can pan.
  36640. * This could help keeping the cammera always in your scene.
  36641. */
  36642. panningDistanceLimit: Nullable<number>;
  36643. /**
  36644. * Defines the target of the camera before paning.
  36645. */
  36646. panningOriginTarget: Vector3;
  36647. /**
  36648. * Defines the value of the inertia used during panning.
  36649. * 0 would mean stop inertia and one would mean no decelleration at all.
  36650. */
  36651. panningInertia: number;
  36652. /**
  36653. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36654. */
  36655. angularSensibilityX: number;
  36656. /**
  36657. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36658. */
  36659. angularSensibilityY: number;
  36660. /**
  36661. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36662. */
  36663. pinchPrecision: number;
  36664. /**
  36665. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36666. * It will be used instead of pinchDeltaPrecision if different from 0.
  36667. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36668. */
  36669. pinchDeltaPercentage: number;
  36670. /**
  36671. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36672. */
  36673. panningSensibility: number;
  36674. /**
  36675. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36676. */
  36677. keysUp: number[];
  36678. /**
  36679. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36680. */
  36681. keysDown: number[];
  36682. /**
  36683. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36684. */
  36685. keysLeft: number[];
  36686. /**
  36687. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36688. */
  36689. keysRight: number[];
  36690. /**
  36691. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36692. */
  36693. wheelPrecision: number;
  36694. /**
  36695. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36696. * It will be used instead of pinchDeltaPrecision if different from 0.
  36697. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36698. */
  36699. wheelDeltaPercentage: number;
  36700. /**
  36701. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36702. */
  36703. zoomOnFactor: number;
  36704. /**
  36705. * Defines a screen offset for the camera position.
  36706. */
  36707. targetScreenOffset: Vector2;
  36708. /**
  36709. * Allows the camera to be completely reversed.
  36710. * If false the camera can not arrive upside down.
  36711. */
  36712. allowUpsideDown: boolean;
  36713. /**
  36714. * Define if double tap/click is used to restore the previously saved state of the camera.
  36715. */
  36716. useInputToRestoreState: boolean;
  36717. /** @hidden */
  36718. _viewMatrix: Matrix;
  36719. /** @hidden */
  36720. _useCtrlForPanning: boolean;
  36721. /** @hidden */
  36722. _panningMouseButton: number;
  36723. /**
  36724. * Defines the input associated to the camera.
  36725. */
  36726. inputs: ArcRotateCameraInputsManager;
  36727. /** @hidden */
  36728. _reset: () => void;
  36729. /**
  36730. * Defines the allowed panning axis.
  36731. */
  36732. panningAxis: Vector3;
  36733. protected _localDirection: Vector3;
  36734. protected _transformedDirection: Vector3;
  36735. private _bouncingBehavior;
  36736. /**
  36737. * Gets the bouncing behavior of the camera if it has been enabled.
  36738. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36739. */
  36740. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36741. /**
  36742. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36744. */
  36745. useBouncingBehavior: boolean;
  36746. private _framingBehavior;
  36747. /**
  36748. * Gets the framing behavior of the camera if it has been enabled.
  36749. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36750. */
  36751. readonly framingBehavior: Nullable<FramingBehavior>;
  36752. /**
  36753. * Defines if the framing behavior of the camera is enabled on the camera.
  36754. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36755. */
  36756. useFramingBehavior: boolean;
  36757. private _autoRotationBehavior;
  36758. /**
  36759. * Gets the auto rotation behavior of the camera if it has been enabled.
  36760. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36761. */
  36762. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36763. /**
  36764. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36765. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36766. */
  36767. useAutoRotationBehavior: boolean;
  36768. /**
  36769. * Observable triggered when the mesh target has been changed on the camera.
  36770. */
  36771. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36772. /**
  36773. * Event raised when the camera is colliding with a mesh.
  36774. */
  36775. onCollide: (collidedMesh: AbstractMesh) => void;
  36776. /**
  36777. * Defines whether the camera should check collision with the objects oh the scene.
  36778. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36779. */
  36780. checkCollisions: boolean;
  36781. /**
  36782. * Defines the collision radius of the camera.
  36783. * This simulates a sphere around the camera.
  36784. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36785. */
  36786. collisionRadius: Vector3;
  36787. protected _collider: Collider;
  36788. protected _previousPosition: Vector3;
  36789. protected _collisionVelocity: Vector3;
  36790. protected _newPosition: Vector3;
  36791. protected _previousAlpha: number;
  36792. protected _previousBeta: number;
  36793. protected _previousRadius: number;
  36794. protected _collisionTriggered: boolean;
  36795. protected _targetBoundingCenter: Nullable<Vector3>;
  36796. private _computationVector;
  36797. /**
  36798. * Instantiates a new ArcRotateCamera in a given scene
  36799. * @param name Defines the name of the camera
  36800. * @param alpha Defines the camera rotation along the logitudinal axis
  36801. * @param beta Defines the camera rotation along the latitudinal axis
  36802. * @param radius Defines the camera distance from its target
  36803. * @param target Defines the camera target
  36804. * @param scene Defines the scene the camera belongs to
  36805. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36806. */
  36807. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36808. /** @hidden */
  36809. _initCache(): void;
  36810. /** @hidden */
  36811. _updateCache(ignoreParentClass?: boolean): void;
  36812. protected _getTargetPosition(): Vector3;
  36813. private _storedAlpha;
  36814. private _storedBeta;
  36815. private _storedRadius;
  36816. private _storedTarget;
  36817. /**
  36818. * Stores the current state of the camera (alpha, beta, radius and target)
  36819. * @returns the camera itself
  36820. */
  36821. storeState(): Camera;
  36822. /**
  36823. * @hidden
  36824. * Restored camera state. You must call storeState() first
  36825. */
  36826. _restoreStateValues(): boolean;
  36827. /** @hidden */
  36828. _isSynchronizedViewMatrix(): boolean;
  36829. /**
  36830. * Attached controls to the current camera.
  36831. * @param element Defines the element the controls should be listened from
  36832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36833. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36834. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36835. */
  36836. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36837. /**
  36838. * Detach the current controls from the camera.
  36839. * The camera will stop reacting to inputs.
  36840. * @param element Defines the element to stop listening the inputs from
  36841. */
  36842. detachControl(element: HTMLElement): void;
  36843. /** @hidden */
  36844. _checkInputs(): void;
  36845. protected _checkLimits(): void;
  36846. /**
  36847. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36848. */
  36849. rebuildAnglesAndRadius(): void;
  36850. /**
  36851. * Use a position to define the current camera related information like aplha, beta and radius
  36852. * @param position Defines the position to set the camera at
  36853. */
  36854. setPosition(position: Vector3): void;
  36855. /**
  36856. * Defines the target the camera should look at.
  36857. * This will automatically adapt alpha beta and radius to fit within the new target.
  36858. * @param target Defines the new target as a Vector or a mesh
  36859. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36860. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36861. */
  36862. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36863. /** @hidden */
  36864. _getViewMatrix(): Matrix;
  36865. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36866. /**
  36867. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36868. * @param meshes Defines the mesh to zoom on
  36869. * @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)
  36870. */
  36871. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36872. /**
  36873. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36874. * The target will be changed but the radius
  36875. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36876. * @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)
  36877. */
  36878. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36879. min: Vector3;
  36880. max: Vector3;
  36881. distance: number;
  36882. }, doNotUpdateMaxZ?: boolean): void;
  36883. /**
  36884. * @override
  36885. * Override Camera.createRigCamera
  36886. */
  36887. createRigCamera(name: string, cameraIndex: number): Camera;
  36888. /**
  36889. * @hidden
  36890. * @override
  36891. * Override Camera._updateRigCameras
  36892. */
  36893. _updateRigCameras(): void;
  36894. /**
  36895. * Destroy the camera and release the current resources hold by it.
  36896. */
  36897. dispose(): void;
  36898. /**
  36899. * Gets the current object class name.
  36900. * @return the class name
  36901. */
  36902. getClassName(): string;
  36903. }
  36904. }
  36905. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36906. import { Behavior } from "babylonjs/Behaviors/behavior";
  36907. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36908. /**
  36909. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36910. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36911. */
  36912. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36913. /**
  36914. * Gets the name of the behavior.
  36915. */
  36916. readonly name: string;
  36917. private _zoomStopsAnimation;
  36918. private _idleRotationSpeed;
  36919. private _idleRotationWaitTime;
  36920. private _idleRotationSpinupTime;
  36921. /**
  36922. * Sets the flag that indicates if user zooming should stop animation.
  36923. */
  36924. /**
  36925. * Gets the flag that indicates if user zooming should stop animation.
  36926. */
  36927. zoomStopsAnimation: boolean;
  36928. /**
  36929. * Sets the default speed at which the camera rotates around the model.
  36930. */
  36931. /**
  36932. * Gets the default speed at which the camera rotates around the model.
  36933. */
  36934. idleRotationSpeed: number;
  36935. /**
  36936. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36937. */
  36938. /**
  36939. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36940. */
  36941. idleRotationWaitTime: number;
  36942. /**
  36943. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36944. */
  36945. /**
  36946. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36947. */
  36948. idleRotationSpinupTime: number;
  36949. /**
  36950. * Gets a value indicating if the camera is currently rotating because of this behavior
  36951. */
  36952. readonly rotationInProgress: boolean;
  36953. private _onPrePointerObservableObserver;
  36954. private _onAfterCheckInputsObserver;
  36955. private _attachedCamera;
  36956. private _isPointerDown;
  36957. private _lastFrameTime;
  36958. private _lastInteractionTime;
  36959. private _cameraRotationSpeed;
  36960. /**
  36961. * Initializes the behavior.
  36962. */
  36963. init(): void;
  36964. /**
  36965. * Attaches the behavior to its arc rotate camera.
  36966. * @param camera Defines the camera to attach the behavior to
  36967. */
  36968. attach(camera: ArcRotateCamera): void;
  36969. /**
  36970. * Detaches the behavior from its current arc rotate camera.
  36971. */
  36972. detach(): void;
  36973. /**
  36974. * Returns true if user is scrolling.
  36975. * @return true if user is scrolling.
  36976. */
  36977. private _userIsZooming;
  36978. private _lastFrameRadius;
  36979. private _shouldAnimationStopForInteraction;
  36980. /**
  36981. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36982. */
  36983. private _applyUserInteraction;
  36984. private _userIsMoving;
  36985. }
  36986. }
  36987. declare module "babylonjs/Behaviors/Cameras/index" {
  36988. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36989. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36990. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36991. }
  36992. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36993. import { Mesh } from "babylonjs/Meshes/mesh";
  36994. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36995. import { Behavior } from "babylonjs/Behaviors/behavior";
  36996. /**
  36997. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36998. */
  36999. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37000. private ui;
  37001. /**
  37002. * The name of the behavior
  37003. */
  37004. name: string;
  37005. /**
  37006. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37007. */
  37008. distanceAwayFromFace: number;
  37009. /**
  37010. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37011. */
  37012. distanceAwayFromBottomOfFace: number;
  37013. private _faceVectors;
  37014. private _target;
  37015. private _scene;
  37016. private _onRenderObserver;
  37017. private _tmpMatrix;
  37018. private _tmpVector;
  37019. /**
  37020. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37021. * @param ui The transform node that should be attched to the mesh
  37022. */
  37023. constructor(ui: TransformNode);
  37024. /**
  37025. * Initializes the behavior
  37026. */
  37027. init(): void;
  37028. private _closestFace;
  37029. private _zeroVector;
  37030. private _lookAtTmpMatrix;
  37031. private _lookAtToRef;
  37032. /**
  37033. * Attaches the AttachToBoxBehavior to the passed in mesh
  37034. * @param target The mesh that the specified node will be attached to
  37035. */
  37036. attach(target: Mesh): void;
  37037. /**
  37038. * Detaches the behavior from the mesh
  37039. */
  37040. detach(): void;
  37041. }
  37042. }
  37043. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37044. import { Behavior } from "babylonjs/Behaviors/behavior";
  37045. import { Mesh } from "babylonjs/Meshes/mesh";
  37046. /**
  37047. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37048. */
  37049. export class FadeInOutBehavior implements Behavior<Mesh> {
  37050. /**
  37051. * Time in milliseconds to delay before fading in (Default: 0)
  37052. */
  37053. delay: number;
  37054. /**
  37055. * Time in milliseconds for the mesh to fade in (Default: 300)
  37056. */
  37057. fadeInTime: number;
  37058. private _millisecondsPerFrame;
  37059. private _hovered;
  37060. private _hoverValue;
  37061. private _ownerNode;
  37062. /**
  37063. * Instatiates the FadeInOutBehavior
  37064. */
  37065. constructor();
  37066. /**
  37067. * The name of the behavior
  37068. */
  37069. readonly name: string;
  37070. /**
  37071. * Initializes the behavior
  37072. */
  37073. init(): void;
  37074. /**
  37075. * Attaches the fade behavior on the passed in mesh
  37076. * @param ownerNode The mesh that will be faded in/out once attached
  37077. */
  37078. attach(ownerNode: Mesh): void;
  37079. /**
  37080. * Detaches the behavior from the mesh
  37081. */
  37082. detach(): void;
  37083. /**
  37084. * Triggers the mesh to begin fading in or out
  37085. * @param value if the object should fade in or out (true to fade in)
  37086. */
  37087. fadeIn(value: boolean): void;
  37088. private _update;
  37089. private _setAllVisibility;
  37090. }
  37091. }
  37092. declare module "babylonjs/Misc/pivotTools" {
  37093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37094. /**
  37095. * Class containing a set of static utilities functions for managing Pivots
  37096. * @hidden
  37097. */
  37098. export class PivotTools {
  37099. private static _PivotCached;
  37100. private static _OldPivotPoint;
  37101. private static _PivotTranslation;
  37102. private static _PivotTmpVector;
  37103. /** @hidden */
  37104. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37105. /** @hidden */
  37106. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37107. }
  37108. }
  37109. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37110. import { Scene } from "babylonjs/scene";
  37111. import { Vector4, Plane } from "babylonjs/Maths/math";
  37112. import { Mesh } from "babylonjs/Meshes/mesh";
  37113. import { Nullable } from "babylonjs/types";
  37114. /**
  37115. * Class containing static functions to help procedurally build meshes
  37116. */
  37117. export class PlaneBuilder {
  37118. /**
  37119. * Creates a plane mesh
  37120. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37121. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37122. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37126. * @param name defines the name of the mesh
  37127. * @param options defines the options used to create the mesh
  37128. * @param scene defines the hosting scene
  37129. * @returns the plane mesh
  37130. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37131. */
  37132. static CreatePlane(name: string, options: {
  37133. size?: number;
  37134. width?: number;
  37135. height?: number;
  37136. sideOrientation?: number;
  37137. frontUVs?: Vector4;
  37138. backUVs?: Vector4;
  37139. updatable?: boolean;
  37140. sourcePlane?: Plane;
  37141. }, scene?: Nullable<Scene>): Mesh;
  37142. }
  37143. }
  37144. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37145. import { Behavior } from "babylonjs/Behaviors/behavior";
  37146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37147. import { Observable } from "babylonjs/Misc/observable";
  37148. import { Vector3 } from "babylonjs/Maths/math";
  37149. import { Ray } from "babylonjs/Culling/ray";
  37150. import "babylonjs/Meshes/Builders/planeBuilder";
  37151. /**
  37152. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37153. */
  37154. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37155. private static _AnyMouseID;
  37156. /**
  37157. * Abstract mesh the behavior is set on
  37158. */
  37159. attachedNode: AbstractMesh;
  37160. private _dragPlane;
  37161. private _scene;
  37162. private _pointerObserver;
  37163. private _beforeRenderObserver;
  37164. private static _planeScene;
  37165. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37166. /**
  37167. * 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)
  37168. */
  37169. maxDragAngle: number;
  37170. /**
  37171. * @hidden
  37172. */
  37173. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37174. /**
  37175. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37176. */
  37177. currentDraggingPointerID: number;
  37178. /**
  37179. * The last position where the pointer hit the drag plane in world space
  37180. */
  37181. lastDragPosition: Vector3;
  37182. /**
  37183. * If the behavior is currently in a dragging state
  37184. */
  37185. dragging: boolean;
  37186. /**
  37187. * 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)
  37188. */
  37189. dragDeltaRatio: number;
  37190. /**
  37191. * If the drag plane orientation should be updated during the dragging (Default: true)
  37192. */
  37193. updateDragPlane: boolean;
  37194. private _debugMode;
  37195. private _moving;
  37196. /**
  37197. * Fires each time the attached mesh is dragged with the pointer
  37198. * * delta between last drag position and current drag position in world space
  37199. * * dragDistance along the drag axis
  37200. * * dragPlaneNormal normal of the current drag plane used during the drag
  37201. * * dragPlanePoint in world space where the drag intersects the drag plane
  37202. */
  37203. onDragObservable: Observable<{
  37204. delta: Vector3;
  37205. dragPlanePoint: Vector3;
  37206. dragPlaneNormal: Vector3;
  37207. dragDistance: number;
  37208. pointerId: number;
  37209. }>;
  37210. /**
  37211. * Fires each time a drag begins (eg. mouse down on mesh)
  37212. */
  37213. onDragStartObservable: Observable<{
  37214. dragPlanePoint: Vector3;
  37215. pointerId: number;
  37216. }>;
  37217. /**
  37218. * Fires each time a drag ends (eg. mouse release after drag)
  37219. */
  37220. onDragEndObservable: Observable<{
  37221. dragPlanePoint: Vector3;
  37222. pointerId: number;
  37223. }>;
  37224. /**
  37225. * If the attached mesh should be moved when dragged
  37226. */
  37227. moveAttached: boolean;
  37228. /**
  37229. * If the drag behavior will react to drag events (Default: true)
  37230. */
  37231. enabled: boolean;
  37232. /**
  37233. * If camera controls should be detached during the drag
  37234. */
  37235. detachCameraControls: boolean;
  37236. /**
  37237. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37238. */
  37239. useObjectOrienationForDragging: boolean;
  37240. private _options;
  37241. /**
  37242. * Creates a pointer drag behavior that can be attached to a mesh
  37243. * @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)
  37244. */
  37245. constructor(options?: {
  37246. dragAxis?: Vector3;
  37247. dragPlaneNormal?: Vector3;
  37248. });
  37249. /**
  37250. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37251. */
  37252. validateDrag: (targetPosition: Vector3) => boolean;
  37253. /**
  37254. * The name of the behavior
  37255. */
  37256. readonly name: string;
  37257. /**
  37258. * Initializes the behavior
  37259. */
  37260. init(): void;
  37261. private _tmpVector;
  37262. private _alternatePickedPoint;
  37263. private _worldDragAxis;
  37264. private _targetPosition;
  37265. private _attachedElement;
  37266. /**
  37267. * Attaches the drag behavior the passed in mesh
  37268. * @param ownerNode The mesh that will be dragged around once attached
  37269. */
  37270. attach(ownerNode: AbstractMesh): void;
  37271. /**
  37272. * Force relase the drag action by code.
  37273. */
  37274. releaseDrag(): void;
  37275. private _startDragRay;
  37276. private _lastPointerRay;
  37277. /**
  37278. * Simulates the start of a pointer drag event on the behavior
  37279. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37280. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37281. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37282. */
  37283. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37284. private _startDrag;
  37285. private _dragDelta;
  37286. private _moveDrag;
  37287. private _pickWithRayOnDragPlane;
  37288. private _pointA;
  37289. private _pointB;
  37290. private _pointC;
  37291. private _lineA;
  37292. private _lineB;
  37293. private _localAxis;
  37294. private _lookAt;
  37295. private _updateDragPlanePosition;
  37296. /**
  37297. * Detaches the behavior from the mesh
  37298. */
  37299. detach(): void;
  37300. }
  37301. }
  37302. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37303. import { Mesh } from "babylonjs/Meshes/mesh";
  37304. import { Behavior } from "babylonjs/Behaviors/behavior";
  37305. /**
  37306. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37307. */
  37308. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37309. private _dragBehaviorA;
  37310. private _dragBehaviorB;
  37311. private _startDistance;
  37312. private _initialScale;
  37313. private _targetScale;
  37314. private _ownerNode;
  37315. private _sceneRenderObserver;
  37316. /**
  37317. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37318. */
  37319. constructor();
  37320. /**
  37321. * The name of the behavior
  37322. */
  37323. readonly name: string;
  37324. /**
  37325. * Initializes the behavior
  37326. */
  37327. init(): void;
  37328. private _getCurrentDistance;
  37329. /**
  37330. * Attaches the scale behavior the passed in mesh
  37331. * @param ownerNode The mesh that will be scaled around once attached
  37332. */
  37333. attach(ownerNode: Mesh): void;
  37334. /**
  37335. * Detaches the behavior from the mesh
  37336. */
  37337. detach(): void;
  37338. }
  37339. }
  37340. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37341. import { Behavior } from "babylonjs/Behaviors/behavior";
  37342. import { Mesh } from "babylonjs/Meshes/mesh";
  37343. import { Observable } from "babylonjs/Misc/observable";
  37344. /**
  37345. * 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
  37346. */
  37347. export class SixDofDragBehavior implements Behavior<Mesh> {
  37348. private static _virtualScene;
  37349. private _ownerNode;
  37350. private _sceneRenderObserver;
  37351. private _scene;
  37352. private _targetPosition;
  37353. private _virtualOriginMesh;
  37354. private _virtualDragMesh;
  37355. private _pointerObserver;
  37356. private _moving;
  37357. private _startingOrientation;
  37358. /**
  37359. * 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)
  37360. */
  37361. private zDragFactor;
  37362. /**
  37363. * If the object should rotate to face the drag origin
  37364. */
  37365. rotateDraggedObject: boolean;
  37366. /**
  37367. * If the behavior is currently in a dragging state
  37368. */
  37369. dragging: boolean;
  37370. /**
  37371. * 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)
  37372. */
  37373. dragDeltaRatio: number;
  37374. /**
  37375. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37376. */
  37377. currentDraggingPointerID: number;
  37378. /**
  37379. * If camera controls should be detached during the drag
  37380. */
  37381. detachCameraControls: boolean;
  37382. /**
  37383. * Fires each time a drag starts
  37384. */
  37385. onDragStartObservable: Observable<{}>;
  37386. /**
  37387. * Fires each time a drag ends (eg. mouse release after drag)
  37388. */
  37389. onDragEndObservable: Observable<{}>;
  37390. /**
  37391. * 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
  37392. */
  37393. constructor();
  37394. /**
  37395. * The name of the behavior
  37396. */
  37397. readonly name: string;
  37398. /**
  37399. * Initializes the behavior
  37400. */
  37401. init(): void;
  37402. /**
  37403. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37404. */
  37405. private readonly _pointerCamera;
  37406. /**
  37407. * Attaches the scale behavior the passed in mesh
  37408. * @param ownerNode The mesh that will be scaled around once attached
  37409. */
  37410. attach(ownerNode: Mesh): void;
  37411. /**
  37412. * Detaches the behavior from the mesh
  37413. */
  37414. detach(): void;
  37415. }
  37416. }
  37417. declare module "babylonjs/Behaviors/Meshes/index" {
  37418. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37419. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37420. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37421. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37422. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37423. }
  37424. declare module "babylonjs/Behaviors/index" {
  37425. export * from "babylonjs/Behaviors/behavior";
  37426. export * from "babylonjs/Behaviors/Cameras/index";
  37427. export * from "babylonjs/Behaviors/Meshes/index";
  37428. }
  37429. declare module "babylonjs/Bones/boneIKController" {
  37430. import { Bone } from "babylonjs/Bones/bone";
  37431. import { Vector3 } from "babylonjs/Maths/math";
  37432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37433. import { Nullable } from "babylonjs/types";
  37434. /**
  37435. * Class used to apply inverse kinematics to bones
  37436. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37437. */
  37438. export class BoneIKController {
  37439. private static _tmpVecs;
  37440. private static _tmpQuat;
  37441. private static _tmpMats;
  37442. /**
  37443. * Gets or sets the target mesh
  37444. */
  37445. targetMesh: AbstractMesh;
  37446. /** Gets or sets the mesh used as pole */
  37447. poleTargetMesh: AbstractMesh;
  37448. /**
  37449. * Gets or sets the bone used as pole
  37450. */
  37451. poleTargetBone: Nullable<Bone>;
  37452. /**
  37453. * Gets or sets the target position
  37454. */
  37455. targetPosition: Vector3;
  37456. /**
  37457. * Gets or sets the pole target position
  37458. */
  37459. poleTargetPosition: Vector3;
  37460. /**
  37461. * Gets or sets the pole target local offset
  37462. */
  37463. poleTargetLocalOffset: Vector3;
  37464. /**
  37465. * Gets or sets the pole angle
  37466. */
  37467. poleAngle: number;
  37468. /**
  37469. * Gets or sets the mesh associated with the controller
  37470. */
  37471. mesh: AbstractMesh;
  37472. /**
  37473. * 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)
  37474. */
  37475. slerpAmount: number;
  37476. private _bone1Quat;
  37477. private _bone1Mat;
  37478. private _bone2Ang;
  37479. private _bone1;
  37480. private _bone2;
  37481. private _bone1Length;
  37482. private _bone2Length;
  37483. private _maxAngle;
  37484. private _maxReach;
  37485. private _rightHandedSystem;
  37486. private _bendAxis;
  37487. private _slerping;
  37488. private _adjustRoll;
  37489. /**
  37490. * Gets or sets maximum allowed angle
  37491. */
  37492. maxAngle: number;
  37493. /**
  37494. * Creates a new BoneIKController
  37495. * @param mesh defines the mesh to control
  37496. * @param bone defines the bone to control
  37497. * @param options defines options to set up the controller
  37498. */
  37499. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37500. targetMesh?: AbstractMesh;
  37501. poleTargetMesh?: AbstractMesh;
  37502. poleTargetBone?: Bone;
  37503. poleTargetLocalOffset?: Vector3;
  37504. poleAngle?: number;
  37505. bendAxis?: Vector3;
  37506. maxAngle?: number;
  37507. slerpAmount?: number;
  37508. });
  37509. private _setMaxAngle;
  37510. /**
  37511. * Force the controller to update the bones
  37512. */
  37513. update(): void;
  37514. }
  37515. }
  37516. declare module "babylonjs/Bones/boneLookController" {
  37517. import { Vector3, Space } from "babylonjs/Maths/math";
  37518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37519. import { Bone } from "babylonjs/Bones/bone";
  37520. /**
  37521. * Class used to make a bone look toward a point in space
  37522. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37523. */
  37524. export class BoneLookController {
  37525. private static _tmpVecs;
  37526. private static _tmpQuat;
  37527. private static _tmpMats;
  37528. /**
  37529. * The target Vector3 that the bone will look at
  37530. */
  37531. target: Vector3;
  37532. /**
  37533. * The mesh that the bone is attached to
  37534. */
  37535. mesh: AbstractMesh;
  37536. /**
  37537. * The bone that will be looking to the target
  37538. */
  37539. bone: Bone;
  37540. /**
  37541. * The up axis of the coordinate system that is used when the bone is rotated
  37542. */
  37543. upAxis: Vector3;
  37544. /**
  37545. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37546. */
  37547. upAxisSpace: Space;
  37548. /**
  37549. * Used to make an adjustment to the yaw of the bone
  37550. */
  37551. adjustYaw: number;
  37552. /**
  37553. * Used to make an adjustment to the pitch of the bone
  37554. */
  37555. adjustPitch: number;
  37556. /**
  37557. * Used to make an adjustment to the roll of the bone
  37558. */
  37559. adjustRoll: number;
  37560. /**
  37561. * 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)
  37562. */
  37563. slerpAmount: number;
  37564. private _minYaw;
  37565. private _maxYaw;
  37566. private _minPitch;
  37567. private _maxPitch;
  37568. private _minYawSin;
  37569. private _minYawCos;
  37570. private _maxYawSin;
  37571. private _maxYawCos;
  37572. private _midYawConstraint;
  37573. private _minPitchTan;
  37574. private _maxPitchTan;
  37575. private _boneQuat;
  37576. private _slerping;
  37577. private _transformYawPitch;
  37578. private _transformYawPitchInv;
  37579. private _firstFrameSkipped;
  37580. private _yawRange;
  37581. private _fowardAxis;
  37582. /**
  37583. * Gets or sets the minimum yaw angle that the bone can look to
  37584. */
  37585. minYaw: number;
  37586. /**
  37587. * Gets or sets the maximum yaw angle that the bone can look to
  37588. */
  37589. maxYaw: number;
  37590. /**
  37591. * Gets or sets the minimum pitch angle that the bone can look to
  37592. */
  37593. minPitch: number;
  37594. /**
  37595. * Gets or sets the maximum pitch angle that the bone can look to
  37596. */
  37597. maxPitch: number;
  37598. /**
  37599. * Create a BoneLookController
  37600. * @param mesh the mesh that the bone belongs to
  37601. * @param bone the bone that will be looking to the target
  37602. * @param target the target Vector3 to look at
  37603. * @param options optional settings:
  37604. * * maxYaw: the maximum angle the bone will yaw to
  37605. * * minYaw: the minimum angle the bone will yaw to
  37606. * * maxPitch: the maximum angle the bone will pitch to
  37607. * * minPitch: the minimum angle the bone will yaw to
  37608. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37609. * * upAxis: the up axis of the coordinate system
  37610. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37611. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37612. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37613. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37614. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37615. * * adjustRoll: used to make an adjustment to the roll of the bone
  37616. **/
  37617. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37618. maxYaw?: number;
  37619. minYaw?: number;
  37620. maxPitch?: number;
  37621. minPitch?: number;
  37622. slerpAmount?: number;
  37623. upAxis?: Vector3;
  37624. upAxisSpace?: Space;
  37625. yawAxis?: Vector3;
  37626. pitchAxis?: Vector3;
  37627. adjustYaw?: number;
  37628. adjustPitch?: number;
  37629. adjustRoll?: number;
  37630. });
  37631. /**
  37632. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37633. */
  37634. update(): void;
  37635. private _getAngleDiff;
  37636. private _getAngleBetween;
  37637. private _isAngleBetween;
  37638. }
  37639. }
  37640. declare module "babylonjs/Bones/index" {
  37641. export * from "babylonjs/Bones/bone";
  37642. export * from "babylonjs/Bones/boneIKController";
  37643. export * from "babylonjs/Bones/boneLookController";
  37644. export * from "babylonjs/Bones/skeleton";
  37645. }
  37646. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37647. import { Nullable } from "babylonjs/types";
  37648. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37649. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37650. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37651. /**
  37652. * Manage the gamepad inputs to control an arc rotate camera.
  37653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37654. */
  37655. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37656. /**
  37657. * Defines the camera the input is attached to.
  37658. */
  37659. camera: ArcRotateCamera;
  37660. /**
  37661. * Defines the gamepad the input is gathering event from.
  37662. */
  37663. gamepad: Nullable<Gamepad>;
  37664. /**
  37665. * Defines the gamepad rotation sensiblity.
  37666. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37667. */
  37668. gamepadRotationSensibility: number;
  37669. /**
  37670. * Defines the gamepad move sensiblity.
  37671. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37672. */
  37673. gamepadMoveSensibility: number;
  37674. private _onGamepadConnectedObserver;
  37675. private _onGamepadDisconnectedObserver;
  37676. /**
  37677. * Attach the input controls to a specific dom element to get the input from.
  37678. * @param element Defines the element the controls should be listened from
  37679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37680. */
  37681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37682. /**
  37683. * Detach the current controls from the specified dom element.
  37684. * @param element Defines the element to stop listening the inputs from
  37685. */
  37686. detachControl(element: Nullable<HTMLElement>): void;
  37687. /**
  37688. * Update the current camera state depending on the inputs that have been used this frame.
  37689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37690. */
  37691. checkInputs(): void;
  37692. /**
  37693. * Gets the class name of the current intput.
  37694. * @returns the class name
  37695. */
  37696. getClassName(): string;
  37697. /**
  37698. * Get the friendly name associated with the input class.
  37699. * @returns the input friendly name
  37700. */
  37701. getSimpleName(): string;
  37702. }
  37703. }
  37704. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37705. import { Nullable } from "babylonjs/types";
  37706. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37707. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37708. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37709. interface ArcRotateCameraInputsManager {
  37710. /**
  37711. * Add orientation input support to the input manager.
  37712. * @returns the current input manager
  37713. */
  37714. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37715. }
  37716. }
  37717. /**
  37718. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37720. */
  37721. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37722. /**
  37723. * Defines the camera the input is attached to.
  37724. */
  37725. camera: ArcRotateCamera;
  37726. /**
  37727. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37728. */
  37729. alphaCorrection: number;
  37730. /**
  37731. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37732. */
  37733. gammaCorrection: number;
  37734. private _alpha;
  37735. private _gamma;
  37736. private _dirty;
  37737. private _deviceOrientationHandler;
  37738. /**
  37739. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37740. */
  37741. constructor();
  37742. /**
  37743. * Attach the input controls to a specific dom element to get the input from.
  37744. * @param element Defines the element the controls should be listened from
  37745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37746. */
  37747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37748. /** @hidden */
  37749. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37750. /**
  37751. * Update the current camera state depending on the inputs that have been used this frame.
  37752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37753. */
  37754. checkInputs(): void;
  37755. /**
  37756. * Detach the current controls from the specified dom element.
  37757. * @param element Defines the element to stop listening the inputs from
  37758. */
  37759. detachControl(element: Nullable<HTMLElement>): void;
  37760. /**
  37761. * Gets the class name of the current intput.
  37762. * @returns the class name
  37763. */
  37764. getClassName(): string;
  37765. /**
  37766. * Get the friendly name associated with the input class.
  37767. * @returns the input friendly name
  37768. */
  37769. getSimpleName(): string;
  37770. }
  37771. }
  37772. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37773. import { Nullable } from "babylonjs/types";
  37774. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37775. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37776. /**
  37777. * Listen to mouse events to control the camera.
  37778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37779. */
  37780. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37781. /**
  37782. * Defines the camera the input is attached to.
  37783. */
  37784. camera: FlyCamera;
  37785. /**
  37786. * Defines if touch is enabled. (Default is true.)
  37787. */
  37788. touchEnabled: boolean;
  37789. /**
  37790. * Defines the buttons associated with the input to handle camera rotation.
  37791. */
  37792. buttons: number[];
  37793. /**
  37794. * Assign buttons for Yaw control.
  37795. */
  37796. buttonsYaw: number[];
  37797. /**
  37798. * Assign buttons for Pitch control.
  37799. */
  37800. buttonsPitch: number[];
  37801. /**
  37802. * Assign buttons for Roll control.
  37803. */
  37804. buttonsRoll: number[];
  37805. /**
  37806. * Detect if any button is being pressed while mouse is moved.
  37807. * -1 = Mouse locked.
  37808. * 0 = Left button.
  37809. * 1 = Middle Button.
  37810. * 2 = Right Button.
  37811. */
  37812. activeButton: number;
  37813. /**
  37814. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37815. * Higher values reduce its sensitivity.
  37816. */
  37817. angularSensibility: number;
  37818. private _mousemoveCallback;
  37819. private _observer;
  37820. private _rollObserver;
  37821. private previousPosition;
  37822. private noPreventDefault;
  37823. private element;
  37824. /**
  37825. * Listen to mouse events to control the camera.
  37826. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37828. */
  37829. constructor(touchEnabled?: boolean);
  37830. /**
  37831. * Attach the mouse control to the HTML DOM element.
  37832. * @param element Defines the element that listens to the input events.
  37833. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37834. */
  37835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37836. /**
  37837. * Detach the current controls from the specified dom element.
  37838. * @param element Defines the element to stop listening the inputs from
  37839. */
  37840. detachControl(element: Nullable<HTMLElement>): void;
  37841. /**
  37842. * Gets the class name of the current input.
  37843. * @returns the class name.
  37844. */
  37845. getClassName(): string;
  37846. /**
  37847. * Get the friendly name associated with the input class.
  37848. * @returns the input's friendly name.
  37849. */
  37850. getSimpleName(): string;
  37851. private _pointerInput;
  37852. private _onMouseMove;
  37853. /**
  37854. * Rotate camera by mouse offset.
  37855. */
  37856. private rotateCamera;
  37857. }
  37858. }
  37859. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37860. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37861. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37862. /**
  37863. * Default Inputs manager for the FlyCamera.
  37864. * It groups all the default supported inputs for ease of use.
  37865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37866. */
  37867. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37868. /**
  37869. * Instantiates a new FlyCameraInputsManager.
  37870. * @param camera Defines the camera the inputs belong to.
  37871. */
  37872. constructor(camera: FlyCamera);
  37873. /**
  37874. * Add keyboard input support to the input manager.
  37875. * @returns the new FlyCameraKeyboardMoveInput().
  37876. */
  37877. addKeyboard(): FlyCameraInputsManager;
  37878. /**
  37879. * Add mouse input support to the input manager.
  37880. * @param touchEnabled Enable touch screen support.
  37881. * @returns the new FlyCameraMouseInput().
  37882. */
  37883. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37884. }
  37885. }
  37886. declare module "babylonjs/Cameras/flyCamera" {
  37887. import { Scene } from "babylonjs/scene";
  37888. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37890. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37891. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37892. /**
  37893. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37894. * such as in a 3D Space Shooter or a Flight Simulator.
  37895. */
  37896. export class FlyCamera extends TargetCamera {
  37897. /**
  37898. * Define the collision ellipsoid of the camera.
  37899. * This is helpful for simulating a camera body, like a player's body.
  37900. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37901. */
  37902. ellipsoid: Vector3;
  37903. /**
  37904. * Define an offset for the position of the ellipsoid around the camera.
  37905. * This can be helpful if the camera is attached away from the player's body center,
  37906. * such as at its head.
  37907. */
  37908. ellipsoidOffset: Vector3;
  37909. /**
  37910. * Enable or disable collisions of the camera with the rest of the scene objects.
  37911. */
  37912. checkCollisions: boolean;
  37913. /**
  37914. * Enable or disable gravity on the camera.
  37915. */
  37916. applyGravity: boolean;
  37917. /**
  37918. * Define the current direction the camera is moving to.
  37919. */
  37920. cameraDirection: Vector3;
  37921. /**
  37922. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37923. * This overrides and empties cameraRotation.
  37924. */
  37925. rotationQuaternion: Quaternion;
  37926. /**
  37927. * Track Roll to maintain the wanted Rolling when looking around.
  37928. */
  37929. _trackRoll: number;
  37930. /**
  37931. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37932. */
  37933. rollCorrect: number;
  37934. /**
  37935. * Mimic a banked turn, Rolling the camera when Yawing.
  37936. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37937. */
  37938. bankedTurn: boolean;
  37939. /**
  37940. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37941. */
  37942. bankedTurnLimit: number;
  37943. /**
  37944. * Value of 0 disables the banked Roll.
  37945. * Value of 1 is equal to the Yaw angle in radians.
  37946. */
  37947. bankedTurnMultiplier: number;
  37948. /**
  37949. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37950. */
  37951. inputs: FlyCameraInputsManager;
  37952. /**
  37953. * Gets the input sensibility for mouse input.
  37954. * Higher values reduce sensitivity.
  37955. */
  37956. /**
  37957. * Sets the input sensibility for a mouse input.
  37958. * Higher values reduce sensitivity.
  37959. */
  37960. angularSensibility: number;
  37961. /**
  37962. * Get the keys for camera movement forward.
  37963. */
  37964. /**
  37965. * Set the keys for camera movement forward.
  37966. */
  37967. keysForward: number[];
  37968. /**
  37969. * Get the keys for camera movement backward.
  37970. */
  37971. keysBackward: number[];
  37972. /**
  37973. * Get the keys for camera movement up.
  37974. */
  37975. /**
  37976. * Set the keys for camera movement up.
  37977. */
  37978. keysUp: number[];
  37979. /**
  37980. * Get the keys for camera movement down.
  37981. */
  37982. /**
  37983. * Set the keys for camera movement down.
  37984. */
  37985. keysDown: number[];
  37986. /**
  37987. * Get the keys for camera movement left.
  37988. */
  37989. /**
  37990. * Set the keys for camera movement left.
  37991. */
  37992. keysLeft: number[];
  37993. /**
  37994. * Set the keys for camera movement right.
  37995. */
  37996. /**
  37997. * Set the keys for camera movement right.
  37998. */
  37999. keysRight: number[];
  38000. /**
  38001. * Event raised when the camera collides with a mesh in the scene.
  38002. */
  38003. onCollide: (collidedMesh: AbstractMesh) => void;
  38004. private _collider;
  38005. private _needMoveForGravity;
  38006. private _oldPosition;
  38007. private _diffPosition;
  38008. private _newPosition;
  38009. /** @hidden */
  38010. _localDirection: Vector3;
  38011. /** @hidden */
  38012. _transformedDirection: Vector3;
  38013. /**
  38014. * Instantiates a FlyCamera.
  38015. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38016. * such as in a 3D Space Shooter or a Flight Simulator.
  38017. * @param name Define the name of the camera in the scene.
  38018. * @param position Define the starting position of the camera in the scene.
  38019. * @param scene Define the scene the camera belongs to.
  38020. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38021. */
  38022. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38023. /**
  38024. * Attach a control to the HTML DOM element.
  38025. * @param element Defines the element that listens to the input events.
  38026. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38027. */
  38028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38029. /**
  38030. * Detach a control from the HTML DOM element.
  38031. * The camera will stop reacting to that input.
  38032. * @param element Defines the element that listens to the input events.
  38033. */
  38034. detachControl(element: HTMLElement): void;
  38035. private _collisionMask;
  38036. /**
  38037. * Get the mask that the camera ignores in collision events.
  38038. */
  38039. /**
  38040. * Set the mask that the camera ignores in collision events.
  38041. */
  38042. collisionMask: number;
  38043. /** @hidden */
  38044. _collideWithWorld(displacement: Vector3): void;
  38045. /** @hidden */
  38046. private _onCollisionPositionChange;
  38047. /** @hidden */
  38048. _checkInputs(): void;
  38049. /** @hidden */
  38050. _decideIfNeedsToMove(): boolean;
  38051. /** @hidden */
  38052. _updatePosition(): void;
  38053. /**
  38054. * Restore the Roll to its target value at the rate specified.
  38055. * @param rate - Higher means slower restoring.
  38056. * @hidden
  38057. */
  38058. restoreRoll(rate: number): void;
  38059. /**
  38060. * Destroy the camera and release the current resources held by it.
  38061. */
  38062. dispose(): void;
  38063. /**
  38064. * Get the current object class name.
  38065. * @returns the class name.
  38066. */
  38067. getClassName(): string;
  38068. }
  38069. }
  38070. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38071. import { Nullable } from "babylonjs/types";
  38072. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38073. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38074. /**
  38075. * Listen to keyboard events to control the camera.
  38076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38077. */
  38078. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38079. /**
  38080. * Defines the camera the input is attached to.
  38081. */
  38082. camera: FlyCamera;
  38083. /**
  38084. * The list of keyboard keys used to control the forward move of the camera.
  38085. */
  38086. keysForward: number[];
  38087. /**
  38088. * The list of keyboard keys used to control the backward move of the camera.
  38089. */
  38090. keysBackward: number[];
  38091. /**
  38092. * The list of keyboard keys used to control the forward move of the camera.
  38093. */
  38094. keysUp: number[];
  38095. /**
  38096. * The list of keyboard keys used to control the backward move of the camera.
  38097. */
  38098. keysDown: number[];
  38099. /**
  38100. * The list of keyboard keys used to control the right strafe move of the camera.
  38101. */
  38102. keysRight: number[];
  38103. /**
  38104. * The list of keyboard keys used to control the left strafe move of the camera.
  38105. */
  38106. keysLeft: number[];
  38107. private _keys;
  38108. private _onCanvasBlurObserver;
  38109. private _onKeyboardObserver;
  38110. private _engine;
  38111. private _scene;
  38112. /**
  38113. * Attach the input controls to a specific dom element to get the input from.
  38114. * @param element Defines the element the controls should be listened from
  38115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38116. */
  38117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38118. /**
  38119. * Detach the current controls from the specified dom element.
  38120. * @param element Defines the element to stop listening the inputs from
  38121. */
  38122. detachControl(element: Nullable<HTMLElement>): void;
  38123. /**
  38124. * Gets the class name of the current intput.
  38125. * @returns the class name
  38126. */
  38127. getClassName(): string;
  38128. /** @hidden */
  38129. _onLostFocus(e: FocusEvent): void;
  38130. /**
  38131. * Get the friendly name associated with the input class.
  38132. * @returns the input friendly name
  38133. */
  38134. getSimpleName(): string;
  38135. /**
  38136. * Update the current camera state depending on the inputs that have been used this frame.
  38137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38138. */
  38139. checkInputs(): void;
  38140. }
  38141. }
  38142. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38143. import { Nullable } from "babylonjs/types";
  38144. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38145. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38146. /**
  38147. * Manage the mouse wheel inputs to control a follow camera.
  38148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38149. */
  38150. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38151. /**
  38152. * Defines the camera the input is attached to.
  38153. */
  38154. camera: FollowCamera;
  38155. /**
  38156. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38157. */
  38158. axisControlRadius: boolean;
  38159. /**
  38160. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38161. */
  38162. axisControlHeight: boolean;
  38163. /**
  38164. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38165. */
  38166. axisControlRotation: boolean;
  38167. /**
  38168. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38169. * relation to mouseWheel events.
  38170. */
  38171. wheelPrecision: number;
  38172. /**
  38173. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38174. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38175. */
  38176. wheelDeltaPercentage: number;
  38177. private _wheel;
  38178. private _observer;
  38179. /**
  38180. * Attach the input controls to a specific dom element to get the input from.
  38181. * @param element Defines the element the controls should be listened from
  38182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38183. */
  38184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38185. /**
  38186. * Detach the current controls from the specified dom element.
  38187. * @param element Defines the element to stop listening the inputs from
  38188. */
  38189. detachControl(element: Nullable<HTMLElement>): void;
  38190. /**
  38191. * Gets the class name of the current intput.
  38192. * @returns the class name
  38193. */
  38194. getClassName(): string;
  38195. /**
  38196. * Get the friendly name associated with the input class.
  38197. * @returns the input friendly name
  38198. */
  38199. getSimpleName(): string;
  38200. }
  38201. }
  38202. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38203. import { Nullable } from "babylonjs/types";
  38204. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38205. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38206. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38207. /**
  38208. * Manage the pointers inputs to control an follow camera.
  38209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38210. */
  38211. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38212. /**
  38213. * Defines the camera the input is attached to.
  38214. */
  38215. camera: FollowCamera;
  38216. /**
  38217. * Gets the class name of the current input.
  38218. * @returns the class name
  38219. */
  38220. getClassName(): string;
  38221. /**
  38222. * Defines the pointer angular sensibility along the X axis or how fast is
  38223. * the camera rotating.
  38224. * A negative number will reverse the axis direction.
  38225. */
  38226. angularSensibilityX: number;
  38227. /**
  38228. * Defines the pointer angular sensibility along the Y axis or how fast is
  38229. * the camera rotating.
  38230. * A negative number will reverse the axis direction.
  38231. */
  38232. angularSensibilityY: number;
  38233. /**
  38234. * Defines the pointer pinch precision or how fast is the camera zooming.
  38235. * A negative number will reverse the axis direction.
  38236. */
  38237. pinchPrecision: number;
  38238. /**
  38239. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38240. * from 0.
  38241. * It defines the percentage of current camera.radius to use as delta when
  38242. * pinch zoom is used.
  38243. */
  38244. pinchDeltaPercentage: number;
  38245. /**
  38246. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38247. */
  38248. axisXControlRadius: boolean;
  38249. /**
  38250. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38251. */
  38252. axisXControlHeight: boolean;
  38253. /**
  38254. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38255. */
  38256. axisXControlRotation: boolean;
  38257. /**
  38258. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38259. */
  38260. axisYControlRadius: boolean;
  38261. /**
  38262. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38263. */
  38264. axisYControlHeight: boolean;
  38265. /**
  38266. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38267. */
  38268. axisYControlRotation: boolean;
  38269. /**
  38270. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38271. */
  38272. axisPinchControlRadius: boolean;
  38273. /**
  38274. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38275. */
  38276. axisPinchControlHeight: boolean;
  38277. /**
  38278. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38279. */
  38280. axisPinchControlRotation: boolean;
  38281. /**
  38282. * Log error messages if basic misconfiguration has occurred.
  38283. */
  38284. warningEnable: boolean;
  38285. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38286. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38287. private _warningCounter;
  38288. private _warning;
  38289. }
  38290. }
  38291. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38292. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38293. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38294. /**
  38295. * Default Inputs manager for the FollowCamera.
  38296. * It groups all the default supported inputs for ease of use.
  38297. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38298. */
  38299. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38300. /**
  38301. * Instantiates a new FollowCameraInputsManager.
  38302. * @param camera Defines the camera the inputs belong to
  38303. */
  38304. constructor(camera: FollowCamera);
  38305. /**
  38306. * Add keyboard input support to the input manager.
  38307. * @returns the current input manager
  38308. */
  38309. addKeyboard(): FollowCameraInputsManager;
  38310. /**
  38311. * Add mouse wheel input support to the input manager.
  38312. * @returns the current input manager
  38313. */
  38314. addMouseWheel(): FollowCameraInputsManager;
  38315. /**
  38316. * Add pointers input support to the input manager.
  38317. * @returns the current input manager
  38318. */
  38319. addPointers(): FollowCameraInputsManager;
  38320. /**
  38321. * Add orientation input support to the input manager.
  38322. * @returns the current input manager
  38323. */
  38324. addVRDeviceOrientation(): FollowCameraInputsManager;
  38325. }
  38326. }
  38327. declare module "babylonjs/Cameras/followCamera" {
  38328. import { Nullable } from "babylonjs/types";
  38329. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38330. import { Scene } from "babylonjs/scene";
  38331. import { Vector3 } from "babylonjs/Maths/math";
  38332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38333. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38334. /**
  38335. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38336. * an arc rotate version arcFollowCamera are available.
  38337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38338. */
  38339. export class FollowCamera extends TargetCamera {
  38340. /**
  38341. * Distance the follow camera should follow an object at
  38342. */
  38343. radius: number;
  38344. /**
  38345. * Minimum allowed distance of the camera to the axis of rotation
  38346. * (The camera can not get closer).
  38347. * This can help limiting how the Camera is able to move in the scene.
  38348. */
  38349. lowerRadiusLimit: Nullable<number>;
  38350. /**
  38351. * Maximum allowed distance of the camera to the axis of rotation
  38352. * (The camera can not get further).
  38353. * This can help limiting how the Camera is able to move in the scene.
  38354. */
  38355. upperRadiusLimit: Nullable<number>;
  38356. /**
  38357. * Define a rotation offset between the camera and the object it follows
  38358. */
  38359. rotationOffset: number;
  38360. /**
  38361. * Minimum allowed angle to camera position relative to target object.
  38362. * This can help limiting how the Camera is able to move in the scene.
  38363. */
  38364. lowerRotationOffsetLimit: Nullable<number>;
  38365. /**
  38366. * Maximum allowed angle to camera position relative to target object.
  38367. * This can help limiting how the Camera is able to move in the scene.
  38368. */
  38369. upperRotationOffsetLimit: Nullable<number>;
  38370. /**
  38371. * Define a height offset between the camera and the object it follows.
  38372. * It can help following an object from the top (like a car chaing a plane)
  38373. */
  38374. heightOffset: number;
  38375. /**
  38376. * Minimum allowed height of camera position relative to target object.
  38377. * This can help limiting how the Camera is able to move in the scene.
  38378. */
  38379. lowerHeightOffsetLimit: Nullable<number>;
  38380. /**
  38381. * Maximum allowed height of camera position relative to target object.
  38382. * This can help limiting how the Camera is able to move in the scene.
  38383. */
  38384. upperHeightOffsetLimit: Nullable<number>;
  38385. /**
  38386. * Define how fast the camera can accelerate to follow it s target.
  38387. */
  38388. cameraAcceleration: number;
  38389. /**
  38390. * Define the speed limit of the camera following an object.
  38391. */
  38392. maxCameraSpeed: number;
  38393. /**
  38394. * Define the target of the camera.
  38395. */
  38396. lockedTarget: Nullable<AbstractMesh>;
  38397. /**
  38398. * Defines the input associated with the camera.
  38399. */
  38400. inputs: FollowCameraInputsManager;
  38401. /**
  38402. * Instantiates the follow camera.
  38403. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38404. * @param name Define the name of the camera in the scene
  38405. * @param position Define the position of the camera
  38406. * @param scene Define the scene the camera belong to
  38407. * @param lockedTarget Define the target of the camera
  38408. */
  38409. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38410. private _follow;
  38411. /**
  38412. * Attached controls to the current camera.
  38413. * @param element Defines the element the controls should be listened from
  38414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38415. */
  38416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38417. /**
  38418. * Detach the current controls from the camera.
  38419. * The camera will stop reacting to inputs.
  38420. * @param element Defines the element to stop listening the inputs from
  38421. */
  38422. detachControl(element: HTMLElement): void;
  38423. /** @hidden */
  38424. _checkInputs(): void;
  38425. private _checkLimits;
  38426. /**
  38427. * Gets the camera class name.
  38428. * @returns the class name
  38429. */
  38430. getClassName(): string;
  38431. }
  38432. /**
  38433. * Arc Rotate version of the follow camera.
  38434. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38435. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38436. */
  38437. export class ArcFollowCamera extends TargetCamera {
  38438. /** The longitudinal angle of the camera */
  38439. alpha: number;
  38440. /** The latitudinal angle of the camera */
  38441. beta: number;
  38442. /** The radius of the camera from its target */
  38443. radius: number;
  38444. /** Define the camera target (the messh it should follow) */
  38445. target: Nullable<AbstractMesh>;
  38446. private _cartesianCoordinates;
  38447. /**
  38448. * Instantiates a new ArcFollowCamera
  38449. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38450. * @param name Define the name of the camera
  38451. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38452. * @param beta Define the rotation angle of the camera around the elevation axis
  38453. * @param radius Define the radius of the camera from its target point
  38454. * @param target Define the target of the camera
  38455. * @param scene Define the scene the camera belongs to
  38456. */
  38457. constructor(name: string,
  38458. /** The longitudinal angle of the camera */
  38459. alpha: number,
  38460. /** The latitudinal angle of the camera */
  38461. beta: number,
  38462. /** The radius of the camera from its target */
  38463. radius: number,
  38464. /** Define the camera target (the messh it should follow) */
  38465. target: Nullable<AbstractMesh>, scene: Scene);
  38466. private _follow;
  38467. /** @hidden */
  38468. _checkInputs(): void;
  38469. /**
  38470. * Returns the class name of the object.
  38471. * It is mostly used internally for serialization purposes.
  38472. */
  38473. getClassName(): string;
  38474. }
  38475. }
  38476. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38477. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38478. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38479. import { Nullable } from "babylonjs/types";
  38480. /**
  38481. * Manage the keyboard inputs to control the movement of a follow camera.
  38482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38483. */
  38484. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38485. /**
  38486. * Defines the camera the input is attached to.
  38487. */
  38488. camera: FollowCamera;
  38489. /**
  38490. * Defines the list of key codes associated with the up action (increase heightOffset)
  38491. */
  38492. keysHeightOffsetIncr: number[];
  38493. /**
  38494. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38495. */
  38496. keysHeightOffsetDecr: number[];
  38497. /**
  38498. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38499. */
  38500. keysHeightOffsetModifierAlt: boolean;
  38501. /**
  38502. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38503. */
  38504. keysHeightOffsetModifierCtrl: boolean;
  38505. /**
  38506. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38507. */
  38508. keysHeightOffsetModifierShift: boolean;
  38509. /**
  38510. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38511. */
  38512. keysRotationOffsetIncr: number[];
  38513. /**
  38514. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38515. */
  38516. keysRotationOffsetDecr: number[];
  38517. /**
  38518. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38519. */
  38520. keysRotationOffsetModifierAlt: boolean;
  38521. /**
  38522. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38523. */
  38524. keysRotationOffsetModifierCtrl: boolean;
  38525. /**
  38526. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38527. */
  38528. keysRotationOffsetModifierShift: boolean;
  38529. /**
  38530. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38531. */
  38532. keysRadiusIncr: number[];
  38533. /**
  38534. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38535. */
  38536. keysRadiusDecr: number[];
  38537. /**
  38538. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38539. */
  38540. keysRadiusModifierAlt: boolean;
  38541. /**
  38542. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38543. */
  38544. keysRadiusModifierCtrl: boolean;
  38545. /**
  38546. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38547. */
  38548. keysRadiusModifierShift: boolean;
  38549. /**
  38550. * Defines the rate of change of heightOffset.
  38551. */
  38552. heightSensibility: number;
  38553. /**
  38554. * Defines the rate of change of rotationOffset.
  38555. */
  38556. rotationSensibility: number;
  38557. /**
  38558. * Defines the rate of change of radius.
  38559. */
  38560. radiusSensibility: number;
  38561. private _keys;
  38562. private _ctrlPressed;
  38563. private _altPressed;
  38564. private _shiftPressed;
  38565. private _onCanvasBlurObserver;
  38566. private _onKeyboardObserver;
  38567. private _engine;
  38568. private _scene;
  38569. /**
  38570. * Attach the input controls to a specific dom element to get the input from.
  38571. * @param element Defines the element the controls should be listened from
  38572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38573. */
  38574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38575. /**
  38576. * Detach the current controls from the specified dom element.
  38577. * @param element Defines the element to stop listening the inputs from
  38578. */
  38579. detachControl(element: Nullable<HTMLElement>): void;
  38580. /**
  38581. * Update the current camera state depending on the inputs that have been used this frame.
  38582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38583. */
  38584. checkInputs(): void;
  38585. /**
  38586. * Gets the class name of the current input.
  38587. * @returns the class name
  38588. */
  38589. getClassName(): string;
  38590. /**
  38591. * Get the friendly name associated with the input class.
  38592. * @returns the input friendly name
  38593. */
  38594. getSimpleName(): string;
  38595. /**
  38596. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38597. * allow modification of the heightOffset value.
  38598. */
  38599. private _modifierHeightOffset;
  38600. /**
  38601. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38602. * allow modification of the rotationOffset value.
  38603. */
  38604. private _modifierRotationOffset;
  38605. /**
  38606. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38607. * allow modification of the radius value.
  38608. */
  38609. private _modifierRadius;
  38610. }
  38611. }
  38612. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38613. import { Nullable } from "babylonjs/types";
  38614. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38615. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38616. import { Observable } from "babylonjs/Misc/observable";
  38617. module "babylonjs/Cameras/freeCameraInputsManager" {
  38618. interface FreeCameraInputsManager {
  38619. /**
  38620. * @hidden
  38621. */
  38622. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38623. /**
  38624. * Add orientation input support to the input manager.
  38625. * @returns the current input manager
  38626. */
  38627. addDeviceOrientation(): FreeCameraInputsManager;
  38628. }
  38629. }
  38630. /**
  38631. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38632. * Screen rotation is taken into account.
  38633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38634. */
  38635. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38636. private _camera;
  38637. private _screenOrientationAngle;
  38638. private _constantTranform;
  38639. private _screenQuaternion;
  38640. private _alpha;
  38641. private _beta;
  38642. private _gamma;
  38643. /**
  38644. * Can be used to detect if a device orientation sensor is availible on a device
  38645. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38646. * @returns a promise that will resolve on orientation change
  38647. */
  38648. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38649. /**
  38650. * @hidden
  38651. */
  38652. _onDeviceOrientationChangedObservable: Observable<void>;
  38653. /**
  38654. * Instantiates a new input
  38655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38656. */
  38657. constructor();
  38658. /**
  38659. * Define the camera controlled by the input.
  38660. */
  38661. camera: FreeCamera;
  38662. /**
  38663. * Attach the input controls to a specific dom element to get the input from.
  38664. * @param element Defines the element the controls should be listened from
  38665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38666. */
  38667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38668. private _orientationChanged;
  38669. private _deviceOrientation;
  38670. /**
  38671. * Detach the current controls from the specified dom element.
  38672. * @param element Defines the element to stop listening the inputs from
  38673. */
  38674. detachControl(element: Nullable<HTMLElement>): void;
  38675. /**
  38676. * Update the current camera state depending on the inputs that have been used this frame.
  38677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38678. */
  38679. checkInputs(): void;
  38680. /**
  38681. * Gets the class name of the current intput.
  38682. * @returns the class name
  38683. */
  38684. getClassName(): string;
  38685. /**
  38686. * Get the friendly name associated with the input class.
  38687. * @returns the input friendly name
  38688. */
  38689. getSimpleName(): string;
  38690. }
  38691. }
  38692. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38693. import { Nullable } from "babylonjs/types";
  38694. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38695. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38696. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38697. /**
  38698. * Manage the gamepad inputs to control a free camera.
  38699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38700. */
  38701. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38702. /**
  38703. * Define the camera the input is attached to.
  38704. */
  38705. camera: FreeCamera;
  38706. /**
  38707. * Define the Gamepad controlling the input
  38708. */
  38709. gamepad: Nullable<Gamepad>;
  38710. /**
  38711. * Defines the gamepad rotation sensiblity.
  38712. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38713. */
  38714. gamepadAngularSensibility: number;
  38715. /**
  38716. * Defines the gamepad move sensiblity.
  38717. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38718. */
  38719. gamepadMoveSensibility: number;
  38720. private _onGamepadConnectedObserver;
  38721. private _onGamepadDisconnectedObserver;
  38722. private _cameraTransform;
  38723. private _deltaTransform;
  38724. private _vector3;
  38725. private _vector2;
  38726. /**
  38727. * Attach the input controls to a specific dom element to get the input from.
  38728. * @param element Defines the element the controls should be listened from
  38729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38730. */
  38731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38732. /**
  38733. * Detach the current controls from the specified dom element.
  38734. * @param element Defines the element to stop listening the inputs from
  38735. */
  38736. detachControl(element: Nullable<HTMLElement>): void;
  38737. /**
  38738. * Update the current camera state depending on the inputs that have been used this frame.
  38739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38740. */
  38741. checkInputs(): void;
  38742. /**
  38743. * Gets the class name of the current intput.
  38744. * @returns the class name
  38745. */
  38746. getClassName(): string;
  38747. /**
  38748. * Get the friendly name associated with the input class.
  38749. * @returns the input friendly name
  38750. */
  38751. getSimpleName(): string;
  38752. }
  38753. }
  38754. declare module "babylonjs/Misc/virtualJoystick" {
  38755. import { Nullable } from "babylonjs/types";
  38756. import { Vector3 } from "babylonjs/Maths/math";
  38757. /**
  38758. * Defines the potential axis of a Joystick
  38759. */
  38760. export enum JoystickAxis {
  38761. /** X axis */
  38762. X = 0,
  38763. /** Y axis */
  38764. Y = 1,
  38765. /** Z axis */
  38766. Z = 2
  38767. }
  38768. /**
  38769. * Class used to define virtual joystick (used in touch mode)
  38770. */
  38771. export class VirtualJoystick {
  38772. /**
  38773. * Gets or sets a boolean indicating that left and right values must be inverted
  38774. */
  38775. reverseLeftRight: boolean;
  38776. /**
  38777. * Gets or sets a boolean indicating that up and down values must be inverted
  38778. */
  38779. reverseUpDown: boolean;
  38780. /**
  38781. * Gets the offset value for the position (ie. the change of the position value)
  38782. */
  38783. deltaPosition: Vector3;
  38784. /**
  38785. * Gets a boolean indicating if the virtual joystick was pressed
  38786. */
  38787. pressed: boolean;
  38788. /**
  38789. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38790. */
  38791. static Canvas: Nullable<HTMLCanvasElement>;
  38792. private static _globalJoystickIndex;
  38793. private static vjCanvasContext;
  38794. private static vjCanvasWidth;
  38795. private static vjCanvasHeight;
  38796. private static halfWidth;
  38797. private _action;
  38798. private _axisTargetedByLeftAndRight;
  38799. private _axisTargetedByUpAndDown;
  38800. private _joystickSensibility;
  38801. private _inversedSensibility;
  38802. private _joystickPointerID;
  38803. private _joystickColor;
  38804. private _joystickPointerPos;
  38805. private _joystickPreviousPointerPos;
  38806. private _joystickPointerStartPos;
  38807. private _deltaJoystickVector;
  38808. private _leftJoystick;
  38809. private _touches;
  38810. private _onPointerDownHandlerRef;
  38811. private _onPointerMoveHandlerRef;
  38812. private _onPointerUpHandlerRef;
  38813. private _onResize;
  38814. /**
  38815. * Creates a new virtual joystick
  38816. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38817. */
  38818. constructor(leftJoystick?: boolean);
  38819. /**
  38820. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38821. * @param newJoystickSensibility defines the new sensibility
  38822. */
  38823. setJoystickSensibility(newJoystickSensibility: number): void;
  38824. private _onPointerDown;
  38825. private _onPointerMove;
  38826. private _onPointerUp;
  38827. /**
  38828. * Change the color of the virtual joystick
  38829. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38830. */
  38831. setJoystickColor(newColor: string): void;
  38832. /**
  38833. * Defines a callback to call when the joystick is touched
  38834. * @param action defines the callback
  38835. */
  38836. setActionOnTouch(action: () => any): void;
  38837. /**
  38838. * Defines which axis you'd like to control for left & right
  38839. * @param axis defines the axis to use
  38840. */
  38841. setAxisForLeftRight(axis: JoystickAxis): void;
  38842. /**
  38843. * Defines which axis you'd like to control for up & down
  38844. * @param axis defines the axis to use
  38845. */
  38846. setAxisForUpDown(axis: JoystickAxis): void;
  38847. private _drawVirtualJoystick;
  38848. /**
  38849. * Release internal HTML canvas
  38850. */
  38851. releaseCanvas(): void;
  38852. }
  38853. }
  38854. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38855. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38856. import { Nullable } from "babylonjs/types";
  38857. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38858. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38859. module "babylonjs/Cameras/freeCameraInputsManager" {
  38860. interface FreeCameraInputsManager {
  38861. /**
  38862. * Add virtual joystick input support to the input manager.
  38863. * @returns the current input manager
  38864. */
  38865. addVirtualJoystick(): FreeCameraInputsManager;
  38866. }
  38867. }
  38868. /**
  38869. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38871. */
  38872. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38873. /**
  38874. * Defines the camera the input is attached to.
  38875. */
  38876. camera: FreeCamera;
  38877. private _leftjoystick;
  38878. private _rightjoystick;
  38879. /**
  38880. * Gets the left stick of the virtual joystick.
  38881. * @returns The virtual Joystick
  38882. */
  38883. getLeftJoystick(): VirtualJoystick;
  38884. /**
  38885. * Gets the right stick of the virtual joystick.
  38886. * @returns The virtual Joystick
  38887. */
  38888. getRightJoystick(): VirtualJoystick;
  38889. /**
  38890. * Update the current camera state depending on the inputs that have been used this frame.
  38891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38892. */
  38893. checkInputs(): void;
  38894. /**
  38895. * Attach the input controls to a specific dom element to get the input from.
  38896. * @param element Defines the element the controls should be listened from
  38897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38898. */
  38899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38900. /**
  38901. * Detach the current controls from the specified dom element.
  38902. * @param element Defines the element to stop listening the inputs from
  38903. */
  38904. detachControl(element: Nullable<HTMLElement>): void;
  38905. /**
  38906. * Gets the class name of the current intput.
  38907. * @returns the class name
  38908. */
  38909. getClassName(): string;
  38910. /**
  38911. * Get the friendly name associated with the input class.
  38912. * @returns the input friendly name
  38913. */
  38914. getSimpleName(): string;
  38915. }
  38916. }
  38917. declare module "babylonjs/Cameras/Inputs/index" {
  38918. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38919. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38920. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38921. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38922. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38923. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38924. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38925. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38926. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38927. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38928. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38929. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38930. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38931. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38932. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38933. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38934. }
  38935. declare module "babylonjs/Cameras/touchCamera" {
  38936. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38937. import { Scene } from "babylonjs/scene";
  38938. import { Vector3 } from "babylonjs/Maths/math";
  38939. /**
  38940. * This represents a FPS type of camera controlled by touch.
  38941. * This is like a universal camera minus the Gamepad controls.
  38942. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38943. */
  38944. export class TouchCamera extends FreeCamera {
  38945. /**
  38946. * Defines the touch sensibility for rotation.
  38947. * The higher the faster.
  38948. */
  38949. touchAngularSensibility: number;
  38950. /**
  38951. * Defines the touch sensibility for move.
  38952. * The higher the faster.
  38953. */
  38954. touchMoveSensibility: number;
  38955. /**
  38956. * Instantiates a new touch camera.
  38957. * This represents a FPS type of camera controlled by touch.
  38958. * This is like a universal camera minus the Gamepad controls.
  38959. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38960. * @param name Define the name of the camera in the scene
  38961. * @param position Define the start position of the camera in the scene
  38962. * @param scene Define the scene the camera belongs to
  38963. */
  38964. constructor(name: string, position: Vector3, scene: Scene);
  38965. /**
  38966. * Gets the current object class name.
  38967. * @return the class name
  38968. */
  38969. getClassName(): string;
  38970. /** @hidden */
  38971. _setupInputs(): void;
  38972. }
  38973. }
  38974. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38975. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38976. import { Scene } from "babylonjs/scene";
  38977. import { Vector3, Axis } from "babylonjs/Maths/math";
  38978. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38979. /**
  38980. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38981. * being tilted forward or back and left or right.
  38982. */
  38983. export class DeviceOrientationCamera extends FreeCamera {
  38984. private _initialQuaternion;
  38985. private _quaternionCache;
  38986. private _tmpDragQuaternion;
  38987. /**
  38988. * Creates a new device orientation camera
  38989. * @param name The name of the camera
  38990. * @param position The start position camera
  38991. * @param scene The scene the camera belongs to
  38992. */
  38993. constructor(name: string, position: Vector3, scene: Scene);
  38994. /**
  38995. * @hidden
  38996. * Disabled pointer input on first orientation sensor update (Default: true)
  38997. */
  38998. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38999. private _dragFactor;
  39000. /**
  39001. * Enabled turning on the y axis when the orientation sensor is active
  39002. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39003. */
  39004. enableHorizontalDragging(dragFactor?: number): void;
  39005. /**
  39006. * Gets the current instance class name ("DeviceOrientationCamera").
  39007. * This helps avoiding instanceof at run time.
  39008. * @returns the class name
  39009. */
  39010. getClassName(): string;
  39011. /**
  39012. * @hidden
  39013. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39014. */
  39015. _checkInputs(): void;
  39016. /**
  39017. * Reset the camera to its default orientation on the specified axis only.
  39018. * @param axis The axis to reset
  39019. */
  39020. resetToCurrentRotation(axis?: Axis): void;
  39021. }
  39022. }
  39023. declare module "babylonjs/Gamepads/xboxGamepad" {
  39024. import { Observable } from "babylonjs/Misc/observable";
  39025. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39026. /**
  39027. * Defines supported buttons for XBox360 compatible gamepads
  39028. */
  39029. export enum Xbox360Button {
  39030. /** A */
  39031. A = 0,
  39032. /** B */
  39033. B = 1,
  39034. /** X */
  39035. X = 2,
  39036. /** Y */
  39037. Y = 3,
  39038. /** Start */
  39039. Start = 4,
  39040. /** Back */
  39041. Back = 5,
  39042. /** Left button */
  39043. LB = 6,
  39044. /** Right button */
  39045. RB = 7,
  39046. /** Left stick */
  39047. LeftStick = 8,
  39048. /** Right stick */
  39049. RightStick = 9
  39050. }
  39051. /** Defines values for XBox360 DPad */
  39052. export enum Xbox360Dpad {
  39053. /** Up */
  39054. Up = 0,
  39055. /** Down */
  39056. Down = 1,
  39057. /** Left */
  39058. Left = 2,
  39059. /** Right */
  39060. Right = 3
  39061. }
  39062. /**
  39063. * Defines a XBox360 gamepad
  39064. */
  39065. export class Xbox360Pad extends Gamepad {
  39066. private _leftTrigger;
  39067. private _rightTrigger;
  39068. private _onlefttriggerchanged;
  39069. private _onrighttriggerchanged;
  39070. private _onbuttondown;
  39071. private _onbuttonup;
  39072. private _ondpaddown;
  39073. private _ondpadup;
  39074. /** Observable raised when a button is pressed */
  39075. onButtonDownObservable: Observable<Xbox360Button>;
  39076. /** Observable raised when a button is released */
  39077. onButtonUpObservable: Observable<Xbox360Button>;
  39078. /** Observable raised when a pad is pressed */
  39079. onPadDownObservable: Observable<Xbox360Dpad>;
  39080. /** Observable raised when a pad is released */
  39081. onPadUpObservable: Observable<Xbox360Dpad>;
  39082. private _buttonA;
  39083. private _buttonB;
  39084. private _buttonX;
  39085. private _buttonY;
  39086. private _buttonBack;
  39087. private _buttonStart;
  39088. private _buttonLB;
  39089. private _buttonRB;
  39090. private _buttonLeftStick;
  39091. private _buttonRightStick;
  39092. private _dPadUp;
  39093. private _dPadDown;
  39094. private _dPadLeft;
  39095. private _dPadRight;
  39096. private _isXboxOnePad;
  39097. /**
  39098. * Creates a new XBox360 gamepad object
  39099. * @param id defines the id of this gamepad
  39100. * @param index defines its index
  39101. * @param gamepad defines the internal HTML gamepad object
  39102. * @param xboxOne defines if it is a XBox One gamepad
  39103. */
  39104. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39105. /**
  39106. * Defines the callback to call when left trigger is pressed
  39107. * @param callback defines the callback to use
  39108. */
  39109. onlefttriggerchanged(callback: (value: number) => void): void;
  39110. /**
  39111. * Defines the callback to call when right trigger is pressed
  39112. * @param callback defines the callback to use
  39113. */
  39114. onrighttriggerchanged(callback: (value: number) => void): void;
  39115. /**
  39116. * Gets the left trigger value
  39117. */
  39118. /**
  39119. * Sets the left trigger value
  39120. */
  39121. leftTrigger: number;
  39122. /**
  39123. * Gets the right trigger value
  39124. */
  39125. /**
  39126. * Sets the right trigger value
  39127. */
  39128. rightTrigger: number;
  39129. /**
  39130. * Defines the callback to call when a button is pressed
  39131. * @param callback defines the callback to use
  39132. */
  39133. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39134. /**
  39135. * Defines the callback to call when a button is released
  39136. * @param callback defines the callback to use
  39137. */
  39138. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39139. /**
  39140. * Defines the callback to call when a pad is pressed
  39141. * @param callback defines the callback to use
  39142. */
  39143. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39144. /**
  39145. * Defines the callback to call when a pad is released
  39146. * @param callback defines the callback to use
  39147. */
  39148. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39149. private _setButtonValue;
  39150. private _setDPadValue;
  39151. /**
  39152. * Gets the value of the `A` button
  39153. */
  39154. /**
  39155. * Sets the value of the `A` button
  39156. */
  39157. buttonA: number;
  39158. /**
  39159. * Gets the value of the `B` button
  39160. */
  39161. /**
  39162. * Sets the value of the `B` button
  39163. */
  39164. buttonB: number;
  39165. /**
  39166. * Gets the value of the `X` button
  39167. */
  39168. /**
  39169. * Sets the value of the `X` button
  39170. */
  39171. buttonX: number;
  39172. /**
  39173. * Gets the value of the `Y` button
  39174. */
  39175. /**
  39176. * Sets the value of the `Y` button
  39177. */
  39178. buttonY: number;
  39179. /**
  39180. * Gets the value of the `Start` button
  39181. */
  39182. /**
  39183. * Sets the value of the `Start` button
  39184. */
  39185. buttonStart: number;
  39186. /**
  39187. * Gets the value of the `Back` button
  39188. */
  39189. /**
  39190. * Sets the value of the `Back` button
  39191. */
  39192. buttonBack: number;
  39193. /**
  39194. * Gets the value of the `Left` button
  39195. */
  39196. /**
  39197. * Sets the value of the `Left` button
  39198. */
  39199. buttonLB: number;
  39200. /**
  39201. * Gets the value of the `Right` button
  39202. */
  39203. /**
  39204. * Sets the value of the `Right` button
  39205. */
  39206. buttonRB: number;
  39207. /**
  39208. * Gets the value of the Left joystick
  39209. */
  39210. /**
  39211. * Sets the value of the Left joystick
  39212. */
  39213. buttonLeftStick: number;
  39214. /**
  39215. * Gets the value of the Right joystick
  39216. */
  39217. /**
  39218. * Sets the value of the Right joystick
  39219. */
  39220. buttonRightStick: number;
  39221. /**
  39222. * Gets the value of D-pad up
  39223. */
  39224. /**
  39225. * Sets the value of D-pad up
  39226. */
  39227. dPadUp: number;
  39228. /**
  39229. * Gets the value of D-pad down
  39230. */
  39231. /**
  39232. * Sets the value of D-pad down
  39233. */
  39234. dPadDown: number;
  39235. /**
  39236. * Gets the value of D-pad left
  39237. */
  39238. /**
  39239. * Sets the value of D-pad left
  39240. */
  39241. dPadLeft: number;
  39242. /**
  39243. * Gets the value of D-pad right
  39244. */
  39245. /**
  39246. * Sets the value of D-pad right
  39247. */
  39248. dPadRight: number;
  39249. /**
  39250. * Force the gamepad to synchronize with device values
  39251. */
  39252. update(): void;
  39253. /**
  39254. * Disposes the gamepad
  39255. */
  39256. dispose(): void;
  39257. }
  39258. }
  39259. declare module "babylonjs/Gamepads/gamepadManager" {
  39260. import { Observable } from "babylonjs/Misc/observable";
  39261. import { Nullable } from "babylonjs/types";
  39262. import { Scene } from "babylonjs/scene";
  39263. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39264. /**
  39265. * Manager for handling gamepads
  39266. */
  39267. export class GamepadManager {
  39268. private _scene?;
  39269. private _babylonGamepads;
  39270. private _oneGamepadConnected;
  39271. /** @hidden */
  39272. _isMonitoring: boolean;
  39273. private _gamepadEventSupported;
  39274. private _gamepadSupport;
  39275. /**
  39276. * observable to be triggered when the gamepad controller has been connected
  39277. */
  39278. onGamepadConnectedObservable: Observable<Gamepad>;
  39279. /**
  39280. * observable to be triggered when the gamepad controller has been disconnected
  39281. */
  39282. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39283. private _onGamepadConnectedEvent;
  39284. private _onGamepadDisconnectedEvent;
  39285. /**
  39286. * Initializes the gamepad manager
  39287. * @param _scene BabylonJS scene
  39288. */
  39289. constructor(_scene?: Scene | undefined);
  39290. /**
  39291. * The gamepads in the game pad manager
  39292. */
  39293. readonly gamepads: Gamepad[];
  39294. /**
  39295. * Get the gamepad controllers based on type
  39296. * @param type The type of gamepad controller
  39297. * @returns Nullable gamepad
  39298. */
  39299. getGamepadByType(type?: number): Nullable<Gamepad>;
  39300. /**
  39301. * Disposes the gamepad manager
  39302. */
  39303. dispose(): void;
  39304. private _addNewGamepad;
  39305. private _startMonitoringGamepads;
  39306. private _stopMonitoringGamepads;
  39307. /** @hidden */
  39308. _checkGamepadsStatus(): void;
  39309. private _updateGamepadObjects;
  39310. }
  39311. }
  39312. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39313. import { Nullable } from "babylonjs/types";
  39314. import { Scene } from "babylonjs/scene";
  39315. import { ISceneComponent } from "babylonjs/sceneComponent";
  39316. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39317. module "babylonjs/scene" {
  39318. interface Scene {
  39319. /** @hidden */
  39320. _gamepadManager: Nullable<GamepadManager>;
  39321. /**
  39322. * Gets the gamepad manager associated with the scene
  39323. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39324. */
  39325. gamepadManager: GamepadManager;
  39326. }
  39327. }
  39328. module "babylonjs/Cameras/freeCameraInputsManager" {
  39329. /**
  39330. * Interface representing a free camera inputs manager
  39331. */
  39332. interface FreeCameraInputsManager {
  39333. /**
  39334. * Adds gamepad input support to the FreeCameraInputsManager.
  39335. * @returns the FreeCameraInputsManager
  39336. */
  39337. addGamepad(): FreeCameraInputsManager;
  39338. }
  39339. }
  39340. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39341. /**
  39342. * Interface representing an arc rotate camera inputs manager
  39343. */
  39344. interface ArcRotateCameraInputsManager {
  39345. /**
  39346. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39347. * @returns the camera inputs manager
  39348. */
  39349. addGamepad(): ArcRotateCameraInputsManager;
  39350. }
  39351. }
  39352. /**
  39353. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39354. */
  39355. export class GamepadSystemSceneComponent implements ISceneComponent {
  39356. /**
  39357. * The component name helpfull to identify the component in the list of scene components.
  39358. */
  39359. readonly name: string;
  39360. /**
  39361. * The scene the component belongs to.
  39362. */
  39363. scene: Scene;
  39364. /**
  39365. * Creates a new instance of the component for the given scene
  39366. * @param scene Defines the scene to register the component in
  39367. */
  39368. constructor(scene: Scene);
  39369. /**
  39370. * Registers the component in a given scene
  39371. */
  39372. register(): void;
  39373. /**
  39374. * Rebuilds the elements related to this component in case of
  39375. * context lost for instance.
  39376. */
  39377. rebuild(): void;
  39378. /**
  39379. * Disposes the component and the associated ressources
  39380. */
  39381. dispose(): void;
  39382. private _beforeCameraUpdate;
  39383. }
  39384. }
  39385. declare module "babylonjs/Cameras/universalCamera" {
  39386. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39387. import { Scene } from "babylonjs/scene";
  39388. import { Vector3 } from "babylonjs/Maths/math";
  39389. import "babylonjs/Gamepads/gamepadSceneComponent";
  39390. /**
  39391. * 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,
  39392. * which still works and will still be found in many Playgrounds.
  39393. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39394. */
  39395. export class UniversalCamera extends TouchCamera {
  39396. /**
  39397. * Defines the gamepad rotation sensiblity.
  39398. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39399. */
  39400. gamepadAngularSensibility: number;
  39401. /**
  39402. * Defines the gamepad move sensiblity.
  39403. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39404. */
  39405. gamepadMoveSensibility: number;
  39406. /**
  39407. * 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,
  39408. * which still works and will still be found in many Playgrounds.
  39409. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39410. * @param name Define the name of the camera in the scene
  39411. * @param position Define the start position of the camera in the scene
  39412. * @param scene Define the scene the camera belongs to
  39413. */
  39414. constructor(name: string, position: Vector3, scene: Scene);
  39415. /**
  39416. * Gets the current object class name.
  39417. * @return the class name
  39418. */
  39419. getClassName(): string;
  39420. }
  39421. }
  39422. declare module "babylonjs/Cameras/gamepadCamera" {
  39423. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39424. import { Scene } from "babylonjs/scene";
  39425. import { Vector3 } from "babylonjs/Maths/math";
  39426. /**
  39427. * This represents a FPS type of camera. This is only here for back compat purpose.
  39428. * Please use the UniversalCamera instead as both are identical.
  39429. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39430. */
  39431. export class GamepadCamera extends UniversalCamera {
  39432. /**
  39433. * Instantiates a new Gamepad Camera
  39434. * This represents a FPS type of camera. This is only here for back compat purpose.
  39435. * Please use the UniversalCamera instead as both are identical.
  39436. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39437. * @param name Define the name of the camera in the scene
  39438. * @param position Define the start position of the camera in the scene
  39439. * @param scene Define the scene the camera belongs to
  39440. */
  39441. constructor(name: string, position: Vector3, scene: Scene);
  39442. /**
  39443. * Gets the current object class name.
  39444. * @return the class name
  39445. */
  39446. getClassName(): string;
  39447. }
  39448. }
  39449. declare module "babylonjs/Shaders/pass.fragment" {
  39450. /** @hidden */
  39451. export var passPixelShader: {
  39452. name: string;
  39453. shader: string;
  39454. };
  39455. }
  39456. declare module "babylonjs/Shaders/passCube.fragment" {
  39457. /** @hidden */
  39458. export var passCubePixelShader: {
  39459. name: string;
  39460. shader: string;
  39461. };
  39462. }
  39463. declare module "babylonjs/PostProcesses/passPostProcess" {
  39464. import { Nullable } from "babylonjs/types";
  39465. import { Camera } from "babylonjs/Cameras/camera";
  39466. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39467. import { Engine } from "babylonjs/Engines/engine";
  39468. import "babylonjs/Shaders/pass.fragment";
  39469. import "babylonjs/Shaders/passCube.fragment";
  39470. /**
  39471. * PassPostProcess which produces an output the same as it's input
  39472. */
  39473. export class PassPostProcess extends PostProcess {
  39474. /**
  39475. * Creates the PassPostProcess
  39476. * @param name The name of the effect.
  39477. * @param options The required width/height ratio to downsize to before computing the render pass.
  39478. * @param camera The camera to apply the render pass to.
  39479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39480. * @param engine The engine which the post process will be applied. (default: current engine)
  39481. * @param reusable If the post process can be reused on the same frame. (default: false)
  39482. * @param textureType The type of texture to be used when performing the post processing.
  39483. * @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)
  39484. */
  39485. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39486. }
  39487. /**
  39488. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39489. */
  39490. export class PassCubePostProcess extends PostProcess {
  39491. private _face;
  39492. /**
  39493. * Gets or sets the cube face to display.
  39494. * * 0 is +X
  39495. * * 1 is -X
  39496. * * 2 is +Y
  39497. * * 3 is -Y
  39498. * * 4 is +Z
  39499. * * 5 is -Z
  39500. */
  39501. face: number;
  39502. /**
  39503. * Creates the PassCubePostProcess
  39504. * @param name The name of the effect.
  39505. * @param options The required width/height ratio to downsize to before computing the render pass.
  39506. * @param camera The camera to apply the render pass to.
  39507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39508. * @param engine The engine which the post process will be applied. (default: current engine)
  39509. * @param reusable If the post process can be reused on the same frame. (default: false)
  39510. * @param textureType The type of texture to be used when performing the post processing.
  39511. * @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)
  39512. */
  39513. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39514. }
  39515. }
  39516. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39517. /** @hidden */
  39518. export var anaglyphPixelShader: {
  39519. name: string;
  39520. shader: string;
  39521. };
  39522. }
  39523. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39524. import { Engine } from "babylonjs/Engines/engine";
  39525. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39526. import { Camera } from "babylonjs/Cameras/camera";
  39527. import "babylonjs/Shaders/anaglyph.fragment";
  39528. /**
  39529. * Postprocess used to generate anaglyphic rendering
  39530. */
  39531. export class AnaglyphPostProcess extends PostProcess {
  39532. private _passedProcess;
  39533. /**
  39534. * Creates a new AnaglyphPostProcess
  39535. * @param name defines postprocess name
  39536. * @param options defines creation options or target ratio scale
  39537. * @param rigCameras defines cameras using this postprocess
  39538. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39539. * @param engine defines hosting engine
  39540. * @param reusable defines if the postprocess will be reused multiple times per frame
  39541. */
  39542. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39543. }
  39544. }
  39545. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39546. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39547. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39548. import { Scene } from "babylonjs/scene";
  39549. import { Vector3 } from "babylonjs/Maths/math";
  39550. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39551. /**
  39552. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39553. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39554. */
  39555. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39556. /**
  39557. * Creates a new AnaglyphArcRotateCamera
  39558. * @param name defines camera name
  39559. * @param alpha defines alpha angle (in radians)
  39560. * @param beta defines beta angle (in radians)
  39561. * @param radius defines radius
  39562. * @param target defines camera target
  39563. * @param interaxialDistance defines distance between each color axis
  39564. * @param scene defines the hosting scene
  39565. */
  39566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39567. /**
  39568. * Gets camera class name
  39569. * @returns AnaglyphArcRotateCamera
  39570. */
  39571. getClassName(): string;
  39572. }
  39573. }
  39574. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39575. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39576. import { Scene } from "babylonjs/scene";
  39577. import { Vector3 } from "babylonjs/Maths/math";
  39578. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39579. /**
  39580. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39581. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39582. */
  39583. export class AnaglyphFreeCamera extends FreeCamera {
  39584. /**
  39585. * Creates a new AnaglyphFreeCamera
  39586. * @param name defines camera name
  39587. * @param position defines initial position
  39588. * @param interaxialDistance defines distance between each color axis
  39589. * @param scene defines the hosting scene
  39590. */
  39591. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39592. /**
  39593. * Gets camera class name
  39594. * @returns AnaglyphFreeCamera
  39595. */
  39596. getClassName(): string;
  39597. }
  39598. }
  39599. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39600. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39601. import { Scene } from "babylonjs/scene";
  39602. import { Vector3 } from "babylonjs/Maths/math";
  39603. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39604. /**
  39605. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39606. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39607. */
  39608. export class AnaglyphGamepadCamera extends GamepadCamera {
  39609. /**
  39610. * Creates a new AnaglyphGamepadCamera
  39611. * @param name defines camera name
  39612. * @param position defines initial position
  39613. * @param interaxialDistance defines distance between each color axis
  39614. * @param scene defines the hosting scene
  39615. */
  39616. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39617. /**
  39618. * Gets camera class name
  39619. * @returns AnaglyphGamepadCamera
  39620. */
  39621. getClassName(): string;
  39622. }
  39623. }
  39624. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39625. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39626. import { Scene } from "babylonjs/scene";
  39627. import { Vector3 } from "babylonjs/Maths/math";
  39628. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39629. /**
  39630. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39631. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39632. */
  39633. export class AnaglyphUniversalCamera extends UniversalCamera {
  39634. /**
  39635. * Creates a new AnaglyphUniversalCamera
  39636. * @param name defines camera name
  39637. * @param position defines initial position
  39638. * @param interaxialDistance defines distance between each color axis
  39639. * @param scene defines the hosting scene
  39640. */
  39641. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39642. /**
  39643. * Gets camera class name
  39644. * @returns AnaglyphUniversalCamera
  39645. */
  39646. getClassName(): string;
  39647. }
  39648. }
  39649. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39650. /** @hidden */
  39651. export var stereoscopicInterlacePixelShader: {
  39652. name: string;
  39653. shader: string;
  39654. };
  39655. }
  39656. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39657. import { Camera } from "babylonjs/Cameras/camera";
  39658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39659. import { Engine } from "babylonjs/Engines/engine";
  39660. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39661. /**
  39662. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39663. */
  39664. export class StereoscopicInterlacePostProcess extends PostProcess {
  39665. private _stepSize;
  39666. private _passedProcess;
  39667. /**
  39668. * Initializes a StereoscopicInterlacePostProcess
  39669. * @param name The name of the effect.
  39670. * @param rigCameras The rig cameras to be appled to the post process
  39671. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39673. * @param engine The engine which the post process will be applied. (default: current engine)
  39674. * @param reusable If the post process can be reused on the same frame. (default: false)
  39675. */
  39676. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39677. }
  39678. }
  39679. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39680. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39681. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39682. import { Scene } from "babylonjs/scene";
  39683. import { Vector3 } from "babylonjs/Maths/math";
  39684. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39685. /**
  39686. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39687. * @see http://doc.babylonjs.com/features/cameras
  39688. */
  39689. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39690. /**
  39691. * Creates a new StereoscopicArcRotateCamera
  39692. * @param name defines camera name
  39693. * @param alpha defines alpha angle (in radians)
  39694. * @param beta defines beta angle (in radians)
  39695. * @param radius defines radius
  39696. * @param target defines camera target
  39697. * @param interaxialDistance defines distance between each color axis
  39698. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39699. * @param scene defines the hosting scene
  39700. */
  39701. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39702. /**
  39703. * Gets camera class name
  39704. * @returns StereoscopicArcRotateCamera
  39705. */
  39706. getClassName(): string;
  39707. }
  39708. }
  39709. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39710. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39711. import { Scene } from "babylonjs/scene";
  39712. import { Vector3 } from "babylonjs/Maths/math";
  39713. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39714. /**
  39715. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39716. * @see http://doc.babylonjs.com/features/cameras
  39717. */
  39718. export class StereoscopicFreeCamera extends FreeCamera {
  39719. /**
  39720. * Creates a new StereoscopicFreeCamera
  39721. * @param name defines camera name
  39722. * @param position defines initial position
  39723. * @param interaxialDistance defines distance between each color axis
  39724. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39725. * @param scene defines the hosting scene
  39726. */
  39727. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39728. /**
  39729. * Gets camera class name
  39730. * @returns StereoscopicFreeCamera
  39731. */
  39732. getClassName(): string;
  39733. }
  39734. }
  39735. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39736. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39737. import { Scene } from "babylonjs/scene";
  39738. import { Vector3 } from "babylonjs/Maths/math";
  39739. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39740. /**
  39741. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39742. * @see http://doc.babylonjs.com/features/cameras
  39743. */
  39744. export class StereoscopicGamepadCamera extends GamepadCamera {
  39745. /**
  39746. * Creates a new StereoscopicGamepadCamera
  39747. * @param name defines camera name
  39748. * @param position defines initial position
  39749. * @param interaxialDistance defines distance between each color axis
  39750. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39751. * @param scene defines the hosting scene
  39752. */
  39753. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39754. /**
  39755. * Gets camera class name
  39756. * @returns StereoscopicGamepadCamera
  39757. */
  39758. getClassName(): string;
  39759. }
  39760. }
  39761. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39762. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39763. import { Scene } from "babylonjs/scene";
  39764. import { Vector3 } from "babylonjs/Maths/math";
  39765. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39766. /**
  39767. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39768. * @see http://doc.babylonjs.com/features/cameras
  39769. */
  39770. export class StereoscopicUniversalCamera extends UniversalCamera {
  39771. /**
  39772. * Creates a new StereoscopicUniversalCamera
  39773. * @param name defines camera name
  39774. * @param position defines initial position
  39775. * @param interaxialDistance defines distance between each color axis
  39776. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39777. * @param scene defines the hosting scene
  39778. */
  39779. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39780. /**
  39781. * Gets camera class name
  39782. * @returns StereoscopicUniversalCamera
  39783. */
  39784. getClassName(): string;
  39785. }
  39786. }
  39787. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39788. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39789. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39790. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39791. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39792. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39793. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39794. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39795. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39796. }
  39797. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39798. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39799. import { Scene } from "babylonjs/scene";
  39800. import { Vector3 } from "babylonjs/Maths/math";
  39801. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39802. /**
  39803. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39804. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39805. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39806. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39807. */
  39808. export class VirtualJoysticksCamera extends FreeCamera {
  39809. /**
  39810. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39811. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39812. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39813. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39814. * @param name Define the name of the camera in the scene
  39815. * @param position Define the start position of the camera in the scene
  39816. * @param scene Define the scene the camera belongs to
  39817. */
  39818. constructor(name: string, position: Vector3, scene: Scene);
  39819. /**
  39820. * Gets the current object class name.
  39821. * @return the class name
  39822. */
  39823. getClassName(): string;
  39824. }
  39825. }
  39826. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39827. import { Matrix } from "babylonjs/Maths/math";
  39828. /**
  39829. * This represents all the required metrics to create a VR camera.
  39830. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39831. */
  39832. export class VRCameraMetrics {
  39833. /**
  39834. * Define the horizontal resolution off the screen.
  39835. */
  39836. hResolution: number;
  39837. /**
  39838. * Define the vertical resolution off the screen.
  39839. */
  39840. vResolution: number;
  39841. /**
  39842. * Define the horizontal screen size.
  39843. */
  39844. hScreenSize: number;
  39845. /**
  39846. * Define the vertical screen size.
  39847. */
  39848. vScreenSize: number;
  39849. /**
  39850. * Define the vertical screen center position.
  39851. */
  39852. vScreenCenter: number;
  39853. /**
  39854. * Define the distance of the eyes to the screen.
  39855. */
  39856. eyeToScreenDistance: number;
  39857. /**
  39858. * Define the distance between both lenses
  39859. */
  39860. lensSeparationDistance: number;
  39861. /**
  39862. * Define the distance between both viewer's eyes.
  39863. */
  39864. interpupillaryDistance: number;
  39865. /**
  39866. * Define the distortion factor of the VR postprocess.
  39867. * Please, touch with care.
  39868. */
  39869. distortionK: number[];
  39870. /**
  39871. * Define the chromatic aberration correction factors for the VR post process.
  39872. */
  39873. chromaAbCorrection: number[];
  39874. /**
  39875. * Define the scale factor of the post process.
  39876. * The smaller the better but the slower.
  39877. */
  39878. postProcessScaleFactor: number;
  39879. /**
  39880. * Define an offset for the lens center.
  39881. */
  39882. lensCenterOffset: number;
  39883. /**
  39884. * Define if the current vr camera should compensate the distortion of the lense or not.
  39885. */
  39886. compensateDistortion: boolean;
  39887. /**
  39888. * Defines if multiview should be enabled when rendering (Default: false)
  39889. */
  39890. multiviewEnabled: boolean;
  39891. /**
  39892. * Gets the rendering aspect ratio based on the provided resolutions.
  39893. */
  39894. readonly aspectRatio: number;
  39895. /**
  39896. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39897. */
  39898. readonly aspectRatioFov: number;
  39899. /**
  39900. * @hidden
  39901. */
  39902. readonly leftHMatrix: Matrix;
  39903. /**
  39904. * @hidden
  39905. */
  39906. readonly rightHMatrix: Matrix;
  39907. /**
  39908. * @hidden
  39909. */
  39910. readonly leftPreViewMatrix: Matrix;
  39911. /**
  39912. * @hidden
  39913. */
  39914. readonly rightPreViewMatrix: Matrix;
  39915. /**
  39916. * Get the default VRMetrics based on the most generic setup.
  39917. * @returns the default vr metrics
  39918. */
  39919. static GetDefault(): VRCameraMetrics;
  39920. }
  39921. }
  39922. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39923. /** @hidden */
  39924. export var vrDistortionCorrectionPixelShader: {
  39925. name: string;
  39926. shader: string;
  39927. };
  39928. }
  39929. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39930. import { Camera } from "babylonjs/Cameras/camera";
  39931. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39933. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39934. /**
  39935. * VRDistortionCorrectionPostProcess used for mobile VR
  39936. */
  39937. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39938. private _isRightEye;
  39939. private _distortionFactors;
  39940. private _postProcessScaleFactor;
  39941. private _lensCenterOffset;
  39942. private _scaleIn;
  39943. private _scaleFactor;
  39944. private _lensCenter;
  39945. /**
  39946. * Initializes the VRDistortionCorrectionPostProcess
  39947. * @param name The name of the effect.
  39948. * @param camera The camera to apply the render pass to.
  39949. * @param isRightEye If this is for the right eye distortion
  39950. * @param vrMetrics All the required metrics for the VR camera
  39951. */
  39952. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39953. }
  39954. }
  39955. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39956. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39957. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39958. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39959. import { Scene } from "babylonjs/scene";
  39960. import { Vector3 } from "babylonjs/Maths/math";
  39961. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39962. import "babylonjs/Cameras/RigModes/vrRigMode";
  39963. /**
  39964. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39965. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39966. */
  39967. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39968. /**
  39969. * Creates a new VRDeviceOrientationArcRotateCamera
  39970. * @param name defines camera name
  39971. * @param alpha defines the camera rotation along the logitudinal axis
  39972. * @param beta defines the camera rotation along the latitudinal axis
  39973. * @param radius defines the camera distance from its target
  39974. * @param target defines the camera target
  39975. * @param scene defines the scene the camera belongs to
  39976. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39977. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39978. */
  39979. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39980. /**
  39981. * Gets camera class name
  39982. * @returns VRDeviceOrientationArcRotateCamera
  39983. */
  39984. getClassName(): string;
  39985. }
  39986. }
  39987. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39988. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39989. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39990. import { Scene } from "babylonjs/scene";
  39991. import { Vector3 } from "babylonjs/Maths/math";
  39992. import "babylonjs/Cameras/RigModes/vrRigMode";
  39993. /**
  39994. * Camera used to simulate VR rendering (based on FreeCamera)
  39995. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39996. */
  39997. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39998. /**
  39999. * Creates a new VRDeviceOrientationFreeCamera
  40000. * @param name defines camera name
  40001. * @param position defines the start position of the camera
  40002. * @param scene defines the scene the camera belongs to
  40003. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40004. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40005. */
  40006. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40007. /**
  40008. * Gets camera class name
  40009. * @returns VRDeviceOrientationFreeCamera
  40010. */
  40011. getClassName(): string;
  40012. }
  40013. }
  40014. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40015. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40016. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40017. import { Scene } from "babylonjs/scene";
  40018. import { Vector3 } from "babylonjs/Maths/math";
  40019. import "babylonjs/Gamepads/gamepadSceneComponent";
  40020. /**
  40021. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40022. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40023. */
  40024. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40025. /**
  40026. * Creates a new VRDeviceOrientationGamepadCamera
  40027. * @param name defines camera name
  40028. * @param position defines the start position of the camera
  40029. * @param scene defines the scene the camera belongs to
  40030. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40031. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40032. */
  40033. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40034. /**
  40035. * Gets camera class name
  40036. * @returns VRDeviceOrientationGamepadCamera
  40037. */
  40038. getClassName(): string;
  40039. }
  40040. }
  40041. declare module "babylonjs/Materials/pushMaterial" {
  40042. import { Nullable } from "babylonjs/types";
  40043. import { Scene } from "babylonjs/scene";
  40044. import { Matrix } from "babylonjs/Maths/math";
  40045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40046. import { Mesh } from "babylonjs/Meshes/mesh";
  40047. import { Material } from "babylonjs/Materials/material";
  40048. import { Effect } from "babylonjs/Materials/effect";
  40049. /**
  40050. * Base class of materials working in push mode in babylon JS
  40051. * @hidden
  40052. */
  40053. export class PushMaterial extends Material {
  40054. protected _activeEffect: Effect;
  40055. protected _normalMatrix: Matrix;
  40056. /**
  40057. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40058. * This means that the material can keep using a previous shader while a new one is being compiled.
  40059. * This is mostly used when shader parallel compilation is supported (true by default)
  40060. */
  40061. allowShaderHotSwapping: boolean;
  40062. constructor(name: string, scene: Scene);
  40063. getEffect(): Effect;
  40064. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40065. /**
  40066. * Binds the given world matrix to the active effect
  40067. *
  40068. * @param world the matrix to bind
  40069. */
  40070. bindOnlyWorldMatrix(world: Matrix): void;
  40071. /**
  40072. * Binds the given normal matrix to the active effect
  40073. *
  40074. * @param normalMatrix the matrix to bind
  40075. */
  40076. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40077. bind(world: Matrix, mesh?: Mesh): void;
  40078. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40079. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40080. }
  40081. }
  40082. declare module "babylonjs/Materials/materialFlags" {
  40083. /**
  40084. * This groups all the flags used to control the materials channel.
  40085. */
  40086. export class MaterialFlags {
  40087. private static _DiffuseTextureEnabled;
  40088. /**
  40089. * Are diffuse textures enabled in the application.
  40090. */
  40091. static DiffuseTextureEnabled: boolean;
  40092. private static _AmbientTextureEnabled;
  40093. /**
  40094. * Are ambient textures enabled in the application.
  40095. */
  40096. static AmbientTextureEnabled: boolean;
  40097. private static _OpacityTextureEnabled;
  40098. /**
  40099. * Are opacity textures enabled in the application.
  40100. */
  40101. static OpacityTextureEnabled: boolean;
  40102. private static _ReflectionTextureEnabled;
  40103. /**
  40104. * Are reflection textures enabled in the application.
  40105. */
  40106. static ReflectionTextureEnabled: boolean;
  40107. private static _EmissiveTextureEnabled;
  40108. /**
  40109. * Are emissive textures enabled in the application.
  40110. */
  40111. static EmissiveTextureEnabled: boolean;
  40112. private static _SpecularTextureEnabled;
  40113. /**
  40114. * Are specular textures enabled in the application.
  40115. */
  40116. static SpecularTextureEnabled: boolean;
  40117. private static _BumpTextureEnabled;
  40118. /**
  40119. * Are bump textures enabled in the application.
  40120. */
  40121. static BumpTextureEnabled: boolean;
  40122. private static _LightmapTextureEnabled;
  40123. /**
  40124. * Are lightmap textures enabled in the application.
  40125. */
  40126. static LightmapTextureEnabled: boolean;
  40127. private static _RefractionTextureEnabled;
  40128. /**
  40129. * Are refraction textures enabled in the application.
  40130. */
  40131. static RefractionTextureEnabled: boolean;
  40132. private static _ColorGradingTextureEnabled;
  40133. /**
  40134. * Are color grading textures enabled in the application.
  40135. */
  40136. static ColorGradingTextureEnabled: boolean;
  40137. private static _FresnelEnabled;
  40138. /**
  40139. * Are fresnels enabled in the application.
  40140. */
  40141. static FresnelEnabled: boolean;
  40142. private static _ClearCoatTextureEnabled;
  40143. /**
  40144. * Are clear coat textures enabled in the application.
  40145. */
  40146. static ClearCoatTextureEnabled: boolean;
  40147. private static _ClearCoatBumpTextureEnabled;
  40148. /**
  40149. * Are clear coat bump textures enabled in the application.
  40150. */
  40151. static ClearCoatBumpTextureEnabled: boolean;
  40152. private static _ClearCoatTintTextureEnabled;
  40153. /**
  40154. * Are clear coat tint textures enabled in the application.
  40155. */
  40156. static ClearCoatTintTextureEnabled: boolean;
  40157. private static _SheenTextureEnabled;
  40158. /**
  40159. * Are sheen textures enabled in the application.
  40160. */
  40161. static SheenTextureEnabled: boolean;
  40162. private static _AnisotropicTextureEnabled;
  40163. /**
  40164. * Are anisotropic textures enabled in the application.
  40165. */
  40166. static AnisotropicTextureEnabled: boolean;
  40167. private static _ThicknessTextureEnabled;
  40168. /**
  40169. * Are thickness textures enabled in the application.
  40170. */
  40171. static ThicknessTextureEnabled: boolean;
  40172. }
  40173. }
  40174. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40175. /** @hidden */
  40176. export var defaultFragmentDeclaration: {
  40177. name: string;
  40178. shader: string;
  40179. };
  40180. }
  40181. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40182. /** @hidden */
  40183. export var defaultUboDeclaration: {
  40184. name: string;
  40185. shader: string;
  40186. };
  40187. }
  40188. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40189. /** @hidden */
  40190. export var lightFragmentDeclaration: {
  40191. name: string;
  40192. shader: string;
  40193. };
  40194. }
  40195. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40196. /** @hidden */
  40197. export var lightUboDeclaration: {
  40198. name: string;
  40199. shader: string;
  40200. };
  40201. }
  40202. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40203. /** @hidden */
  40204. export var lightsFragmentFunctions: {
  40205. name: string;
  40206. shader: string;
  40207. };
  40208. }
  40209. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40210. /** @hidden */
  40211. export var shadowsFragmentFunctions: {
  40212. name: string;
  40213. shader: string;
  40214. };
  40215. }
  40216. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40217. /** @hidden */
  40218. export var fresnelFunction: {
  40219. name: string;
  40220. shader: string;
  40221. };
  40222. }
  40223. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40224. /** @hidden */
  40225. export var reflectionFunction: {
  40226. name: string;
  40227. shader: string;
  40228. };
  40229. }
  40230. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40231. /** @hidden */
  40232. export var bumpFragmentFunctions: {
  40233. name: string;
  40234. shader: string;
  40235. };
  40236. }
  40237. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40238. /** @hidden */
  40239. export var logDepthDeclaration: {
  40240. name: string;
  40241. shader: string;
  40242. };
  40243. }
  40244. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40245. /** @hidden */
  40246. export var bumpFragment: {
  40247. name: string;
  40248. shader: string;
  40249. };
  40250. }
  40251. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40252. /** @hidden */
  40253. export var depthPrePass: {
  40254. name: string;
  40255. shader: string;
  40256. };
  40257. }
  40258. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40259. /** @hidden */
  40260. export var lightFragment: {
  40261. name: string;
  40262. shader: string;
  40263. };
  40264. }
  40265. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40266. /** @hidden */
  40267. export var logDepthFragment: {
  40268. name: string;
  40269. shader: string;
  40270. };
  40271. }
  40272. declare module "babylonjs/Shaders/default.fragment" {
  40273. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40274. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40275. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40276. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40277. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40278. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40279. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40280. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40281. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40282. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40283. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40284. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40285. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40286. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40287. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40288. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40289. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40290. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40291. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40292. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40293. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40294. /** @hidden */
  40295. export var defaultPixelShader: {
  40296. name: string;
  40297. shader: string;
  40298. };
  40299. }
  40300. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40301. /** @hidden */
  40302. export var defaultVertexDeclaration: {
  40303. name: string;
  40304. shader: string;
  40305. };
  40306. }
  40307. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40308. /** @hidden */
  40309. export var bumpVertexDeclaration: {
  40310. name: string;
  40311. shader: string;
  40312. };
  40313. }
  40314. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40315. /** @hidden */
  40316. export var bumpVertex: {
  40317. name: string;
  40318. shader: string;
  40319. };
  40320. }
  40321. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40322. /** @hidden */
  40323. export var fogVertex: {
  40324. name: string;
  40325. shader: string;
  40326. };
  40327. }
  40328. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40329. /** @hidden */
  40330. export var shadowsVertex: {
  40331. name: string;
  40332. shader: string;
  40333. };
  40334. }
  40335. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40336. /** @hidden */
  40337. export var pointCloudVertex: {
  40338. name: string;
  40339. shader: string;
  40340. };
  40341. }
  40342. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40343. /** @hidden */
  40344. export var logDepthVertex: {
  40345. name: string;
  40346. shader: string;
  40347. };
  40348. }
  40349. declare module "babylonjs/Shaders/default.vertex" {
  40350. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40351. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40352. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40353. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40354. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40355. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40356. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40357. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40358. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40359. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40360. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40361. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40362. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40363. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40364. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40365. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40366. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40367. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40368. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40369. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40370. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40371. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40372. /** @hidden */
  40373. export var defaultVertexShader: {
  40374. name: string;
  40375. shader: string;
  40376. };
  40377. }
  40378. declare module "babylonjs/Materials/standardMaterial" {
  40379. import { SmartArray } from "babylonjs/Misc/smartArray";
  40380. import { IAnimatable } from "babylonjs/Misc/tools";
  40381. import { Nullable } from "babylonjs/types";
  40382. import { Scene } from "babylonjs/scene";
  40383. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40384. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40386. import { Mesh } from "babylonjs/Meshes/mesh";
  40387. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40388. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40389. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40390. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40391. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40394. import "babylonjs/Shaders/default.fragment";
  40395. import "babylonjs/Shaders/default.vertex";
  40396. /** @hidden */
  40397. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40398. MAINUV1: boolean;
  40399. MAINUV2: boolean;
  40400. DIFFUSE: boolean;
  40401. DIFFUSEDIRECTUV: number;
  40402. AMBIENT: boolean;
  40403. AMBIENTDIRECTUV: number;
  40404. OPACITY: boolean;
  40405. OPACITYDIRECTUV: number;
  40406. OPACITYRGB: boolean;
  40407. REFLECTION: boolean;
  40408. EMISSIVE: boolean;
  40409. EMISSIVEDIRECTUV: number;
  40410. SPECULAR: boolean;
  40411. SPECULARDIRECTUV: number;
  40412. BUMP: boolean;
  40413. BUMPDIRECTUV: number;
  40414. PARALLAX: boolean;
  40415. PARALLAXOCCLUSION: boolean;
  40416. SPECULAROVERALPHA: boolean;
  40417. CLIPPLANE: boolean;
  40418. CLIPPLANE2: boolean;
  40419. CLIPPLANE3: boolean;
  40420. CLIPPLANE4: boolean;
  40421. ALPHATEST: boolean;
  40422. DEPTHPREPASS: boolean;
  40423. ALPHAFROMDIFFUSE: boolean;
  40424. POINTSIZE: boolean;
  40425. FOG: boolean;
  40426. SPECULARTERM: boolean;
  40427. DIFFUSEFRESNEL: boolean;
  40428. OPACITYFRESNEL: boolean;
  40429. REFLECTIONFRESNEL: boolean;
  40430. REFRACTIONFRESNEL: boolean;
  40431. EMISSIVEFRESNEL: boolean;
  40432. FRESNEL: boolean;
  40433. NORMAL: boolean;
  40434. UV1: boolean;
  40435. UV2: boolean;
  40436. VERTEXCOLOR: boolean;
  40437. VERTEXALPHA: boolean;
  40438. NUM_BONE_INFLUENCERS: number;
  40439. BonesPerMesh: number;
  40440. BONETEXTURE: boolean;
  40441. INSTANCES: boolean;
  40442. GLOSSINESS: boolean;
  40443. ROUGHNESS: boolean;
  40444. EMISSIVEASILLUMINATION: boolean;
  40445. LINKEMISSIVEWITHDIFFUSE: boolean;
  40446. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40447. LIGHTMAP: boolean;
  40448. LIGHTMAPDIRECTUV: number;
  40449. OBJECTSPACE_NORMALMAP: boolean;
  40450. USELIGHTMAPASSHADOWMAP: boolean;
  40451. REFLECTIONMAP_3D: boolean;
  40452. REFLECTIONMAP_SPHERICAL: boolean;
  40453. REFLECTIONMAP_PLANAR: boolean;
  40454. REFLECTIONMAP_CUBIC: boolean;
  40455. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40456. REFLECTIONMAP_PROJECTION: boolean;
  40457. REFLECTIONMAP_SKYBOX: boolean;
  40458. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40459. REFLECTIONMAP_EXPLICIT: boolean;
  40460. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40461. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40462. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40463. INVERTCUBICMAP: boolean;
  40464. LOGARITHMICDEPTH: boolean;
  40465. REFRACTION: boolean;
  40466. REFRACTIONMAP_3D: boolean;
  40467. REFLECTIONOVERALPHA: boolean;
  40468. TWOSIDEDLIGHTING: boolean;
  40469. SHADOWFLOAT: boolean;
  40470. MORPHTARGETS: boolean;
  40471. MORPHTARGETS_NORMAL: boolean;
  40472. MORPHTARGETS_TANGENT: boolean;
  40473. MORPHTARGETS_UV: boolean;
  40474. NUM_MORPH_INFLUENCERS: number;
  40475. NONUNIFORMSCALING: boolean;
  40476. PREMULTIPLYALPHA: boolean;
  40477. IMAGEPROCESSING: boolean;
  40478. VIGNETTE: boolean;
  40479. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40480. VIGNETTEBLENDMODEOPAQUE: boolean;
  40481. TONEMAPPING: boolean;
  40482. TONEMAPPING_ACES: boolean;
  40483. CONTRAST: boolean;
  40484. COLORCURVES: boolean;
  40485. COLORGRADING: boolean;
  40486. COLORGRADING3D: boolean;
  40487. SAMPLER3DGREENDEPTH: boolean;
  40488. SAMPLER3DBGRMAP: boolean;
  40489. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40490. MULTIVIEW: boolean;
  40491. /**
  40492. * If the reflection texture on this material is in linear color space
  40493. * @hidden
  40494. */
  40495. IS_REFLECTION_LINEAR: boolean;
  40496. /**
  40497. * If the refraction texture on this material is in linear color space
  40498. * @hidden
  40499. */
  40500. IS_REFRACTION_LINEAR: boolean;
  40501. EXPOSURE: boolean;
  40502. constructor();
  40503. setReflectionMode(modeToEnable: string): void;
  40504. }
  40505. /**
  40506. * This is the default material used in Babylon. It is the best trade off between quality
  40507. * and performances.
  40508. * @see http://doc.babylonjs.com/babylon101/materials
  40509. */
  40510. export class StandardMaterial extends PushMaterial {
  40511. private _diffuseTexture;
  40512. /**
  40513. * The basic texture of the material as viewed under a light.
  40514. */
  40515. diffuseTexture: Nullable<BaseTexture>;
  40516. private _ambientTexture;
  40517. /**
  40518. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40519. */
  40520. ambientTexture: Nullable<BaseTexture>;
  40521. private _opacityTexture;
  40522. /**
  40523. * Define the transparency of the material from a texture.
  40524. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40525. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40526. */
  40527. opacityTexture: Nullable<BaseTexture>;
  40528. private _reflectionTexture;
  40529. /**
  40530. * Define the texture used to display the reflection.
  40531. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40532. */
  40533. reflectionTexture: Nullable<BaseTexture>;
  40534. private _emissiveTexture;
  40535. /**
  40536. * Define texture of the material as if self lit.
  40537. * This will be mixed in the final result even in the absence of light.
  40538. */
  40539. emissiveTexture: Nullable<BaseTexture>;
  40540. private _specularTexture;
  40541. /**
  40542. * Define how the color and intensity of the highlight given by the light in the material.
  40543. */
  40544. specularTexture: Nullable<BaseTexture>;
  40545. private _bumpTexture;
  40546. /**
  40547. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40548. * 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.
  40549. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40550. */
  40551. bumpTexture: Nullable<BaseTexture>;
  40552. private _lightmapTexture;
  40553. /**
  40554. * Complex lighting can be computationally expensive to compute at runtime.
  40555. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40556. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40557. */
  40558. lightmapTexture: Nullable<BaseTexture>;
  40559. private _refractionTexture;
  40560. /**
  40561. * Define the texture used to display the refraction.
  40562. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40563. */
  40564. refractionTexture: Nullable<BaseTexture>;
  40565. /**
  40566. * The color of the material lit by the environmental background lighting.
  40567. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40568. */
  40569. ambientColor: Color3;
  40570. /**
  40571. * The basic color of the material as viewed under a light.
  40572. */
  40573. diffuseColor: Color3;
  40574. /**
  40575. * Define how the color and intensity of the highlight given by the light in the material.
  40576. */
  40577. specularColor: Color3;
  40578. /**
  40579. * Define the color of the material as if self lit.
  40580. * This will be mixed in the final result even in the absence of light.
  40581. */
  40582. emissiveColor: Color3;
  40583. /**
  40584. * Defines how sharp are the highlights in the material.
  40585. * The bigger the value the sharper giving a more glossy feeling to the result.
  40586. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40587. */
  40588. specularPower: number;
  40589. private _useAlphaFromDiffuseTexture;
  40590. /**
  40591. * Does the transparency come from the diffuse texture alpha channel.
  40592. */
  40593. useAlphaFromDiffuseTexture: boolean;
  40594. private _useEmissiveAsIllumination;
  40595. /**
  40596. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40597. */
  40598. useEmissiveAsIllumination: boolean;
  40599. private _linkEmissiveWithDiffuse;
  40600. /**
  40601. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40602. * the emissive level when the final color is close to one.
  40603. */
  40604. linkEmissiveWithDiffuse: boolean;
  40605. private _useSpecularOverAlpha;
  40606. /**
  40607. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40608. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40609. */
  40610. useSpecularOverAlpha: boolean;
  40611. private _useReflectionOverAlpha;
  40612. /**
  40613. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40614. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40615. */
  40616. useReflectionOverAlpha: boolean;
  40617. private _disableLighting;
  40618. /**
  40619. * Does lights from the scene impacts this material.
  40620. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40621. */
  40622. disableLighting: boolean;
  40623. private _useObjectSpaceNormalMap;
  40624. /**
  40625. * Allows using an object space normal map (instead of tangent space).
  40626. */
  40627. useObjectSpaceNormalMap: boolean;
  40628. private _useParallax;
  40629. /**
  40630. * Is parallax enabled or not.
  40631. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40632. */
  40633. useParallax: boolean;
  40634. private _useParallaxOcclusion;
  40635. /**
  40636. * Is parallax occlusion enabled or not.
  40637. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40638. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40639. */
  40640. useParallaxOcclusion: boolean;
  40641. /**
  40642. * 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.
  40643. */
  40644. parallaxScaleBias: number;
  40645. private _roughness;
  40646. /**
  40647. * Helps to define how blurry the reflections should appears in the material.
  40648. */
  40649. roughness: number;
  40650. /**
  40651. * In case of refraction, define the value of the index of refraction.
  40652. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40653. */
  40654. indexOfRefraction: number;
  40655. /**
  40656. * Invert the refraction texture alongside the y axis.
  40657. * It can be useful with procedural textures or probe for instance.
  40658. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40659. */
  40660. invertRefractionY: boolean;
  40661. /**
  40662. * Defines the alpha limits in alpha test mode.
  40663. */
  40664. alphaCutOff: number;
  40665. private _useLightmapAsShadowmap;
  40666. /**
  40667. * In case of light mapping, define whether the map contains light or shadow informations.
  40668. */
  40669. useLightmapAsShadowmap: boolean;
  40670. private _diffuseFresnelParameters;
  40671. /**
  40672. * Define the diffuse fresnel parameters of the material.
  40673. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40674. */
  40675. diffuseFresnelParameters: FresnelParameters;
  40676. private _opacityFresnelParameters;
  40677. /**
  40678. * Define the opacity fresnel parameters of the material.
  40679. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40680. */
  40681. opacityFresnelParameters: FresnelParameters;
  40682. private _reflectionFresnelParameters;
  40683. /**
  40684. * Define the reflection fresnel parameters of the material.
  40685. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40686. */
  40687. reflectionFresnelParameters: FresnelParameters;
  40688. private _refractionFresnelParameters;
  40689. /**
  40690. * Define the refraction fresnel parameters of the material.
  40691. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40692. */
  40693. refractionFresnelParameters: FresnelParameters;
  40694. private _emissiveFresnelParameters;
  40695. /**
  40696. * Define the emissive fresnel parameters of the material.
  40697. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40698. */
  40699. emissiveFresnelParameters: FresnelParameters;
  40700. private _useReflectionFresnelFromSpecular;
  40701. /**
  40702. * If true automatically deducts the fresnels values from the material specularity.
  40703. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40704. */
  40705. useReflectionFresnelFromSpecular: boolean;
  40706. private _useGlossinessFromSpecularMapAlpha;
  40707. /**
  40708. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40709. */
  40710. useGlossinessFromSpecularMapAlpha: boolean;
  40711. private _maxSimultaneousLights;
  40712. /**
  40713. * Defines the maximum number of lights that can be used in the material
  40714. */
  40715. maxSimultaneousLights: number;
  40716. private _invertNormalMapX;
  40717. /**
  40718. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40719. */
  40720. invertNormalMapX: boolean;
  40721. private _invertNormalMapY;
  40722. /**
  40723. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40724. */
  40725. invertNormalMapY: boolean;
  40726. private _twoSidedLighting;
  40727. /**
  40728. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40729. */
  40730. twoSidedLighting: boolean;
  40731. /**
  40732. * Default configuration related to image processing available in the standard Material.
  40733. */
  40734. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40735. /**
  40736. * Gets the image processing configuration used either in this material.
  40737. */
  40738. /**
  40739. * Sets the Default image processing configuration used either in the this material.
  40740. *
  40741. * If sets to null, the scene one is in use.
  40742. */
  40743. imageProcessingConfiguration: ImageProcessingConfiguration;
  40744. /**
  40745. * Keep track of the image processing observer to allow dispose and replace.
  40746. */
  40747. private _imageProcessingObserver;
  40748. /**
  40749. * Attaches a new image processing configuration to the Standard Material.
  40750. * @param configuration
  40751. */
  40752. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40753. /**
  40754. * Gets wether the color curves effect is enabled.
  40755. */
  40756. /**
  40757. * Sets wether the color curves effect is enabled.
  40758. */
  40759. cameraColorCurvesEnabled: boolean;
  40760. /**
  40761. * Gets wether the color grading effect is enabled.
  40762. */
  40763. /**
  40764. * Gets wether the color grading effect is enabled.
  40765. */
  40766. cameraColorGradingEnabled: boolean;
  40767. /**
  40768. * Gets wether tonemapping is enabled or not.
  40769. */
  40770. /**
  40771. * Sets wether tonemapping is enabled or not
  40772. */
  40773. cameraToneMappingEnabled: boolean;
  40774. /**
  40775. * The camera exposure used on this material.
  40776. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40777. * This corresponds to a photographic exposure.
  40778. */
  40779. /**
  40780. * The camera exposure used on this material.
  40781. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40782. * This corresponds to a photographic exposure.
  40783. */
  40784. cameraExposure: number;
  40785. /**
  40786. * Gets The camera contrast used on this material.
  40787. */
  40788. /**
  40789. * Sets The camera contrast used on this material.
  40790. */
  40791. cameraContrast: number;
  40792. /**
  40793. * Gets the Color Grading 2D Lookup Texture.
  40794. */
  40795. /**
  40796. * Sets the Color Grading 2D Lookup Texture.
  40797. */
  40798. cameraColorGradingTexture: Nullable<BaseTexture>;
  40799. /**
  40800. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40801. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40802. * 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;
  40803. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40804. */
  40805. /**
  40806. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40807. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40808. * 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;
  40809. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40810. */
  40811. cameraColorCurves: Nullable<ColorCurves>;
  40812. /**
  40813. * Custom callback helping to override the default shader used in the material.
  40814. */
  40815. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40816. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40817. protected _worldViewProjectionMatrix: Matrix;
  40818. protected _globalAmbientColor: Color3;
  40819. protected _useLogarithmicDepth: boolean;
  40820. /**
  40821. * Instantiates a new standard material.
  40822. * This is the default material used in Babylon. It is the best trade off between quality
  40823. * and performances.
  40824. * @see http://doc.babylonjs.com/babylon101/materials
  40825. * @param name Define the name of the material in the scene
  40826. * @param scene Define the scene the material belong to
  40827. */
  40828. constructor(name: string, scene: Scene);
  40829. /**
  40830. * Gets a boolean indicating that current material needs to register RTT
  40831. */
  40832. readonly hasRenderTargetTextures: boolean;
  40833. /**
  40834. * Gets the current class name of the material e.g. "StandardMaterial"
  40835. * Mainly use in serialization.
  40836. * @returns the class name
  40837. */
  40838. getClassName(): string;
  40839. /**
  40840. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40841. * You can try switching to logarithmic depth.
  40842. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40843. */
  40844. useLogarithmicDepth: boolean;
  40845. /**
  40846. * Specifies if the material will require alpha blending
  40847. * @returns a boolean specifying if alpha blending is needed
  40848. */
  40849. needAlphaBlending(): boolean;
  40850. /**
  40851. * Specifies if this material should be rendered in alpha test mode
  40852. * @returns a boolean specifying if an alpha test is needed.
  40853. */
  40854. needAlphaTesting(): boolean;
  40855. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40856. /**
  40857. * Get the texture used for alpha test purpose.
  40858. * @returns the diffuse texture in case of the standard material.
  40859. */
  40860. getAlphaTestTexture(): Nullable<BaseTexture>;
  40861. /**
  40862. * Get if the submesh is ready to be used and all its information available.
  40863. * Child classes can use it to update shaders
  40864. * @param mesh defines the mesh to check
  40865. * @param subMesh defines which submesh to check
  40866. * @param useInstances specifies that instances should be used
  40867. * @returns a boolean indicating that the submesh is ready or not
  40868. */
  40869. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40870. /**
  40871. * Builds the material UBO layouts.
  40872. * Used internally during the effect preparation.
  40873. */
  40874. buildUniformLayout(): void;
  40875. /**
  40876. * Unbinds the material from the mesh
  40877. */
  40878. unbind(): void;
  40879. /**
  40880. * Binds the submesh to this material by preparing the effect and shader to draw
  40881. * @param world defines the world transformation matrix
  40882. * @param mesh defines the mesh containing the submesh
  40883. * @param subMesh defines the submesh to bind the material to
  40884. */
  40885. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40886. /**
  40887. * Get the list of animatables in the material.
  40888. * @returns the list of animatables object used in the material
  40889. */
  40890. getAnimatables(): IAnimatable[];
  40891. /**
  40892. * Gets the active textures from the material
  40893. * @returns an array of textures
  40894. */
  40895. getActiveTextures(): BaseTexture[];
  40896. /**
  40897. * Specifies if the material uses a texture
  40898. * @param texture defines the texture to check against the material
  40899. * @returns a boolean specifying if the material uses the texture
  40900. */
  40901. hasTexture(texture: BaseTexture): boolean;
  40902. /**
  40903. * Disposes the material
  40904. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40905. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40906. */
  40907. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40908. /**
  40909. * Makes a duplicate of the material, and gives it a new name
  40910. * @param name defines the new name for the duplicated material
  40911. * @returns the cloned material
  40912. */
  40913. clone(name: string): StandardMaterial;
  40914. /**
  40915. * Serializes this material in a JSON representation
  40916. * @returns the serialized material object
  40917. */
  40918. serialize(): any;
  40919. /**
  40920. * Creates a standard material from parsed material data
  40921. * @param source defines the JSON representation of the material
  40922. * @param scene defines the hosting scene
  40923. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40924. * @returns a new standard material
  40925. */
  40926. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40927. /**
  40928. * Are diffuse textures enabled in the application.
  40929. */
  40930. static DiffuseTextureEnabled: boolean;
  40931. /**
  40932. * Are ambient textures enabled in the application.
  40933. */
  40934. static AmbientTextureEnabled: boolean;
  40935. /**
  40936. * Are opacity textures enabled in the application.
  40937. */
  40938. static OpacityTextureEnabled: boolean;
  40939. /**
  40940. * Are reflection textures enabled in the application.
  40941. */
  40942. static ReflectionTextureEnabled: boolean;
  40943. /**
  40944. * Are emissive textures enabled in the application.
  40945. */
  40946. static EmissiveTextureEnabled: boolean;
  40947. /**
  40948. * Are specular textures enabled in the application.
  40949. */
  40950. static SpecularTextureEnabled: boolean;
  40951. /**
  40952. * Are bump textures enabled in the application.
  40953. */
  40954. static BumpTextureEnabled: boolean;
  40955. /**
  40956. * Are lightmap textures enabled in the application.
  40957. */
  40958. static LightmapTextureEnabled: boolean;
  40959. /**
  40960. * Are refraction textures enabled in the application.
  40961. */
  40962. static RefractionTextureEnabled: boolean;
  40963. /**
  40964. * Are color grading textures enabled in the application.
  40965. */
  40966. static ColorGradingTextureEnabled: boolean;
  40967. /**
  40968. * Are fresnels enabled in the application.
  40969. */
  40970. static FresnelEnabled: boolean;
  40971. }
  40972. }
  40973. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40974. import { Scene } from "babylonjs/scene";
  40975. import { Texture } from "babylonjs/Materials/Textures/texture";
  40976. /**
  40977. * A class extending Texture allowing drawing on a texture
  40978. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40979. */
  40980. export class DynamicTexture extends Texture {
  40981. private _generateMipMaps;
  40982. private _canvas;
  40983. private _context;
  40984. private _engine;
  40985. /**
  40986. * Creates a DynamicTexture
  40987. * @param name defines the name of the texture
  40988. * @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
  40989. * @param scene defines the scene where you want the texture
  40990. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40991. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40992. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40993. */
  40994. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40995. /**
  40996. * Get the current class name of the texture useful for serialization or dynamic coding.
  40997. * @returns "DynamicTexture"
  40998. */
  40999. getClassName(): string;
  41000. /**
  41001. * Gets the current state of canRescale
  41002. */
  41003. readonly canRescale: boolean;
  41004. private _recreate;
  41005. /**
  41006. * Scales the texture
  41007. * @param ratio the scale factor to apply to both width and height
  41008. */
  41009. scale(ratio: number): void;
  41010. /**
  41011. * Resizes the texture
  41012. * @param width the new width
  41013. * @param height the new height
  41014. */
  41015. scaleTo(width: number, height: number): void;
  41016. /**
  41017. * Gets the context of the canvas used by the texture
  41018. * @returns the canvas context of the dynamic texture
  41019. */
  41020. getContext(): CanvasRenderingContext2D;
  41021. /**
  41022. * Clears the texture
  41023. */
  41024. clear(): void;
  41025. /**
  41026. * Updates the texture
  41027. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41028. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41029. */
  41030. update(invertY?: boolean, premulAlpha?: boolean): void;
  41031. /**
  41032. * Draws text onto the texture
  41033. * @param text defines the text to be drawn
  41034. * @param x defines the placement of the text from the left
  41035. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41036. * @param font defines the font to be used with font-style, font-size, font-name
  41037. * @param color defines the color used for the text
  41038. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41039. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41040. * @param update defines whether texture is immediately update (default is true)
  41041. */
  41042. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41043. /**
  41044. * Clones the texture
  41045. * @returns the clone of the texture.
  41046. */
  41047. clone(): DynamicTexture;
  41048. /**
  41049. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41050. * @returns a serialized dynamic texture object
  41051. */
  41052. serialize(): any;
  41053. /** @hidden */
  41054. _rebuild(): void;
  41055. }
  41056. }
  41057. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41058. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41059. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41060. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41061. /** @hidden */
  41062. export var imageProcessingPixelShader: {
  41063. name: string;
  41064. shader: string;
  41065. };
  41066. }
  41067. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41068. import { Nullable } from "babylonjs/types";
  41069. import { Color4 } from "babylonjs/Maths/math";
  41070. import { Camera } from "babylonjs/Cameras/camera";
  41071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41072. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41073. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41074. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41075. import { Engine } from "babylonjs/Engines/engine";
  41076. import "babylonjs/Shaders/imageProcessing.fragment";
  41077. import "babylonjs/Shaders/postprocess.vertex";
  41078. /**
  41079. * ImageProcessingPostProcess
  41080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41081. */
  41082. export class ImageProcessingPostProcess extends PostProcess {
  41083. /**
  41084. * Default configuration related to image processing available in the PBR Material.
  41085. */
  41086. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41087. /**
  41088. * Gets the image processing configuration used either in this material.
  41089. */
  41090. /**
  41091. * Sets the Default image processing configuration used either in the this material.
  41092. *
  41093. * If sets to null, the scene one is in use.
  41094. */
  41095. imageProcessingConfiguration: ImageProcessingConfiguration;
  41096. /**
  41097. * Keep track of the image processing observer to allow dispose and replace.
  41098. */
  41099. private _imageProcessingObserver;
  41100. /**
  41101. * Attaches a new image processing configuration to the PBR Material.
  41102. * @param configuration
  41103. */
  41104. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41105. /**
  41106. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41107. */
  41108. /**
  41109. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41110. */
  41111. colorCurves: Nullable<ColorCurves>;
  41112. /**
  41113. * Gets wether the color curves effect is enabled.
  41114. */
  41115. /**
  41116. * Sets wether the color curves effect is enabled.
  41117. */
  41118. colorCurvesEnabled: boolean;
  41119. /**
  41120. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41121. */
  41122. /**
  41123. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41124. */
  41125. colorGradingTexture: Nullable<BaseTexture>;
  41126. /**
  41127. * Gets wether the color grading effect is enabled.
  41128. */
  41129. /**
  41130. * Gets wether the color grading effect is enabled.
  41131. */
  41132. colorGradingEnabled: boolean;
  41133. /**
  41134. * Gets exposure used in the effect.
  41135. */
  41136. /**
  41137. * Sets exposure used in the effect.
  41138. */
  41139. exposure: number;
  41140. /**
  41141. * Gets wether tonemapping is enabled or not.
  41142. */
  41143. /**
  41144. * Sets wether tonemapping is enabled or not
  41145. */
  41146. toneMappingEnabled: boolean;
  41147. /**
  41148. * Gets the type of tone mapping effect.
  41149. */
  41150. /**
  41151. * Sets the type of tone mapping effect.
  41152. */
  41153. toneMappingType: number;
  41154. /**
  41155. * Gets contrast used in the effect.
  41156. */
  41157. /**
  41158. * Sets contrast used in the effect.
  41159. */
  41160. contrast: number;
  41161. /**
  41162. * Gets Vignette stretch size.
  41163. */
  41164. /**
  41165. * Sets Vignette stretch size.
  41166. */
  41167. vignetteStretch: number;
  41168. /**
  41169. * Gets Vignette centre X Offset.
  41170. */
  41171. /**
  41172. * Sets Vignette centre X Offset.
  41173. */
  41174. vignetteCentreX: number;
  41175. /**
  41176. * Gets Vignette centre Y Offset.
  41177. */
  41178. /**
  41179. * Sets Vignette centre Y Offset.
  41180. */
  41181. vignetteCentreY: number;
  41182. /**
  41183. * Gets Vignette weight or intensity of the vignette effect.
  41184. */
  41185. /**
  41186. * Sets Vignette weight or intensity of the vignette effect.
  41187. */
  41188. vignetteWeight: number;
  41189. /**
  41190. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41191. * if vignetteEnabled is set to true.
  41192. */
  41193. /**
  41194. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41195. * if vignetteEnabled is set to true.
  41196. */
  41197. vignetteColor: Color4;
  41198. /**
  41199. * Gets Camera field of view used by the Vignette effect.
  41200. */
  41201. /**
  41202. * Sets Camera field of view used by the Vignette effect.
  41203. */
  41204. vignetteCameraFov: number;
  41205. /**
  41206. * Gets the vignette blend mode allowing different kind of effect.
  41207. */
  41208. /**
  41209. * Sets the vignette blend mode allowing different kind of effect.
  41210. */
  41211. vignetteBlendMode: number;
  41212. /**
  41213. * Gets wether the vignette effect is enabled.
  41214. */
  41215. /**
  41216. * Sets wether the vignette effect is enabled.
  41217. */
  41218. vignetteEnabled: boolean;
  41219. private _fromLinearSpace;
  41220. /**
  41221. * Gets wether the input of the processing is in Gamma or Linear Space.
  41222. */
  41223. /**
  41224. * Sets wether the input of the processing is in Gamma or Linear Space.
  41225. */
  41226. fromLinearSpace: boolean;
  41227. /**
  41228. * Defines cache preventing GC.
  41229. */
  41230. private _defines;
  41231. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41232. /**
  41233. * "ImageProcessingPostProcess"
  41234. * @returns "ImageProcessingPostProcess"
  41235. */
  41236. getClassName(): string;
  41237. protected _updateParameters(): void;
  41238. dispose(camera?: Camera): void;
  41239. }
  41240. }
  41241. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41242. import { Scene } from "babylonjs/scene";
  41243. import { Color3 } from "babylonjs/Maths/math";
  41244. import { Mesh } from "babylonjs/Meshes/mesh";
  41245. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41246. import { Nullable } from "babylonjs/types";
  41247. /**
  41248. * Class containing static functions to help procedurally build meshes
  41249. */
  41250. export class GroundBuilder {
  41251. /**
  41252. * Creates a ground mesh
  41253. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41254. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41256. * @param name defines the name of the mesh
  41257. * @param options defines the options used to create the mesh
  41258. * @param scene defines the hosting scene
  41259. * @returns the ground mesh
  41260. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41261. */
  41262. static CreateGround(name: string, options: {
  41263. width?: number;
  41264. height?: number;
  41265. subdivisions?: number;
  41266. subdivisionsX?: number;
  41267. subdivisionsY?: number;
  41268. updatable?: boolean;
  41269. }, scene: any): Mesh;
  41270. /**
  41271. * Creates a tiled ground mesh
  41272. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41273. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41274. * * 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
  41275. * * 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
  41276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41277. * @param name defines the name of the mesh
  41278. * @param options defines the options used to create the mesh
  41279. * @param scene defines the hosting scene
  41280. * @returns the tiled ground mesh
  41281. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41282. */
  41283. static CreateTiledGround(name: string, options: {
  41284. xmin: number;
  41285. zmin: number;
  41286. xmax: number;
  41287. zmax: number;
  41288. subdivisions?: {
  41289. w: number;
  41290. h: number;
  41291. };
  41292. precision?: {
  41293. w: number;
  41294. h: number;
  41295. };
  41296. updatable?: boolean;
  41297. }, scene?: Nullable<Scene>): Mesh;
  41298. /**
  41299. * Creates a ground mesh from a height map
  41300. * * The parameter `url` sets the URL of the height map image resource.
  41301. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41302. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41303. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41304. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41305. * * 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.
  41306. * * 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).
  41307. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41309. * @param name defines the name of the mesh
  41310. * @param url defines the url to the height map
  41311. * @param options defines the options used to create the mesh
  41312. * @param scene defines the hosting scene
  41313. * @returns the ground mesh
  41314. * @see https://doc.babylonjs.com/babylon101/height_map
  41315. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41316. */
  41317. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41318. width?: number;
  41319. height?: number;
  41320. subdivisions?: number;
  41321. minHeight?: number;
  41322. maxHeight?: number;
  41323. colorFilter?: Color3;
  41324. alphaFilter?: number;
  41325. updatable?: boolean;
  41326. onReady?: (mesh: GroundMesh) => void;
  41327. }, scene?: Nullable<Scene>): GroundMesh;
  41328. }
  41329. }
  41330. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41331. import { Vector4 } from "babylonjs/Maths/math";
  41332. import { Mesh } from "babylonjs/Meshes/mesh";
  41333. /**
  41334. * Class containing static functions to help procedurally build meshes
  41335. */
  41336. export class TorusBuilder {
  41337. /**
  41338. * Creates a torus mesh
  41339. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41340. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41341. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41345. * @param name defines the name of the mesh
  41346. * @param options defines the options used to create the mesh
  41347. * @param scene defines the hosting scene
  41348. * @returns the torus mesh
  41349. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41350. */
  41351. static CreateTorus(name: string, options: {
  41352. diameter?: number;
  41353. thickness?: number;
  41354. tessellation?: number;
  41355. updatable?: boolean;
  41356. sideOrientation?: number;
  41357. frontUVs?: Vector4;
  41358. backUVs?: Vector4;
  41359. }, scene: any): Mesh;
  41360. }
  41361. }
  41362. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41363. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41364. import { Mesh } from "babylonjs/Meshes/mesh";
  41365. /**
  41366. * Class containing static functions to help procedurally build meshes
  41367. */
  41368. export class CylinderBuilder {
  41369. /**
  41370. * Creates a cylinder or a cone mesh
  41371. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41372. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41373. * * 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.
  41374. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41375. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41376. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41377. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41378. * * 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).
  41379. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41380. * * 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).
  41381. * * 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
  41382. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41383. * * 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
  41384. * * 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.
  41385. * * If `enclose` is false, a ring surface is one element.
  41386. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41387. * * 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
  41388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41391. * @param name defines the name of the mesh
  41392. * @param options defines the options used to create the mesh
  41393. * @param scene defines the hosting scene
  41394. * @returns the cylinder mesh
  41395. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41396. */
  41397. static CreateCylinder(name: string, options: {
  41398. height?: number;
  41399. diameterTop?: number;
  41400. diameterBottom?: number;
  41401. diameter?: number;
  41402. tessellation?: number;
  41403. subdivisions?: number;
  41404. arc?: number;
  41405. faceColors?: Color4[];
  41406. faceUV?: Vector4[];
  41407. updatable?: boolean;
  41408. hasRings?: boolean;
  41409. enclose?: boolean;
  41410. cap?: number;
  41411. sideOrientation?: number;
  41412. frontUVs?: Vector4;
  41413. backUVs?: Vector4;
  41414. }, scene: any): Mesh;
  41415. }
  41416. }
  41417. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41418. import { Observable } from "babylonjs/Misc/observable";
  41419. import { Nullable } from "babylonjs/types";
  41420. import { Camera } from "babylonjs/Cameras/camera";
  41421. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41422. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41423. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41424. import { Scene } from "babylonjs/scene";
  41425. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41426. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41428. import { Mesh } from "babylonjs/Meshes/mesh";
  41429. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41430. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41431. import "babylonjs/Meshes/Builders/groundBuilder";
  41432. import "babylonjs/Meshes/Builders/torusBuilder";
  41433. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41434. import "babylonjs/Gamepads/gamepadSceneComponent";
  41435. import "babylonjs/Animations/animatable";
  41436. /**
  41437. * Options to modify the vr teleportation behavior.
  41438. */
  41439. export interface VRTeleportationOptions {
  41440. /**
  41441. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41442. */
  41443. floorMeshName?: string;
  41444. /**
  41445. * A list of meshes to be used as the teleportation floor. (default: empty)
  41446. */
  41447. floorMeshes?: Mesh[];
  41448. }
  41449. /**
  41450. * Options to modify the vr experience helper's behavior.
  41451. */
  41452. export interface VRExperienceHelperOptions extends WebVROptions {
  41453. /**
  41454. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41455. */
  41456. createDeviceOrientationCamera?: boolean;
  41457. /**
  41458. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41459. */
  41460. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41461. /**
  41462. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41463. */
  41464. laserToggle?: boolean;
  41465. /**
  41466. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41467. */
  41468. floorMeshes?: Mesh[];
  41469. /**
  41470. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41471. */
  41472. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41473. }
  41474. /**
  41475. * Event containing information after VR has been entered
  41476. */
  41477. export class OnAfterEnteringVRObservableEvent {
  41478. /**
  41479. * If entering vr was successful
  41480. */
  41481. success: boolean;
  41482. }
  41483. /**
  41484. * Helps to quickly add VR support to an existing scene.
  41485. * See http://doc.babylonjs.com/how_to/webvr_helper
  41486. */
  41487. export class VRExperienceHelper {
  41488. /** Options to modify the vr experience helper's behavior. */
  41489. webVROptions: VRExperienceHelperOptions;
  41490. private _scene;
  41491. private _position;
  41492. private _btnVR;
  41493. private _btnVRDisplayed;
  41494. private _webVRsupported;
  41495. private _webVRready;
  41496. private _webVRrequesting;
  41497. private _webVRpresenting;
  41498. private _hasEnteredVR;
  41499. private _fullscreenVRpresenting;
  41500. private _canvas;
  41501. private _webVRCamera;
  41502. private _vrDeviceOrientationCamera;
  41503. private _deviceOrientationCamera;
  41504. private _existingCamera;
  41505. private _onKeyDown;
  41506. private _onVrDisplayPresentChange;
  41507. private _onVRDisplayChanged;
  41508. private _onVRRequestPresentStart;
  41509. private _onVRRequestPresentComplete;
  41510. /**
  41511. * Observable raised right before entering VR.
  41512. */
  41513. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41514. /**
  41515. * Observable raised when entering VR has completed.
  41516. */
  41517. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41518. /**
  41519. * Observable raised when exiting VR.
  41520. */
  41521. onExitingVRObservable: Observable<VRExperienceHelper>;
  41522. /**
  41523. * Observable raised when controller mesh is loaded.
  41524. */
  41525. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41526. /** Return this.onEnteringVRObservable
  41527. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41528. */
  41529. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41530. /** Return this.onExitingVRObservable
  41531. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41532. */
  41533. readonly onExitingVR: Observable<VRExperienceHelper>;
  41534. /** Return this.onControllerMeshLoadedObservable
  41535. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41536. */
  41537. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41538. private _rayLength;
  41539. private _useCustomVRButton;
  41540. private _teleportationRequested;
  41541. private _teleportActive;
  41542. private _floorMeshName;
  41543. private _floorMeshesCollection;
  41544. private _rotationAllowed;
  41545. private _teleportBackwardsVector;
  41546. private _teleportationTarget;
  41547. private _isDefaultTeleportationTarget;
  41548. private _postProcessMove;
  41549. private _teleportationFillColor;
  41550. private _teleportationBorderColor;
  41551. private _rotationAngle;
  41552. private _haloCenter;
  41553. private _cameraGazer;
  41554. private _padSensibilityUp;
  41555. private _padSensibilityDown;
  41556. private _leftController;
  41557. private _rightController;
  41558. /**
  41559. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41560. */
  41561. onNewMeshSelected: Observable<AbstractMesh>;
  41562. /**
  41563. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41564. */
  41565. onNewMeshPicked: Observable<PickingInfo>;
  41566. private _circleEase;
  41567. /**
  41568. * Observable raised before camera teleportation
  41569. */
  41570. onBeforeCameraTeleport: Observable<Vector3>;
  41571. /**
  41572. * Observable raised after camera teleportation
  41573. */
  41574. onAfterCameraTeleport: Observable<Vector3>;
  41575. /**
  41576. * Observable raised when current selected mesh gets unselected
  41577. */
  41578. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41579. private _raySelectionPredicate;
  41580. /**
  41581. * To be optionaly changed by user to define custom ray selection
  41582. */
  41583. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41584. /**
  41585. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41586. */
  41587. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41588. /**
  41589. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41590. */
  41591. teleportationEnabled: boolean;
  41592. private _defaultHeight;
  41593. private _teleportationInitialized;
  41594. private _interactionsEnabled;
  41595. private _interactionsRequested;
  41596. private _displayGaze;
  41597. private _displayLaserPointer;
  41598. /**
  41599. * The mesh used to display where the user is going to teleport.
  41600. */
  41601. /**
  41602. * Sets the mesh to be used to display where the user is going to teleport.
  41603. */
  41604. teleportationTarget: Mesh;
  41605. /**
  41606. * 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
  41607. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41608. * See http://doc.babylonjs.com/resources/baking_transformations
  41609. */
  41610. gazeTrackerMesh: Mesh;
  41611. /**
  41612. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41613. */
  41614. updateGazeTrackerScale: boolean;
  41615. /**
  41616. * If the gaze trackers color should be updated when selecting meshes
  41617. */
  41618. updateGazeTrackerColor: boolean;
  41619. /**
  41620. * The gaze tracking mesh corresponding to the left controller
  41621. */
  41622. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41623. /**
  41624. * The gaze tracking mesh corresponding to the right controller
  41625. */
  41626. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41627. /**
  41628. * If the ray of the gaze should be displayed.
  41629. */
  41630. /**
  41631. * Sets if the ray of the gaze should be displayed.
  41632. */
  41633. displayGaze: boolean;
  41634. /**
  41635. * If the ray of the LaserPointer should be displayed.
  41636. */
  41637. /**
  41638. * Sets if the ray of the LaserPointer should be displayed.
  41639. */
  41640. displayLaserPointer: boolean;
  41641. /**
  41642. * The deviceOrientationCamera used as the camera when not in VR.
  41643. */
  41644. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41645. /**
  41646. * Based on the current WebVR support, returns the current VR camera used.
  41647. */
  41648. readonly currentVRCamera: Nullable<Camera>;
  41649. /**
  41650. * The webVRCamera which is used when in VR.
  41651. */
  41652. readonly webVRCamera: WebVRFreeCamera;
  41653. /**
  41654. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41655. */
  41656. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41657. private readonly _teleportationRequestInitiated;
  41658. /**
  41659. * Defines wether or not Pointer lock should be requested when switching to
  41660. * full screen.
  41661. */
  41662. requestPointerLockOnFullScreen: boolean;
  41663. /**
  41664. * Instantiates a VRExperienceHelper.
  41665. * Helps to quickly add VR support to an existing scene.
  41666. * @param scene The scene the VRExperienceHelper belongs to.
  41667. * @param webVROptions Options to modify the vr experience helper's behavior.
  41668. */
  41669. constructor(scene: Scene,
  41670. /** Options to modify the vr experience helper's behavior. */
  41671. webVROptions?: VRExperienceHelperOptions);
  41672. private _onDefaultMeshLoaded;
  41673. private _onResize;
  41674. private _onFullscreenChange;
  41675. /**
  41676. * Gets a value indicating if we are currently in VR mode.
  41677. */
  41678. readonly isInVRMode: boolean;
  41679. private onVrDisplayPresentChange;
  41680. private onVRDisplayChanged;
  41681. private moveButtonToBottomRight;
  41682. private displayVRButton;
  41683. private updateButtonVisibility;
  41684. private _cachedAngularSensibility;
  41685. /**
  41686. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41687. * Otherwise, will use the fullscreen API.
  41688. */
  41689. enterVR(): void;
  41690. /**
  41691. * Attempt to exit VR, or fullscreen.
  41692. */
  41693. exitVR(): void;
  41694. /**
  41695. * The position of the vr experience helper.
  41696. */
  41697. /**
  41698. * Sets the position of the vr experience helper.
  41699. */
  41700. position: Vector3;
  41701. /**
  41702. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41703. */
  41704. enableInteractions(): void;
  41705. private readonly _noControllerIsActive;
  41706. private beforeRender;
  41707. private _isTeleportationFloor;
  41708. /**
  41709. * Adds a floor mesh to be used for teleportation.
  41710. * @param floorMesh the mesh to be used for teleportation.
  41711. */
  41712. addFloorMesh(floorMesh: Mesh): void;
  41713. /**
  41714. * Removes a floor mesh from being used for teleportation.
  41715. * @param floorMesh the mesh to be removed.
  41716. */
  41717. removeFloorMesh(floorMesh: Mesh): void;
  41718. /**
  41719. * Enables interactions and teleportation using the VR controllers and gaze.
  41720. * @param vrTeleportationOptions options to modify teleportation behavior.
  41721. */
  41722. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41723. private _onNewGamepadConnected;
  41724. private _tryEnableInteractionOnController;
  41725. private _onNewGamepadDisconnected;
  41726. private _enableInteractionOnController;
  41727. private _checkTeleportWithRay;
  41728. private _checkRotate;
  41729. private _checkTeleportBackwards;
  41730. private _enableTeleportationOnController;
  41731. private _createTeleportationCircles;
  41732. private _displayTeleportationTarget;
  41733. private _hideTeleportationTarget;
  41734. private _rotateCamera;
  41735. private _moveTeleportationSelectorTo;
  41736. private _workingVector;
  41737. private _workingQuaternion;
  41738. private _workingMatrix;
  41739. /**
  41740. * Teleports the users feet to the desired location
  41741. * @param location The location where the user's feet should be placed
  41742. */
  41743. teleportCamera(location: Vector3): void;
  41744. private _convertNormalToDirectionOfRay;
  41745. private _castRayAndSelectObject;
  41746. private _notifySelectedMeshUnselected;
  41747. /**
  41748. * Sets the color of the laser ray from the vr controllers.
  41749. * @param color new color for the ray.
  41750. */
  41751. changeLaserColor(color: Color3): void;
  41752. /**
  41753. * Sets the color of the ray from the vr headsets gaze.
  41754. * @param color new color for the ray.
  41755. */
  41756. changeGazeColor(color: Color3): void;
  41757. /**
  41758. * Exits VR and disposes of the vr experience helper
  41759. */
  41760. dispose(): void;
  41761. /**
  41762. * Gets the name of the VRExperienceHelper class
  41763. * @returns "VRExperienceHelper"
  41764. */
  41765. getClassName(): string;
  41766. }
  41767. }
  41768. declare module "babylonjs/Cameras/VR/index" {
  41769. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41770. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41771. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41772. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41773. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41774. export * from "babylonjs/Cameras/VR/webVRCamera";
  41775. }
  41776. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41777. import { Observable } from "babylonjs/Misc/observable";
  41778. import { Nullable } from "babylonjs/types";
  41779. import { IDisposable, Scene } from "babylonjs/scene";
  41780. import { Vector3 } from "babylonjs/Maths/math";
  41781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41782. import { Ray } from "babylonjs/Culling/ray";
  41783. /**
  41784. * Manages an XRSession
  41785. * @see https://doc.babylonjs.com/how_to/webxr
  41786. */
  41787. export class WebXRSessionManager implements IDisposable {
  41788. private scene;
  41789. /**
  41790. * Fires every time a new xrFrame arrives which can be used to update the camera
  41791. */
  41792. onXRFrameObservable: Observable<any>;
  41793. /**
  41794. * Fires when the xr session is ended either by the device or manually done
  41795. */
  41796. onXRSessionEnded: Observable<any>;
  41797. /** @hidden */
  41798. _xrSession: XRSession;
  41799. /** @hidden */
  41800. _frameOfReference: XRFrameOfReference;
  41801. /** @hidden */
  41802. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41803. /** @hidden */
  41804. _currentXRFrame: Nullable<XRFrame>;
  41805. private _xrNavigator;
  41806. private _xrDevice;
  41807. private _tmpMatrix;
  41808. /**
  41809. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41810. * @param scene The scene which the session should be created for
  41811. */
  41812. constructor(scene: Scene);
  41813. /**
  41814. * Initializes the manager
  41815. * After initialization enterXR can be called to start an XR session
  41816. * @returns Promise which resolves after it is initialized
  41817. */
  41818. initializeAsync(): Promise<void>;
  41819. /**
  41820. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41821. * @param sessionCreationOptions xr options to create the session with
  41822. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41823. * @returns Promise which resolves after it enters XR
  41824. */
  41825. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41826. /**
  41827. * Stops the xrSession and restores the renderloop
  41828. * @returns Promise which resolves after it exits XR
  41829. */
  41830. exitXRAsync(): Promise<void>;
  41831. /**
  41832. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41833. * @param ray ray to cast into the environment
  41834. * @returns Promise which resolves with a collision point in the environment if it exists
  41835. */
  41836. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41837. /**
  41838. * Checks if a session would be supported for the creation options specified
  41839. * @param options creation options to check if they are supported
  41840. * @returns true if supported
  41841. */
  41842. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41843. /**
  41844. * @hidden
  41845. * Converts the render layer of xrSession to a render target
  41846. * @param session session to create render target for
  41847. * @param scene scene the new render target should be created for
  41848. */
  41849. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41850. /**
  41851. * Disposes of the session manager
  41852. */
  41853. dispose(): void;
  41854. }
  41855. }
  41856. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41857. import { Scene } from "babylonjs/scene";
  41858. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41859. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41860. /**
  41861. * WebXR Camera which holds the views for the xrSession
  41862. * @see https://doc.babylonjs.com/how_to/webxr
  41863. */
  41864. export class WebXRCamera extends FreeCamera {
  41865. private static _TmpMatrix;
  41866. /**
  41867. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41868. * @param name the name of the camera
  41869. * @param scene the scene to add the camera to
  41870. */
  41871. constructor(name: string, scene: Scene);
  41872. private _updateNumberOfRigCameras;
  41873. /** @hidden */
  41874. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41875. /**
  41876. * Updates the cameras position from the current pose information of the XR session
  41877. * @param xrSessionManager the session containing pose information
  41878. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41879. */
  41880. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41881. }
  41882. }
  41883. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41884. import { Nullable } from "babylonjs/types";
  41885. import { Observable } from "babylonjs/Misc/observable";
  41886. import { IDisposable, Scene } from "babylonjs/scene";
  41887. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41889. import { Ray } from "babylonjs/Culling/ray";
  41890. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41891. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41892. /**
  41893. * States of the webXR experience
  41894. */
  41895. export enum WebXRState {
  41896. /**
  41897. * Transitioning to being in XR mode
  41898. */
  41899. ENTERING_XR = 0,
  41900. /**
  41901. * Transitioning to non XR mode
  41902. */
  41903. EXITING_XR = 1,
  41904. /**
  41905. * In XR mode and presenting
  41906. */
  41907. IN_XR = 2,
  41908. /**
  41909. * Not entered XR mode
  41910. */
  41911. NOT_IN_XR = 3
  41912. }
  41913. /**
  41914. * Helper class used to enable XR
  41915. * @see https://doc.babylonjs.com/how_to/webxr
  41916. */
  41917. export class WebXRExperienceHelper implements IDisposable {
  41918. private scene;
  41919. /**
  41920. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  41921. */
  41922. container: AbstractMesh;
  41923. /**
  41924. * Camera used to render xr content
  41925. */
  41926. camera: WebXRCamera;
  41927. /**
  41928. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41929. */
  41930. state: WebXRState;
  41931. private _setState;
  41932. private static _TmpVector;
  41933. /**
  41934. * Fires when the state of the experience helper has changed
  41935. */
  41936. onStateChangedObservable: Observable<WebXRState>;
  41937. /** @hidden */
  41938. _sessionManager: WebXRSessionManager;
  41939. private _nonVRCamera;
  41940. private _originalSceneAutoClear;
  41941. private _supported;
  41942. /**
  41943. * Creates the experience helper
  41944. * @param scene the scene to attach the experience helper to
  41945. * @returns a promise for the experience helper
  41946. */
  41947. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41948. /**
  41949. * Creates a WebXRExperienceHelper
  41950. * @param scene The scene the helper should be created in
  41951. */
  41952. private constructor();
  41953. /**
  41954. * Exits XR mode and returns the scene to its original state
  41955. * @returns promise that resolves after xr mode has exited
  41956. */
  41957. exitXRAsync(): Promise<void>;
  41958. /**
  41959. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41960. * @param sessionCreationOptions options for the XR session
  41961. * @param frameOfReference frame of reference of the XR session
  41962. * @returns promise that resolves after xr mode has entered
  41963. */
  41964. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41965. /**
  41966. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41967. * @param ray ray to cast into the environment
  41968. * @returns Promise which resolves with a collision point in the environment if it exists
  41969. */
  41970. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41971. /**
  41972. * Updates the global position of the camera by moving the camera's container
  41973. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41974. * @param position The desired global position of the camera
  41975. */
  41976. setPositionOfCameraUsingContainer(position: Vector3): void;
  41977. /**
  41978. * Rotates the xr camera by rotating the camera's container around the camera's position
  41979. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41980. * @param rotation the desired quaternion rotation to apply to the camera
  41981. */
  41982. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41983. /**
  41984. * Checks if the creation options are supported by the xr session
  41985. * @param options creation options
  41986. * @returns true if supported
  41987. */
  41988. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41989. /**
  41990. * Disposes of the experience helper
  41991. */
  41992. dispose(): void;
  41993. }
  41994. }
  41995. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41996. import { Nullable } from "babylonjs/types";
  41997. import { Observable } from "babylonjs/Misc/observable";
  41998. import { IDisposable, Scene } from "babylonjs/scene";
  41999. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42000. /**
  42001. * Button which can be used to enter a different mode of XR
  42002. */
  42003. export class WebXREnterExitUIButton {
  42004. /** button element */
  42005. element: HTMLElement;
  42006. /** XR initialization options for the button */
  42007. initializationOptions: XRSessionCreationOptions;
  42008. /**
  42009. * Creates a WebXREnterExitUIButton
  42010. * @param element button element
  42011. * @param initializationOptions XR initialization options for the button
  42012. */
  42013. constructor(
  42014. /** button element */
  42015. element: HTMLElement,
  42016. /** XR initialization options for the button */
  42017. initializationOptions: XRSessionCreationOptions);
  42018. /**
  42019. * Overwritable function which can be used to update the button's visuals when the state changes
  42020. * @param activeButton the current active button in the UI
  42021. */
  42022. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42023. }
  42024. /**
  42025. * Options to create the webXR UI
  42026. */
  42027. export class WebXREnterExitUIOptions {
  42028. /**
  42029. * Context to enter xr with
  42030. */
  42031. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42032. /**
  42033. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42034. */
  42035. customButtons?: Array<WebXREnterExitUIButton>;
  42036. }
  42037. /**
  42038. * UI to allow the user to enter/exit XR mode
  42039. */
  42040. export class WebXREnterExitUI implements IDisposable {
  42041. private scene;
  42042. private _overlay;
  42043. private _buttons;
  42044. private _activeButton;
  42045. /**
  42046. * Fired every time the active button is changed.
  42047. *
  42048. * When xr is entered via a button that launches xr that button will be the callback parameter
  42049. *
  42050. * When exiting xr the callback parameter will be null)
  42051. */
  42052. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42053. /**
  42054. * Creates UI to allow the user to enter/exit XR mode
  42055. * @param scene the scene to add the ui to
  42056. * @param helper the xr experience helper to enter/exit xr with
  42057. * @param options options to configure the UI
  42058. * @returns the created ui
  42059. */
  42060. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42061. private constructor();
  42062. private _updateButtons;
  42063. /**
  42064. * Disposes of the object
  42065. */
  42066. dispose(): void;
  42067. }
  42068. }
  42069. declare module "babylonjs/Cameras/XR/webXRInput" {
  42070. import { IDisposable, Scene } from "babylonjs/scene";
  42071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42072. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42073. /**
  42074. * Represents an XR input
  42075. */
  42076. export class WebXRController {
  42077. /**
  42078. * 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
  42079. */
  42080. grip?: AbstractMesh;
  42081. /**
  42082. * Pointer which can be used to select objects or attach a visible laser to
  42083. */
  42084. pointer: AbstractMesh;
  42085. /**
  42086. * Creates the controller
  42087. * @see https://doc.babylonjs.com/how_to/webxr
  42088. * @param scene the scene which the controller should be associated to
  42089. */
  42090. constructor(scene: Scene);
  42091. /**
  42092. * Disposes of the object
  42093. */
  42094. dispose(): void;
  42095. }
  42096. /**
  42097. * XR input used to track XR inputs such as controllers/rays
  42098. */
  42099. export class WebXRInput implements IDisposable {
  42100. private helper;
  42101. /**
  42102. * XR controllers being tracked
  42103. */
  42104. controllers: Array<WebXRController>;
  42105. private _tmpMatrix;
  42106. private _frameObserver;
  42107. /**
  42108. * Initializes the WebXRInput
  42109. * @param helper experience helper which the input should be created for
  42110. */
  42111. constructor(helper: WebXRExperienceHelper);
  42112. /**
  42113. * Disposes of the object
  42114. */
  42115. dispose(): void;
  42116. }
  42117. }
  42118. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42119. import { Nullable } from "babylonjs/types";
  42120. import { IDisposable } from "babylonjs/scene";
  42121. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42122. /**
  42123. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42124. */
  42125. export class WebXRManagedOutputCanvas implements IDisposable {
  42126. private _canvas;
  42127. /**
  42128. * xrpresent context of the canvas which can be used to display/mirror xr content
  42129. */
  42130. canvasContext: Nullable<WebGLRenderingContext>;
  42131. /**
  42132. * Initializes the canvas to be added/removed upon entering/exiting xr
  42133. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42134. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42135. */
  42136. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42137. /**
  42138. * Disposes of the object
  42139. */
  42140. dispose(): void;
  42141. private _setManagedOutputCanvas;
  42142. private _addCanvas;
  42143. private _removeCanvas;
  42144. }
  42145. }
  42146. declare module "babylonjs/Cameras/XR/index" {
  42147. export * from "babylonjs/Cameras/XR/webXRCamera";
  42148. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42149. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42150. export * from "babylonjs/Cameras/XR/webXRInput";
  42151. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42152. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42153. }
  42154. declare module "babylonjs/Cameras/RigModes/index" {
  42155. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42156. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42157. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42158. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42159. }
  42160. declare module "babylonjs/Cameras/index" {
  42161. export * from "babylonjs/Cameras/Inputs/index";
  42162. export * from "babylonjs/Cameras/cameraInputsManager";
  42163. export * from "babylonjs/Cameras/camera";
  42164. export * from "babylonjs/Cameras/targetCamera";
  42165. export * from "babylonjs/Cameras/freeCamera";
  42166. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42167. export * from "babylonjs/Cameras/touchCamera";
  42168. export * from "babylonjs/Cameras/arcRotateCamera";
  42169. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42170. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42171. export * from "babylonjs/Cameras/flyCamera";
  42172. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42173. export * from "babylonjs/Cameras/followCamera";
  42174. export * from "babylonjs/Cameras/gamepadCamera";
  42175. export * from "babylonjs/Cameras/Stereoscopic/index";
  42176. export * from "babylonjs/Cameras/universalCamera";
  42177. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42178. export * from "babylonjs/Cameras/VR/index";
  42179. export * from "babylonjs/Cameras/XR/index";
  42180. export * from "babylonjs/Cameras/RigModes/index";
  42181. }
  42182. declare module "babylonjs/Collisions/index" {
  42183. export * from "babylonjs/Collisions/collider";
  42184. export * from "babylonjs/Collisions/collisionCoordinator";
  42185. export * from "babylonjs/Collisions/pickingInfo";
  42186. export * from "babylonjs/Collisions/intersectionInfo";
  42187. export * from "babylonjs/Collisions/meshCollisionData";
  42188. }
  42189. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42190. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42191. import { Vector3, Plane } from "babylonjs/Maths/math";
  42192. import { Ray } from "babylonjs/Culling/ray";
  42193. /**
  42194. * Contains an array of blocks representing the octree
  42195. */
  42196. export interface IOctreeContainer<T> {
  42197. /**
  42198. * Blocks within the octree
  42199. */
  42200. blocks: Array<OctreeBlock<T>>;
  42201. }
  42202. /**
  42203. * Class used to store a cell in an octree
  42204. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42205. */
  42206. export class OctreeBlock<T> {
  42207. /**
  42208. * Gets the content of the current block
  42209. */
  42210. entries: T[];
  42211. /**
  42212. * Gets the list of block children
  42213. */
  42214. blocks: Array<OctreeBlock<T>>;
  42215. private _depth;
  42216. private _maxDepth;
  42217. private _capacity;
  42218. private _minPoint;
  42219. private _maxPoint;
  42220. private _boundingVectors;
  42221. private _creationFunc;
  42222. /**
  42223. * Creates a new block
  42224. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42225. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42226. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42227. * @param depth defines the current depth of this block in the octree
  42228. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42229. * @param creationFunc defines a callback to call when an element is added to the block
  42230. */
  42231. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42232. /**
  42233. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42234. */
  42235. readonly capacity: number;
  42236. /**
  42237. * Gets the minimum vector (in world space) of the block's bounding box
  42238. */
  42239. readonly minPoint: Vector3;
  42240. /**
  42241. * Gets the maximum vector (in world space) of the block's bounding box
  42242. */
  42243. readonly maxPoint: Vector3;
  42244. /**
  42245. * Add a new element to this block
  42246. * @param entry defines the element to add
  42247. */
  42248. addEntry(entry: T): void;
  42249. /**
  42250. * Remove an element from this block
  42251. * @param entry defines the element to remove
  42252. */
  42253. removeEntry(entry: T): void;
  42254. /**
  42255. * Add an array of elements to this block
  42256. * @param entries defines the array of elements to add
  42257. */
  42258. addEntries(entries: T[]): void;
  42259. /**
  42260. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42261. * @param frustumPlanes defines the frustum planes to test
  42262. * @param selection defines the array to store current content if selection is positive
  42263. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42264. */
  42265. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42266. /**
  42267. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42268. * @param sphereCenter defines the bounding sphere center
  42269. * @param sphereRadius defines the bounding sphere radius
  42270. * @param selection defines the array to store current content if selection is positive
  42271. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42272. */
  42273. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42274. /**
  42275. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42276. * @param ray defines the ray to test with
  42277. * @param selection defines the array to store current content if selection is positive
  42278. */
  42279. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42280. /**
  42281. * Subdivide the content into child blocks (this block will then be empty)
  42282. */
  42283. createInnerBlocks(): void;
  42284. /**
  42285. * @hidden
  42286. */
  42287. 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;
  42288. }
  42289. }
  42290. declare module "babylonjs/Culling/Octrees/octree" {
  42291. import { SmartArray } from "babylonjs/Misc/smartArray";
  42292. import { Vector3, Plane } from "babylonjs/Maths/math";
  42293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42295. import { Ray } from "babylonjs/Culling/ray";
  42296. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42297. /**
  42298. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42299. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42300. */
  42301. export class Octree<T> {
  42302. /** 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.) */
  42303. maxDepth: number;
  42304. /**
  42305. * Blocks within the octree containing objects
  42306. */
  42307. blocks: Array<OctreeBlock<T>>;
  42308. /**
  42309. * Content stored in the octree
  42310. */
  42311. dynamicContent: T[];
  42312. private _maxBlockCapacity;
  42313. private _selectionContent;
  42314. private _creationFunc;
  42315. /**
  42316. * Creates a octree
  42317. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42318. * @param creationFunc function to be used to instatiate the octree
  42319. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42320. * @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.)
  42321. */
  42322. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42323. /** 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.) */
  42324. maxDepth?: number);
  42325. /**
  42326. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42327. * @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);
  42328. * @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);
  42329. * @param entries meshes to be added to the octree blocks
  42330. */
  42331. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42332. /**
  42333. * Adds a mesh to the octree
  42334. * @param entry Mesh to add to the octree
  42335. */
  42336. addMesh(entry: T): void;
  42337. /**
  42338. * Remove an element from the octree
  42339. * @param entry defines the element to remove
  42340. */
  42341. removeMesh(entry: T): void;
  42342. /**
  42343. * Selects an array of meshes within the frustum
  42344. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42345. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42346. * @returns array of meshes within the frustum
  42347. */
  42348. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42349. /**
  42350. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42351. * @param sphereCenter defines the bounding sphere center
  42352. * @param sphereRadius defines the bounding sphere radius
  42353. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42354. * @returns an array of objects that intersect the sphere
  42355. */
  42356. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42357. /**
  42358. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42359. * @param ray defines the ray to test with
  42360. * @returns array of intersected objects
  42361. */
  42362. intersectsRay(ray: Ray): SmartArray<T>;
  42363. /**
  42364. * Adds a mesh into the octree block if it intersects the block
  42365. */
  42366. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42367. /**
  42368. * Adds a submesh into the octree block if it intersects the block
  42369. */
  42370. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42371. }
  42372. }
  42373. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42374. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42375. import { Scene } from "babylonjs/scene";
  42376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42378. import { Ray } from "babylonjs/Culling/ray";
  42379. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42380. import { Collider } from "babylonjs/Collisions/collider";
  42381. module "babylonjs/scene" {
  42382. interface Scene {
  42383. /**
  42384. * @hidden
  42385. * Backing Filed
  42386. */
  42387. _selectionOctree: Octree<AbstractMesh>;
  42388. /**
  42389. * Gets the octree used to boost mesh selection (picking)
  42390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42391. */
  42392. selectionOctree: Octree<AbstractMesh>;
  42393. /**
  42394. * Creates or updates the octree used to boost selection (picking)
  42395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42396. * @param maxCapacity defines the maximum capacity per leaf
  42397. * @param maxDepth defines the maximum depth of the octree
  42398. * @returns an octree of AbstractMesh
  42399. */
  42400. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42401. }
  42402. }
  42403. module "babylonjs/Meshes/abstractMesh" {
  42404. interface AbstractMesh {
  42405. /**
  42406. * @hidden
  42407. * Backing Field
  42408. */
  42409. _submeshesOctree: Octree<SubMesh>;
  42410. /**
  42411. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42412. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42413. * @param maxCapacity defines the maximum size of each block (64 by default)
  42414. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42415. * @returns the new octree
  42416. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42418. */
  42419. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42420. }
  42421. }
  42422. /**
  42423. * Defines the octree scene component responsible to manage any octrees
  42424. * in a given scene.
  42425. */
  42426. export class OctreeSceneComponent {
  42427. /**
  42428. * The component name help to identify the component in the list of scene components.
  42429. */
  42430. readonly name: string;
  42431. /**
  42432. * The scene the component belongs to.
  42433. */
  42434. scene: Scene;
  42435. /**
  42436. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42437. */
  42438. readonly checksIsEnabled: boolean;
  42439. /**
  42440. * Creates a new instance of the component for the given scene
  42441. * @param scene Defines the scene to register the component in
  42442. */
  42443. constructor(scene: Scene);
  42444. /**
  42445. * Registers the component in a given scene
  42446. */
  42447. register(): void;
  42448. /**
  42449. * Return the list of active meshes
  42450. * @returns the list of active meshes
  42451. */
  42452. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42453. /**
  42454. * Return the list of active sub meshes
  42455. * @param mesh The mesh to get the candidates sub meshes from
  42456. * @returns the list of active sub meshes
  42457. */
  42458. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42459. private _tempRay;
  42460. /**
  42461. * Return the list of sub meshes intersecting with a given local ray
  42462. * @param mesh defines the mesh to find the submesh for
  42463. * @param localRay defines the ray in local space
  42464. * @returns the list of intersecting sub meshes
  42465. */
  42466. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42467. /**
  42468. * Return the list of sub meshes colliding with a collider
  42469. * @param mesh defines the mesh to find the submesh for
  42470. * @param collider defines the collider to evaluate the collision against
  42471. * @returns the list of colliding sub meshes
  42472. */
  42473. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42474. /**
  42475. * Rebuilds the elements related to this component in case of
  42476. * context lost for instance.
  42477. */
  42478. rebuild(): void;
  42479. /**
  42480. * Disposes the component and the associated ressources.
  42481. */
  42482. dispose(): void;
  42483. }
  42484. }
  42485. declare module "babylonjs/Culling/Octrees/index" {
  42486. export * from "babylonjs/Culling/Octrees/octree";
  42487. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42488. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42489. }
  42490. declare module "babylonjs/Culling/index" {
  42491. export * from "babylonjs/Culling/boundingBox";
  42492. export * from "babylonjs/Culling/boundingInfo";
  42493. export * from "babylonjs/Culling/boundingSphere";
  42494. export * from "babylonjs/Culling/Octrees/index";
  42495. export * from "babylonjs/Culling/ray";
  42496. }
  42497. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42498. import { IDisposable, Scene } from "babylonjs/scene";
  42499. import { Nullable } from "babylonjs/types";
  42500. import { Observable } from "babylonjs/Misc/observable";
  42501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42502. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42503. import { Camera } from "babylonjs/Cameras/camera";
  42504. /**
  42505. * Renders a layer on top of an existing scene
  42506. */
  42507. export class UtilityLayerRenderer implements IDisposable {
  42508. /** the original scene that will be rendered on top of */
  42509. originalScene: Scene;
  42510. private _pointerCaptures;
  42511. private _lastPointerEvents;
  42512. private static _DefaultUtilityLayer;
  42513. private static _DefaultKeepDepthUtilityLayer;
  42514. private _sharedGizmoLight;
  42515. private _renderCamera;
  42516. /**
  42517. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42518. * @returns the camera that is used when rendering the utility layer
  42519. */
  42520. getRenderCamera(): Nullable<Camera>;
  42521. /**
  42522. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42523. * @param cam the camera that should be used when rendering the utility layer
  42524. */
  42525. setRenderCamera(cam: Nullable<Camera>): void;
  42526. /**
  42527. * @hidden
  42528. * Light which used by gizmos to get light shading
  42529. */
  42530. _getSharedGizmoLight(): HemisphericLight;
  42531. /**
  42532. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42533. */
  42534. pickUtilitySceneFirst: boolean;
  42535. /**
  42536. * 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)
  42537. */
  42538. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42539. /**
  42540. * 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)
  42541. */
  42542. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42543. /**
  42544. * The scene that is rendered on top of the original scene
  42545. */
  42546. utilityLayerScene: Scene;
  42547. /**
  42548. * If the utility layer should automatically be rendered on top of existing scene
  42549. */
  42550. shouldRender: boolean;
  42551. /**
  42552. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42553. */
  42554. onlyCheckPointerDownEvents: boolean;
  42555. /**
  42556. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42557. */
  42558. processAllEvents: boolean;
  42559. /**
  42560. * Observable raised when the pointer move from the utility layer scene to the main scene
  42561. */
  42562. onPointerOutObservable: Observable<number>;
  42563. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42564. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42565. private _afterRenderObserver;
  42566. private _sceneDisposeObserver;
  42567. private _originalPointerObserver;
  42568. /**
  42569. * Instantiates a UtilityLayerRenderer
  42570. * @param originalScene the original scene that will be rendered on top of
  42571. * @param handleEvents boolean indicating if the utility layer should handle events
  42572. */
  42573. constructor(
  42574. /** the original scene that will be rendered on top of */
  42575. originalScene: Scene, handleEvents?: boolean);
  42576. private _notifyObservers;
  42577. /**
  42578. * Renders the utility layers scene on top of the original scene
  42579. */
  42580. render(): void;
  42581. /**
  42582. * Disposes of the renderer
  42583. */
  42584. dispose(): void;
  42585. private _updateCamera;
  42586. }
  42587. }
  42588. declare module "babylonjs/Gizmos/gizmo" {
  42589. import { Nullable } from "babylonjs/types";
  42590. import { IDisposable } from "babylonjs/scene";
  42591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42592. import { Mesh } from "babylonjs/Meshes/mesh";
  42593. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42594. /**
  42595. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42596. */
  42597. export class Gizmo implements IDisposable {
  42598. /** The utility layer the gizmo will be added to */
  42599. gizmoLayer: UtilityLayerRenderer;
  42600. /**
  42601. * The root mesh of the gizmo
  42602. */
  42603. _rootMesh: Mesh;
  42604. private _attachedMesh;
  42605. /**
  42606. * Ratio for the scale of the gizmo (Default: 1)
  42607. */
  42608. scaleRatio: number;
  42609. /**
  42610. * If a custom mesh has been set (Default: false)
  42611. */
  42612. protected _customMeshSet: boolean;
  42613. /**
  42614. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42615. * * When set, interactions will be enabled
  42616. */
  42617. attachedMesh: Nullable<AbstractMesh>;
  42618. /**
  42619. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42620. * @param mesh The mesh to replace the default mesh of the gizmo
  42621. */
  42622. setCustomMesh(mesh: Mesh): void;
  42623. /**
  42624. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42625. */
  42626. updateGizmoRotationToMatchAttachedMesh: boolean;
  42627. /**
  42628. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42629. */
  42630. updateGizmoPositionToMatchAttachedMesh: boolean;
  42631. /**
  42632. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42633. */
  42634. protected _updateScale: boolean;
  42635. protected _interactionsEnabled: boolean;
  42636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42637. private _beforeRenderObserver;
  42638. private _tempVector;
  42639. /**
  42640. * Creates a gizmo
  42641. * @param gizmoLayer The utility layer the gizmo will be added to
  42642. */
  42643. constructor(
  42644. /** The utility layer the gizmo will be added to */
  42645. gizmoLayer?: UtilityLayerRenderer);
  42646. /**
  42647. * Updates the gizmo to match the attached mesh's position/rotation
  42648. */
  42649. protected _update(): void;
  42650. /**
  42651. * Disposes of the gizmo
  42652. */
  42653. dispose(): void;
  42654. }
  42655. }
  42656. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42657. import { Observable } from "babylonjs/Misc/observable";
  42658. import { Nullable } from "babylonjs/types";
  42659. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42662. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42663. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42664. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42665. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42666. import { Scene } from "babylonjs/scene";
  42667. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42668. /**
  42669. * Single plane drag gizmo
  42670. */
  42671. export class PlaneDragGizmo extends Gizmo {
  42672. /**
  42673. * Drag behavior responsible for the gizmos dragging interactions
  42674. */
  42675. dragBehavior: PointerDragBehavior;
  42676. private _pointerObserver;
  42677. /**
  42678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42679. */
  42680. snapDistance: number;
  42681. /**
  42682. * Event that fires each time the gizmo snaps to a new location.
  42683. * * snapDistance is the the change in distance
  42684. */
  42685. onSnapObservable: Observable<{
  42686. snapDistance: number;
  42687. }>;
  42688. private _plane;
  42689. private _coloredMaterial;
  42690. private _hoverMaterial;
  42691. private _isEnabled;
  42692. private _parent;
  42693. /** @hidden */
  42694. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42695. /** @hidden */
  42696. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42697. /**
  42698. * Creates a PlaneDragGizmo
  42699. * @param gizmoLayer The utility layer the gizmo will be added to
  42700. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42701. * @param color The color of the gizmo
  42702. */
  42703. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42704. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42705. /**
  42706. * If the gizmo is enabled
  42707. */
  42708. isEnabled: boolean;
  42709. /**
  42710. * Disposes of the gizmo
  42711. */
  42712. dispose(): void;
  42713. }
  42714. }
  42715. declare module "babylonjs/Gizmos/positionGizmo" {
  42716. import { Observable } from "babylonjs/Misc/observable";
  42717. import { Nullable } from "babylonjs/types";
  42718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42719. import { Mesh } from "babylonjs/Meshes/mesh";
  42720. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42721. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42722. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42723. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42724. /**
  42725. * Gizmo that enables dragging a mesh along 3 axis
  42726. */
  42727. export class PositionGizmo extends Gizmo {
  42728. /**
  42729. * Internal gizmo used for interactions on the x axis
  42730. */
  42731. xGizmo: AxisDragGizmo;
  42732. /**
  42733. * Internal gizmo used for interactions on the y axis
  42734. */
  42735. yGizmo: AxisDragGizmo;
  42736. /**
  42737. * Internal gizmo used for interactions on the z axis
  42738. */
  42739. zGizmo: AxisDragGizmo;
  42740. /**
  42741. * Internal gizmo used for interactions on the yz plane
  42742. */
  42743. xPlaneGizmo: PlaneDragGizmo;
  42744. /**
  42745. * Internal gizmo used for interactions on the xz plane
  42746. */
  42747. yPlaneGizmo: PlaneDragGizmo;
  42748. /**
  42749. * Internal gizmo used for interactions on the xy plane
  42750. */
  42751. zPlaneGizmo: PlaneDragGizmo;
  42752. /**
  42753. * private variables
  42754. */
  42755. private _meshAttached;
  42756. private _updateGizmoRotationToMatchAttachedMesh;
  42757. private _snapDistance;
  42758. private _scaleRatio;
  42759. /** Fires an event when any of it's sub gizmos are dragged */
  42760. onDragStartObservable: Observable<unknown>;
  42761. /** Fires an event when any of it's sub gizmos are released from dragging */
  42762. onDragEndObservable: Observable<unknown>;
  42763. /**
  42764. * If set to true, planar drag is enabled
  42765. */
  42766. private _planarGizmoEnabled;
  42767. attachedMesh: Nullable<AbstractMesh>;
  42768. /**
  42769. * Creates a PositionGizmo
  42770. * @param gizmoLayer The utility layer the gizmo will be added to
  42771. */
  42772. constructor(gizmoLayer?: UtilityLayerRenderer);
  42773. /**
  42774. * If the planar drag gizmo is enabled
  42775. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42776. */
  42777. planarGizmoEnabled: boolean;
  42778. updateGizmoRotationToMatchAttachedMesh: boolean;
  42779. /**
  42780. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42781. */
  42782. snapDistance: number;
  42783. /**
  42784. * Ratio for the scale of the gizmo (Default: 1)
  42785. */
  42786. scaleRatio: number;
  42787. /**
  42788. * Disposes of the gizmo
  42789. */
  42790. dispose(): void;
  42791. /**
  42792. * CustomMeshes are not supported by this gizmo
  42793. * @param mesh The mesh to replace the default mesh of the gizmo
  42794. */
  42795. setCustomMesh(mesh: Mesh): void;
  42796. }
  42797. }
  42798. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42799. import { Observable } from "babylonjs/Misc/observable";
  42800. import { Nullable } from "babylonjs/types";
  42801. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42802. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42804. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42805. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42806. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42807. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42808. import { Scene } from "babylonjs/scene";
  42809. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42810. /**
  42811. * Single axis drag gizmo
  42812. */
  42813. export class AxisDragGizmo extends Gizmo {
  42814. /**
  42815. * Drag behavior responsible for the gizmos dragging interactions
  42816. */
  42817. dragBehavior: PointerDragBehavior;
  42818. private _pointerObserver;
  42819. /**
  42820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42821. */
  42822. snapDistance: number;
  42823. /**
  42824. * Event that fires each time the gizmo snaps to a new location.
  42825. * * snapDistance is the the change in distance
  42826. */
  42827. onSnapObservable: Observable<{
  42828. snapDistance: number;
  42829. }>;
  42830. private _isEnabled;
  42831. private _parent;
  42832. private _arrow;
  42833. private _coloredMaterial;
  42834. private _hoverMaterial;
  42835. /** @hidden */
  42836. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42837. /** @hidden */
  42838. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42839. /**
  42840. * Creates an AxisDragGizmo
  42841. * @param gizmoLayer The utility layer the gizmo will be added to
  42842. * @param dragAxis The axis which the gizmo will be able to drag on
  42843. * @param color The color of the gizmo
  42844. */
  42845. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42846. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42847. /**
  42848. * If the gizmo is enabled
  42849. */
  42850. isEnabled: boolean;
  42851. /**
  42852. * Disposes of the gizmo
  42853. */
  42854. dispose(): void;
  42855. }
  42856. }
  42857. declare module "babylonjs/Debug/axesViewer" {
  42858. import { Vector3 } from "babylonjs/Maths/math";
  42859. import { Nullable } from "babylonjs/types";
  42860. import { Scene } from "babylonjs/scene";
  42861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42862. /**
  42863. * The Axes viewer will show 3 axes in a specific point in space
  42864. */
  42865. export class AxesViewer {
  42866. private _xAxis;
  42867. private _yAxis;
  42868. private _zAxis;
  42869. private _scaleLinesFactor;
  42870. private _instanced;
  42871. /**
  42872. * Gets the hosting scene
  42873. */
  42874. scene: Scene;
  42875. /**
  42876. * Gets or sets a number used to scale line length
  42877. */
  42878. scaleLines: number;
  42879. /** Gets the node hierarchy used to render x-axis */
  42880. readonly xAxis: TransformNode;
  42881. /** Gets the node hierarchy used to render y-axis */
  42882. readonly yAxis: TransformNode;
  42883. /** Gets the node hierarchy used to render z-axis */
  42884. readonly zAxis: TransformNode;
  42885. /**
  42886. * Creates a new AxesViewer
  42887. * @param scene defines the hosting scene
  42888. * @param scaleLines defines a number used to scale line length (1 by default)
  42889. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42890. * @param xAxis defines the node hierarchy used to render the x-axis
  42891. * @param yAxis defines the node hierarchy used to render the y-axis
  42892. * @param zAxis defines the node hierarchy used to render the z-axis
  42893. */
  42894. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42895. /**
  42896. * Force the viewer to update
  42897. * @param position defines the position of the viewer
  42898. * @param xaxis defines the x axis of the viewer
  42899. * @param yaxis defines the y axis of the viewer
  42900. * @param zaxis defines the z axis of the viewer
  42901. */
  42902. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42903. /**
  42904. * Creates an instance of this axes viewer.
  42905. * @returns a new axes viewer with instanced meshes
  42906. */
  42907. createInstance(): AxesViewer;
  42908. /** Releases resources */
  42909. dispose(): void;
  42910. private static _SetRenderingGroupId;
  42911. }
  42912. }
  42913. declare module "babylonjs/Debug/boneAxesViewer" {
  42914. import { Nullable } from "babylonjs/types";
  42915. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42916. import { Vector3 } from "babylonjs/Maths/math";
  42917. import { Mesh } from "babylonjs/Meshes/mesh";
  42918. import { Bone } from "babylonjs/Bones/bone";
  42919. import { Scene } from "babylonjs/scene";
  42920. /**
  42921. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42922. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42923. */
  42924. export class BoneAxesViewer extends AxesViewer {
  42925. /**
  42926. * Gets or sets the target mesh where to display the axes viewer
  42927. */
  42928. mesh: Nullable<Mesh>;
  42929. /**
  42930. * Gets or sets the target bone where to display the axes viewer
  42931. */
  42932. bone: Nullable<Bone>;
  42933. /** Gets current position */
  42934. pos: Vector3;
  42935. /** Gets direction of X axis */
  42936. xaxis: Vector3;
  42937. /** Gets direction of Y axis */
  42938. yaxis: Vector3;
  42939. /** Gets direction of Z axis */
  42940. zaxis: Vector3;
  42941. /**
  42942. * Creates a new BoneAxesViewer
  42943. * @param scene defines the hosting scene
  42944. * @param bone defines the target bone
  42945. * @param mesh defines the target mesh
  42946. * @param scaleLines defines a scaling factor for line length (1 by default)
  42947. */
  42948. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42949. /**
  42950. * Force the viewer to update
  42951. */
  42952. update(): void;
  42953. /** Releases resources */
  42954. dispose(): void;
  42955. }
  42956. }
  42957. declare module "babylonjs/Debug/debugLayer" {
  42958. import { Observable } from "babylonjs/Misc/observable";
  42959. import { Scene } from "babylonjs/scene";
  42960. /**
  42961. * Interface used to define scene explorer extensibility option
  42962. */
  42963. export interface IExplorerExtensibilityOption {
  42964. /**
  42965. * Define the option label
  42966. */
  42967. label: string;
  42968. /**
  42969. * Defines the action to execute on click
  42970. */
  42971. action: (entity: any) => void;
  42972. }
  42973. /**
  42974. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42975. */
  42976. export interface IExplorerExtensibilityGroup {
  42977. /**
  42978. * Defines a predicate to test if a given type mut be extended
  42979. */
  42980. predicate: (entity: any) => boolean;
  42981. /**
  42982. * Gets the list of options added to a type
  42983. */
  42984. entries: IExplorerExtensibilityOption[];
  42985. }
  42986. /**
  42987. * Interface used to define the options to use to create the Inspector
  42988. */
  42989. export interface IInspectorOptions {
  42990. /**
  42991. * Display in overlay mode (default: false)
  42992. */
  42993. overlay?: boolean;
  42994. /**
  42995. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42996. */
  42997. globalRoot?: HTMLElement;
  42998. /**
  42999. * Display the Scene explorer
  43000. */
  43001. showExplorer?: boolean;
  43002. /**
  43003. * Display the property inspector
  43004. */
  43005. showInspector?: boolean;
  43006. /**
  43007. * Display in embed mode (both panes on the right)
  43008. */
  43009. embedMode?: boolean;
  43010. /**
  43011. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43012. */
  43013. handleResize?: boolean;
  43014. /**
  43015. * Allow the panes to popup (default: true)
  43016. */
  43017. enablePopup?: boolean;
  43018. /**
  43019. * Allow the panes to be closed by users (default: true)
  43020. */
  43021. enableClose?: boolean;
  43022. /**
  43023. * Optional list of extensibility entries
  43024. */
  43025. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43026. /**
  43027. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43028. */
  43029. inspectorURL?: string;
  43030. }
  43031. module "babylonjs/scene" {
  43032. interface Scene {
  43033. /**
  43034. * @hidden
  43035. * Backing field
  43036. */
  43037. _debugLayer: DebugLayer;
  43038. /**
  43039. * Gets the debug layer (aka Inspector) associated with the scene
  43040. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43041. */
  43042. debugLayer: DebugLayer;
  43043. }
  43044. }
  43045. /**
  43046. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43047. * what is happening in your scene
  43048. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43049. */
  43050. export class DebugLayer {
  43051. /**
  43052. * Define the url to get the inspector script from.
  43053. * By default it uses the babylonjs CDN.
  43054. * @ignoreNaming
  43055. */
  43056. static InspectorURL: string;
  43057. private _scene;
  43058. private BJSINSPECTOR;
  43059. /**
  43060. * Observable triggered when a property is changed through the inspector.
  43061. */
  43062. onPropertyChangedObservable: Observable<{
  43063. object: any;
  43064. property: string;
  43065. value: any;
  43066. initialValue: any;
  43067. }>;
  43068. /**
  43069. * Instantiates a new debug layer.
  43070. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43071. * what is happening in your scene
  43072. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43073. * @param scene Defines the scene to inspect
  43074. */
  43075. constructor(scene: Scene);
  43076. /** Creates the inspector window. */
  43077. private _createInspector;
  43078. /**
  43079. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43080. * @param entity defines the entity to select
  43081. * @param lineContainerTitle defines the specific block to highlight
  43082. */
  43083. select(entity: any, lineContainerTitle?: string): void;
  43084. /** Get the inspector from bundle or global */
  43085. private _getGlobalInspector;
  43086. /**
  43087. * Get if the inspector is visible or not.
  43088. * @returns true if visible otherwise, false
  43089. */
  43090. isVisible(): boolean;
  43091. /**
  43092. * Hide the inspector and close its window.
  43093. */
  43094. hide(): void;
  43095. /**
  43096. * Launch the debugLayer.
  43097. * @param config Define the configuration of the inspector
  43098. * @return a promise fulfilled when the debug layer is visible
  43099. */
  43100. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43101. }
  43102. }
  43103. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43104. import { Nullable } from "babylonjs/types";
  43105. import { Scene } from "babylonjs/scene";
  43106. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43107. import { Mesh } from "babylonjs/Meshes/mesh";
  43108. /**
  43109. * Class containing static functions to help procedurally build meshes
  43110. */
  43111. export class BoxBuilder {
  43112. /**
  43113. * Creates a box mesh
  43114. * * The parameter `size` sets the size (float) of each box side (default 1)
  43115. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43116. * * 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)
  43117. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43121. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43122. * @param name defines the name of the mesh
  43123. * @param options defines the options used to create the mesh
  43124. * @param scene defines the hosting scene
  43125. * @returns the box mesh
  43126. */
  43127. static CreateBox(name: string, options: {
  43128. size?: number;
  43129. width?: number;
  43130. height?: number;
  43131. depth?: number;
  43132. faceUV?: Vector4[];
  43133. faceColors?: Color4[];
  43134. sideOrientation?: number;
  43135. frontUVs?: Vector4;
  43136. backUVs?: Vector4;
  43137. wrap?: boolean;
  43138. topBaseAt?: number;
  43139. bottomBaseAt?: number;
  43140. updatable?: boolean;
  43141. }, scene?: Nullable<Scene>): Mesh;
  43142. }
  43143. }
  43144. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43145. import { Vector4 } from "babylonjs/Maths/math";
  43146. import { Mesh } from "babylonjs/Meshes/mesh";
  43147. /**
  43148. * Class containing static functions to help procedurally build meshes
  43149. */
  43150. export class SphereBuilder {
  43151. /**
  43152. * Creates a sphere mesh
  43153. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43154. * * 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`)
  43155. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43156. * * 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
  43157. * * 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)
  43158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43161. * @param name defines the name of the mesh
  43162. * @param options defines the options used to create the mesh
  43163. * @param scene defines the hosting scene
  43164. * @returns the sphere mesh
  43165. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43166. */
  43167. static CreateSphere(name: string, options: {
  43168. segments?: number;
  43169. diameter?: number;
  43170. diameterX?: number;
  43171. diameterY?: number;
  43172. diameterZ?: number;
  43173. arc?: number;
  43174. slice?: number;
  43175. sideOrientation?: number;
  43176. frontUVs?: Vector4;
  43177. backUVs?: Vector4;
  43178. updatable?: boolean;
  43179. }, scene: any): Mesh;
  43180. }
  43181. }
  43182. declare module "babylonjs/Debug/physicsViewer" {
  43183. import { Nullable } from "babylonjs/types";
  43184. import { Scene } from "babylonjs/scene";
  43185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43186. import { Mesh } from "babylonjs/Meshes/mesh";
  43187. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43188. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43189. /**
  43190. * Used to show the physics impostor around the specific mesh
  43191. */
  43192. export class PhysicsViewer {
  43193. /** @hidden */
  43194. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43195. /** @hidden */
  43196. protected _meshes: Array<Nullable<AbstractMesh>>;
  43197. /** @hidden */
  43198. protected _scene: Nullable<Scene>;
  43199. /** @hidden */
  43200. protected _numMeshes: number;
  43201. /** @hidden */
  43202. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43203. private _renderFunction;
  43204. private _utilityLayer;
  43205. private _debugBoxMesh;
  43206. private _debugSphereMesh;
  43207. private _debugCylinderMesh;
  43208. private _debugMaterial;
  43209. private _debugMeshMeshes;
  43210. /**
  43211. * Creates a new PhysicsViewer
  43212. * @param scene defines the hosting scene
  43213. */
  43214. constructor(scene: Scene);
  43215. /** @hidden */
  43216. protected _updateDebugMeshes(): void;
  43217. /**
  43218. * Renders a specified physic impostor
  43219. * @param impostor defines the impostor to render
  43220. * @param targetMesh defines the mesh represented by the impostor
  43221. * @returns the new debug mesh used to render the impostor
  43222. */
  43223. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43224. /**
  43225. * Hides a specified physic impostor
  43226. * @param impostor defines the impostor to hide
  43227. */
  43228. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43229. private _getDebugMaterial;
  43230. private _getDebugBoxMesh;
  43231. private _getDebugSphereMesh;
  43232. private _getDebugCylinderMesh;
  43233. private _getDebugMeshMesh;
  43234. private _getDebugMesh;
  43235. /** Releases all resources */
  43236. dispose(): void;
  43237. }
  43238. }
  43239. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43240. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43241. import { Nullable } from "babylonjs/types";
  43242. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43243. import { Scene } from "babylonjs/scene";
  43244. /**
  43245. * Class containing static functions to help procedurally build meshes
  43246. */
  43247. export class LinesBuilder {
  43248. /**
  43249. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43250. * * 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
  43251. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43252. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43253. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43254. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43255. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43256. * * 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
  43257. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43260. * @param name defines the name of the new line system
  43261. * @param options defines the options used to create the line system
  43262. * @param scene defines the hosting scene
  43263. * @returns a new line system mesh
  43264. */
  43265. static CreateLineSystem(name: string, options: {
  43266. lines: Vector3[][];
  43267. updatable?: boolean;
  43268. instance?: Nullable<LinesMesh>;
  43269. colors?: Nullable<Color4[][]>;
  43270. useVertexAlpha?: boolean;
  43271. }, scene: Nullable<Scene>): LinesMesh;
  43272. /**
  43273. * Creates a line mesh
  43274. * 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
  43275. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43276. * * The parameter `points` is an array successive Vector3
  43277. * * 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
  43278. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43279. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43280. * * When updating an instance, remember that only point positions can change, not the number of points
  43281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43283. * @param name defines the name of the new line system
  43284. * @param options defines the options used to create the line system
  43285. * @param scene defines the hosting scene
  43286. * @returns a new line mesh
  43287. */
  43288. static CreateLines(name: string, options: {
  43289. points: Vector3[];
  43290. updatable?: boolean;
  43291. instance?: Nullable<LinesMesh>;
  43292. colors?: Color4[];
  43293. useVertexAlpha?: boolean;
  43294. }, scene?: Nullable<Scene>): LinesMesh;
  43295. /**
  43296. * Creates a dashed line mesh
  43297. * * 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
  43298. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43299. * * The parameter `points` is an array successive Vector3
  43300. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43301. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43302. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43303. * * 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
  43304. * * When updating an instance, remember that only point positions can change, not the number of points
  43305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43306. * @param name defines the name of the mesh
  43307. * @param options defines the options used to create the mesh
  43308. * @param scene defines the hosting scene
  43309. * @returns the dashed line mesh
  43310. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43311. */
  43312. static CreateDashedLines(name: string, options: {
  43313. points: Vector3[];
  43314. dashSize?: number;
  43315. gapSize?: number;
  43316. dashNb?: number;
  43317. updatable?: boolean;
  43318. instance?: LinesMesh;
  43319. }, scene?: Nullable<Scene>): LinesMesh;
  43320. }
  43321. }
  43322. declare module "babylonjs/Debug/rayHelper" {
  43323. import { Nullable } from "babylonjs/types";
  43324. import { Ray } from "babylonjs/Culling/ray";
  43325. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43326. import { Scene } from "babylonjs/scene";
  43327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43328. import "babylonjs/Meshes/Builders/linesBuilder";
  43329. /**
  43330. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43331. * in order to better appreciate the issue one might have.
  43332. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43333. */
  43334. export class RayHelper {
  43335. /**
  43336. * Defines the ray we are currently tryin to visualize.
  43337. */
  43338. ray: Nullable<Ray>;
  43339. private _renderPoints;
  43340. private _renderLine;
  43341. private _renderFunction;
  43342. private _scene;
  43343. private _updateToMeshFunction;
  43344. private _attachedToMesh;
  43345. private _meshSpaceDirection;
  43346. private _meshSpaceOrigin;
  43347. /**
  43348. * Helper function to create a colored helper in a scene in one line.
  43349. * @param ray Defines the ray we are currently tryin to visualize
  43350. * @param scene Defines the scene the ray is used in
  43351. * @param color Defines the color we want to see the ray in
  43352. * @returns The newly created ray helper.
  43353. */
  43354. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43355. /**
  43356. * Instantiate a new ray helper.
  43357. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43358. * in order to better appreciate the issue one might have.
  43359. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43360. * @param ray Defines the ray we are currently tryin to visualize
  43361. */
  43362. constructor(ray: Ray);
  43363. /**
  43364. * Shows the ray we are willing to debug.
  43365. * @param scene Defines the scene the ray needs to be rendered in
  43366. * @param color Defines the color the ray needs to be rendered in
  43367. */
  43368. show(scene: Scene, color?: Color3): void;
  43369. /**
  43370. * Hides the ray we are debugging.
  43371. */
  43372. hide(): void;
  43373. private _render;
  43374. /**
  43375. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43376. * @param mesh Defines the mesh we want the helper attached to
  43377. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43378. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43379. * @param length Defines the length of the ray
  43380. */
  43381. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43382. /**
  43383. * Detach the ray helper from the mesh it has previously been attached to.
  43384. */
  43385. detachFromMesh(): void;
  43386. private _updateToMesh;
  43387. /**
  43388. * Dispose the helper and release its associated resources.
  43389. */
  43390. dispose(): void;
  43391. }
  43392. }
  43393. declare module "babylonjs/Debug/skeletonViewer" {
  43394. import { Color3 } from "babylonjs/Maths/math";
  43395. import { Scene } from "babylonjs/scene";
  43396. import { Nullable } from "babylonjs/types";
  43397. import { Skeleton } from "babylonjs/Bones/skeleton";
  43398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43399. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43400. /**
  43401. * Class used to render a debug view of a given skeleton
  43402. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43403. */
  43404. export class SkeletonViewer {
  43405. /** defines the skeleton to render */
  43406. skeleton: Skeleton;
  43407. /** defines the mesh attached to the skeleton */
  43408. mesh: AbstractMesh;
  43409. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43410. autoUpdateBonesMatrices: boolean;
  43411. /** defines the rendering group id to use with the viewer */
  43412. renderingGroupId: number;
  43413. /** Gets or sets the color used to render the skeleton */
  43414. color: Color3;
  43415. private _scene;
  43416. private _debugLines;
  43417. private _debugMesh;
  43418. private _isEnabled;
  43419. private _renderFunction;
  43420. private _utilityLayer;
  43421. /**
  43422. * Returns the mesh used to render the bones
  43423. */
  43424. readonly debugMesh: Nullable<LinesMesh>;
  43425. /**
  43426. * Creates a new SkeletonViewer
  43427. * @param skeleton defines the skeleton to render
  43428. * @param mesh defines the mesh attached to the skeleton
  43429. * @param scene defines the hosting scene
  43430. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43431. * @param renderingGroupId defines the rendering group id to use with the viewer
  43432. */
  43433. constructor(
  43434. /** defines the skeleton to render */
  43435. skeleton: Skeleton,
  43436. /** defines the mesh attached to the skeleton */
  43437. mesh: AbstractMesh, scene: Scene,
  43438. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43439. autoUpdateBonesMatrices?: boolean,
  43440. /** defines the rendering group id to use with the viewer */
  43441. renderingGroupId?: number);
  43442. /** Gets or sets a boolean indicating if the viewer is enabled */
  43443. isEnabled: boolean;
  43444. private _getBonePosition;
  43445. private _getLinesForBonesWithLength;
  43446. private _getLinesForBonesNoLength;
  43447. /** Update the viewer to sync with current skeleton state */
  43448. update(): void;
  43449. /** Release associated resources */
  43450. dispose(): void;
  43451. }
  43452. }
  43453. declare module "babylonjs/Debug/index" {
  43454. export * from "babylonjs/Debug/axesViewer";
  43455. export * from "babylonjs/Debug/boneAxesViewer";
  43456. export * from "babylonjs/Debug/debugLayer";
  43457. export * from "babylonjs/Debug/physicsViewer";
  43458. export * from "babylonjs/Debug/rayHelper";
  43459. export * from "babylonjs/Debug/skeletonViewer";
  43460. }
  43461. declare module "babylonjs/Engines/nullEngine" {
  43462. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43463. import { Scene } from "babylonjs/scene";
  43464. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43465. import { Engine } from "babylonjs/Engines/engine";
  43466. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43467. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43468. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43469. import { Effect } from "babylonjs/Materials/effect";
  43470. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43471. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43472. /**
  43473. * Options to create the null engine
  43474. */
  43475. export class NullEngineOptions {
  43476. /**
  43477. * Render width (Default: 512)
  43478. */
  43479. renderWidth: number;
  43480. /**
  43481. * Render height (Default: 256)
  43482. */
  43483. renderHeight: number;
  43484. /**
  43485. * Texture size (Default: 512)
  43486. */
  43487. textureSize: number;
  43488. /**
  43489. * If delta time between frames should be constant
  43490. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43491. */
  43492. deterministicLockstep: boolean;
  43493. /**
  43494. * Maximum about of steps between frames (Default: 4)
  43495. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43496. */
  43497. lockstepMaxSteps: number;
  43498. }
  43499. /**
  43500. * The null engine class provides support for headless version of babylon.js.
  43501. * This can be used in server side scenario or for testing purposes
  43502. */
  43503. export class NullEngine extends Engine {
  43504. private _options;
  43505. /**
  43506. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43507. */
  43508. isDeterministicLockStep(): boolean;
  43509. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43510. getLockstepMaxSteps(): number;
  43511. /**
  43512. * Sets hardware scaling, used to save performance if needed
  43513. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43514. */
  43515. getHardwareScalingLevel(): number;
  43516. constructor(options?: NullEngineOptions);
  43517. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43518. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43519. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43520. getRenderWidth(useScreen?: boolean): number;
  43521. getRenderHeight(useScreen?: boolean): number;
  43522. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43523. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43524. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43525. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43526. bindSamplers(effect: Effect): void;
  43527. enableEffect(effect: Effect): void;
  43528. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43529. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43530. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43531. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43532. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43533. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43534. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43535. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43536. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43537. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43538. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43539. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43540. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43541. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43542. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43543. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43544. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43545. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43546. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43547. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43548. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43549. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43550. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43551. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43552. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43553. bindBuffers(vertexBuffers: {
  43554. [key: string]: VertexBuffer;
  43555. }, indexBuffer: DataBuffer, effect: Effect): void;
  43556. wipeCaches(bruteForce?: boolean): void;
  43557. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43558. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43559. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43560. /** @hidden */
  43561. _createTexture(): WebGLTexture;
  43562. /** @hidden */
  43563. _releaseTexture(texture: InternalTexture): void;
  43564. 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;
  43565. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43566. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43567. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43568. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43569. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43570. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43571. areAllEffectsReady(): boolean;
  43572. /**
  43573. * @hidden
  43574. * Get the current error code of the webGL context
  43575. * @returns the error code
  43576. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43577. */
  43578. getError(): number;
  43579. /** @hidden */
  43580. _getUnpackAlignement(): number;
  43581. /** @hidden */
  43582. _unpackFlipY(value: boolean): void;
  43583. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43584. /**
  43585. * Updates a dynamic vertex buffer.
  43586. * @param vertexBuffer the vertex buffer to update
  43587. * @param data the data used to update the vertex buffer
  43588. * @param byteOffset the byte offset of the data (optional)
  43589. * @param byteLength the byte length of the data (optional)
  43590. */
  43591. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43592. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43593. /** @hidden */
  43594. _bindTexture(channel: number, texture: InternalTexture): void;
  43595. /** @hidden */
  43596. _releaseBuffer(buffer: DataBuffer): boolean;
  43597. releaseEffects(): void;
  43598. displayLoadingUI(): void;
  43599. hideLoadingUI(): void;
  43600. /** @hidden */
  43601. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43602. /** @hidden */
  43603. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43604. /** @hidden */
  43605. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43606. /** @hidden */
  43607. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43608. }
  43609. }
  43610. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43611. import { Nullable, int } from "babylonjs/types";
  43612. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43613. /** @hidden */
  43614. export class _OcclusionDataStorage {
  43615. /** @hidden */
  43616. occlusionInternalRetryCounter: number;
  43617. /** @hidden */
  43618. isOcclusionQueryInProgress: boolean;
  43619. /** @hidden */
  43620. isOccluded: boolean;
  43621. /** @hidden */
  43622. occlusionRetryCount: number;
  43623. /** @hidden */
  43624. occlusionType: number;
  43625. /** @hidden */
  43626. occlusionQueryAlgorithmType: number;
  43627. }
  43628. module "babylonjs/Engines/engine" {
  43629. interface Engine {
  43630. /**
  43631. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43632. * @return the new query
  43633. */
  43634. createQuery(): WebGLQuery;
  43635. /**
  43636. * Delete and release a webGL query
  43637. * @param query defines the query to delete
  43638. * @return the current engine
  43639. */
  43640. deleteQuery(query: WebGLQuery): Engine;
  43641. /**
  43642. * Check if a given query has resolved and got its value
  43643. * @param query defines the query to check
  43644. * @returns true if the query got its value
  43645. */
  43646. isQueryResultAvailable(query: WebGLQuery): boolean;
  43647. /**
  43648. * Gets the value of a given query
  43649. * @param query defines the query to check
  43650. * @returns the value of the query
  43651. */
  43652. getQueryResult(query: WebGLQuery): number;
  43653. /**
  43654. * Initiates an occlusion query
  43655. * @param algorithmType defines the algorithm to use
  43656. * @param query defines the query to use
  43657. * @returns the current engine
  43658. * @see http://doc.babylonjs.com/features/occlusionquery
  43659. */
  43660. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43661. /**
  43662. * Ends an occlusion query
  43663. * @see http://doc.babylonjs.com/features/occlusionquery
  43664. * @param algorithmType defines the algorithm to use
  43665. * @returns the current engine
  43666. */
  43667. endOcclusionQuery(algorithmType: number): Engine;
  43668. /**
  43669. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43670. * Please note that only one query can be issued at a time
  43671. * @returns a time token used to track the time span
  43672. */
  43673. startTimeQuery(): Nullable<_TimeToken>;
  43674. /**
  43675. * Ends a time query
  43676. * @param token defines the token used to measure the time span
  43677. * @returns the time spent (in ns)
  43678. */
  43679. endTimeQuery(token: _TimeToken): int;
  43680. /** @hidden */
  43681. _currentNonTimestampToken: Nullable<_TimeToken>;
  43682. /** @hidden */
  43683. _createTimeQuery(): WebGLQuery;
  43684. /** @hidden */
  43685. _deleteTimeQuery(query: WebGLQuery): void;
  43686. /** @hidden */
  43687. _getGlAlgorithmType(algorithmType: number): number;
  43688. /** @hidden */
  43689. _getTimeQueryResult(query: WebGLQuery): any;
  43690. /** @hidden */
  43691. _getTimeQueryAvailability(query: WebGLQuery): any;
  43692. }
  43693. }
  43694. module "babylonjs/Meshes/abstractMesh" {
  43695. interface AbstractMesh {
  43696. /**
  43697. * Backing filed
  43698. * @hidden
  43699. */
  43700. __occlusionDataStorage: _OcclusionDataStorage;
  43701. /**
  43702. * Access property
  43703. * @hidden
  43704. */
  43705. _occlusionDataStorage: _OcclusionDataStorage;
  43706. /**
  43707. * 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.
  43708. * The default value is -1 which means don't break the query and wait till the result
  43709. * @see http://doc.babylonjs.com/features/occlusionquery
  43710. */
  43711. occlusionRetryCount: number;
  43712. /**
  43713. * 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:
  43714. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43715. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43716. * * 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.
  43717. * @see http://doc.babylonjs.com/features/occlusionquery
  43718. */
  43719. occlusionType: number;
  43720. /**
  43721. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43722. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43723. * * 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.
  43724. * @see http://doc.babylonjs.com/features/occlusionquery
  43725. */
  43726. occlusionQueryAlgorithmType: number;
  43727. /**
  43728. * 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
  43729. * @see http://doc.babylonjs.com/features/occlusionquery
  43730. */
  43731. isOccluded: boolean;
  43732. /**
  43733. * Flag to check the progress status of the query
  43734. * @see http://doc.babylonjs.com/features/occlusionquery
  43735. */
  43736. isOcclusionQueryInProgress: boolean;
  43737. }
  43738. }
  43739. }
  43740. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43741. import { Nullable } from "babylonjs/types";
  43742. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43743. /** @hidden */
  43744. export var _forceTransformFeedbackToBundle: boolean;
  43745. module "babylonjs/Engines/engine" {
  43746. interface Engine {
  43747. /**
  43748. * Creates a webGL transform feedback object
  43749. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43750. * @returns the webGL transform feedback object
  43751. */
  43752. createTransformFeedback(): WebGLTransformFeedback;
  43753. /**
  43754. * Delete a webGL transform feedback object
  43755. * @param value defines the webGL transform feedback object to delete
  43756. */
  43757. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43758. /**
  43759. * Bind a webGL transform feedback object to the webgl context
  43760. * @param value defines the webGL transform feedback object to bind
  43761. */
  43762. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43763. /**
  43764. * Begins a transform feedback operation
  43765. * @param usePoints defines if points or triangles must be used
  43766. */
  43767. beginTransformFeedback(usePoints: boolean): void;
  43768. /**
  43769. * Ends a transform feedback operation
  43770. */
  43771. endTransformFeedback(): void;
  43772. /**
  43773. * Specify the varyings to use with transform feedback
  43774. * @param program defines the associated webGL program
  43775. * @param value defines the list of strings representing the varying names
  43776. */
  43777. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43778. /**
  43779. * Bind a webGL buffer for a transform feedback operation
  43780. * @param value defines the webGL buffer to bind
  43781. */
  43782. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43783. }
  43784. }
  43785. }
  43786. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43787. import { Scene } from "babylonjs/scene";
  43788. import { Engine } from "babylonjs/Engines/engine";
  43789. import { Texture } from "babylonjs/Materials/Textures/texture";
  43790. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43791. import "babylonjs/Engines/Extensions/engine.multiRender";
  43792. /**
  43793. * Creation options of the multi render target texture.
  43794. */
  43795. export interface IMultiRenderTargetOptions {
  43796. /**
  43797. * Define if the texture needs to create mip maps after render.
  43798. */
  43799. generateMipMaps?: boolean;
  43800. /**
  43801. * Define the types of all the draw buffers we want to create
  43802. */
  43803. types?: number[];
  43804. /**
  43805. * Define the sampling modes of all the draw buffers we want to create
  43806. */
  43807. samplingModes?: number[];
  43808. /**
  43809. * Define if a depth buffer is required
  43810. */
  43811. generateDepthBuffer?: boolean;
  43812. /**
  43813. * Define if a stencil buffer is required
  43814. */
  43815. generateStencilBuffer?: boolean;
  43816. /**
  43817. * Define if a depth texture is required instead of a depth buffer
  43818. */
  43819. generateDepthTexture?: boolean;
  43820. /**
  43821. * Define the number of desired draw buffers
  43822. */
  43823. textureCount?: number;
  43824. /**
  43825. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43826. */
  43827. doNotChangeAspectRatio?: boolean;
  43828. /**
  43829. * Define the default type of the buffers we are creating
  43830. */
  43831. defaultType?: number;
  43832. }
  43833. /**
  43834. * A multi render target, like a render target provides the ability to render to a texture.
  43835. * Unlike the render target, it can render to several draw buffers in one draw.
  43836. * This is specially interesting in deferred rendering or for any effects requiring more than
  43837. * just one color from a single pass.
  43838. */
  43839. export class MultiRenderTarget extends RenderTargetTexture {
  43840. private _internalTextures;
  43841. private _textures;
  43842. private _multiRenderTargetOptions;
  43843. /**
  43844. * Get if draw buffers are currently supported by the used hardware and browser.
  43845. */
  43846. readonly isSupported: boolean;
  43847. /**
  43848. * Get the list of textures generated by the multi render target.
  43849. */
  43850. readonly textures: Texture[];
  43851. /**
  43852. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43853. */
  43854. readonly depthTexture: Texture;
  43855. /**
  43856. * Set the wrapping mode on U of all the textures we are rendering to.
  43857. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43858. */
  43859. wrapU: number;
  43860. /**
  43861. * Set the wrapping mode on V of all the textures we are rendering to.
  43862. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43863. */
  43864. wrapV: number;
  43865. /**
  43866. * Instantiate a new multi render target texture.
  43867. * A multi render target, like a render target provides the ability to render to a texture.
  43868. * Unlike the render target, it can render to several draw buffers in one draw.
  43869. * This is specially interesting in deferred rendering or for any effects requiring more than
  43870. * just one color from a single pass.
  43871. * @param name Define the name of the texture
  43872. * @param size Define the size of the buffers to render to
  43873. * @param count Define the number of target we are rendering into
  43874. * @param scene Define the scene the texture belongs to
  43875. * @param options Define the options used to create the multi render target
  43876. */
  43877. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43878. /** @hidden */
  43879. _rebuild(): void;
  43880. private _createInternalTextures;
  43881. private _createTextures;
  43882. /**
  43883. * Define the number of samples used if MSAA is enabled.
  43884. */
  43885. samples: number;
  43886. /**
  43887. * Resize all the textures in the multi render target.
  43888. * Be carrefull as it will recreate all the data in the new texture.
  43889. * @param size Define the new size
  43890. */
  43891. resize(size: any): void;
  43892. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43893. /**
  43894. * Dispose the render targets and their associated resources
  43895. */
  43896. dispose(): void;
  43897. /**
  43898. * Release all the underlying texture used as draw buffers.
  43899. */
  43900. releaseInternalTextures(): void;
  43901. }
  43902. }
  43903. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43904. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43905. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43906. import { Nullable } from "babylonjs/types";
  43907. module "babylonjs/Engines/engine" {
  43908. interface Engine {
  43909. /**
  43910. * Unbind a list of render target textures from the webGL context
  43911. * This is used only when drawBuffer extension or webGL2 are active
  43912. * @param textures defines the render target textures to unbind
  43913. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43914. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43915. */
  43916. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43917. /**
  43918. * Create a multi render target texture
  43919. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43920. * @param size defines the size of the texture
  43921. * @param options defines the creation options
  43922. * @returns the cube texture as an InternalTexture
  43923. */
  43924. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43925. /**
  43926. * Update the sample count for a given multiple render target texture
  43927. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43928. * @param textures defines the textures to update
  43929. * @param samples defines the sample count to set
  43930. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43931. */
  43932. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43933. }
  43934. }
  43935. }
  43936. declare module "babylonjs/Engines/Extensions/index" {
  43937. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43938. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43939. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43940. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43941. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43942. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43943. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43944. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43945. }
  43946. declare module "babylonjs/Engines/index" {
  43947. export * from "babylonjs/Engines/constants";
  43948. export * from "babylonjs/Engines/engine";
  43949. export * from "babylonjs/Engines/engineStore";
  43950. export * from "babylonjs/Engines/nullEngine";
  43951. export * from "babylonjs/Engines/Extensions/index";
  43952. export * from "babylonjs/Engines/IPipelineContext";
  43953. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43954. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43955. }
  43956. declare module "babylonjs/Events/clipboardEvents" {
  43957. /**
  43958. * Gather the list of clipboard event types as constants.
  43959. */
  43960. export class ClipboardEventTypes {
  43961. /**
  43962. * The clipboard event is fired when a copy command is active (pressed).
  43963. */
  43964. static readonly COPY: number;
  43965. /**
  43966. * The clipboard event is fired when a cut command is active (pressed).
  43967. */
  43968. static readonly CUT: number;
  43969. /**
  43970. * The clipboard event is fired when a paste command is active (pressed).
  43971. */
  43972. static readonly PASTE: number;
  43973. }
  43974. /**
  43975. * This class is used to store clipboard related info for the onClipboardObservable event.
  43976. */
  43977. export class ClipboardInfo {
  43978. /**
  43979. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43980. */
  43981. type: number;
  43982. /**
  43983. * Defines the related dom event
  43984. */
  43985. event: ClipboardEvent;
  43986. /**
  43987. *Creates an instance of ClipboardInfo.
  43988. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43989. * @param event Defines the related dom event
  43990. */
  43991. constructor(
  43992. /**
  43993. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43994. */
  43995. type: number,
  43996. /**
  43997. * Defines the related dom event
  43998. */
  43999. event: ClipboardEvent);
  44000. /**
  44001. * Get the clipboard event's type from the keycode.
  44002. * @param keyCode Defines the keyCode for the current keyboard event.
  44003. * @return {number}
  44004. */
  44005. static GetTypeFromCharacter(keyCode: number): number;
  44006. }
  44007. }
  44008. declare module "babylonjs/Events/index" {
  44009. export * from "babylonjs/Events/keyboardEvents";
  44010. export * from "babylonjs/Events/pointerEvents";
  44011. export * from "babylonjs/Events/clipboardEvents";
  44012. }
  44013. declare module "babylonjs/Loading/sceneLoader" {
  44014. import { Observable } from "babylonjs/Misc/observable";
  44015. import { Nullable } from "babylonjs/types";
  44016. import { Scene } from "babylonjs/scene";
  44017. import { Engine } from "babylonjs/Engines/engine";
  44018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44019. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44020. import { AssetContainer } from "babylonjs/assetContainer";
  44021. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44022. import { Skeleton } from "babylonjs/Bones/skeleton";
  44023. /**
  44024. * Class used to represent data loading progression
  44025. */
  44026. export class SceneLoaderProgressEvent {
  44027. /** defines if data length to load can be evaluated */
  44028. readonly lengthComputable: boolean;
  44029. /** defines the loaded data length */
  44030. readonly loaded: number;
  44031. /** defines the data length to load */
  44032. readonly total: number;
  44033. /**
  44034. * Create a new progress event
  44035. * @param lengthComputable defines if data length to load can be evaluated
  44036. * @param loaded defines the loaded data length
  44037. * @param total defines the data length to load
  44038. */
  44039. constructor(
  44040. /** defines if data length to load can be evaluated */
  44041. lengthComputable: boolean,
  44042. /** defines the loaded data length */
  44043. loaded: number,
  44044. /** defines the data length to load */
  44045. total: number);
  44046. /**
  44047. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44048. * @param event defines the source event
  44049. * @returns a new SceneLoaderProgressEvent
  44050. */
  44051. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44052. }
  44053. /**
  44054. * Interface used by SceneLoader plugins to define supported file extensions
  44055. */
  44056. export interface ISceneLoaderPluginExtensions {
  44057. /**
  44058. * Defines the list of supported extensions
  44059. */
  44060. [extension: string]: {
  44061. isBinary: boolean;
  44062. };
  44063. }
  44064. /**
  44065. * Interface used by SceneLoader plugin factory
  44066. */
  44067. export interface ISceneLoaderPluginFactory {
  44068. /**
  44069. * Defines the name of the factory
  44070. */
  44071. name: string;
  44072. /**
  44073. * Function called to create a new plugin
  44074. * @return the new plugin
  44075. */
  44076. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44077. /**
  44078. * Boolean indicating if the plugin can direct load specific data
  44079. */
  44080. canDirectLoad?: (data: string) => boolean;
  44081. }
  44082. /**
  44083. * Interface used to define a SceneLoader plugin
  44084. */
  44085. export interface ISceneLoaderPlugin {
  44086. /**
  44087. * The friendly name of this plugin.
  44088. */
  44089. name: string;
  44090. /**
  44091. * The file extensions supported by this plugin.
  44092. */
  44093. extensions: string | ISceneLoaderPluginExtensions;
  44094. /**
  44095. * Import meshes into a scene.
  44096. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44097. * @param scene The scene to import into
  44098. * @param data The data to import
  44099. * @param rootUrl The root url for scene and resources
  44100. * @param meshes The meshes array to import into
  44101. * @param particleSystems The particle systems array to import into
  44102. * @param skeletons The skeletons array to import into
  44103. * @param onError The callback when import fails
  44104. * @returns True if successful or false otherwise
  44105. */
  44106. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44107. /**
  44108. * Load into a scene.
  44109. * @param scene The scene to load into
  44110. * @param data The data to import
  44111. * @param rootUrl The root url for scene and resources
  44112. * @param onError The callback when import fails
  44113. * @returns true if successful or false otherwise
  44114. */
  44115. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44116. /**
  44117. * The callback that returns true if the data can be directly loaded.
  44118. */
  44119. canDirectLoad?: (data: string) => boolean;
  44120. /**
  44121. * The callback that allows custom handling of the root url based on the response url.
  44122. */
  44123. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44124. /**
  44125. * Load into an asset container.
  44126. * @param scene The scene to load into
  44127. * @param data The data to import
  44128. * @param rootUrl The root url for scene and resources
  44129. * @param onError The callback when import fails
  44130. * @returns The loaded asset container
  44131. */
  44132. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44133. }
  44134. /**
  44135. * Interface used to define an async SceneLoader plugin
  44136. */
  44137. export interface ISceneLoaderPluginAsync {
  44138. /**
  44139. * The friendly name of this plugin.
  44140. */
  44141. name: string;
  44142. /**
  44143. * The file extensions supported by this plugin.
  44144. */
  44145. extensions: string | ISceneLoaderPluginExtensions;
  44146. /**
  44147. * Import meshes into a scene.
  44148. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44149. * @param scene The scene to import into
  44150. * @param data The data to import
  44151. * @param rootUrl The root url for scene and resources
  44152. * @param onProgress The callback when the load progresses
  44153. * @param fileName Defines the name of the file to load
  44154. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44155. */
  44156. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44157. meshes: AbstractMesh[];
  44158. particleSystems: IParticleSystem[];
  44159. skeletons: Skeleton[];
  44160. animationGroups: AnimationGroup[];
  44161. }>;
  44162. /**
  44163. * Load into a scene.
  44164. * @param scene The scene to load into
  44165. * @param data The data to import
  44166. * @param rootUrl The root url for scene and resources
  44167. * @param onProgress The callback when the load progresses
  44168. * @param fileName Defines the name of the file to load
  44169. * @returns Nothing
  44170. */
  44171. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44172. /**
  44173. * The callback that returns true if the data can be directly loaded.
  44174. */
  44175. canDirectLoad?: (data: string) => boolean;
  44176. /**
  44177. * The callback that allows custom handling of the root url based on the response url.
  44178. */
  44179. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44180. /**
  44181. * Load into an asset container.
  44182. * @param scene The scene to load into
  44183. * @param data The data to import
  44184. * @param rootUrl The root url for scene and resources
  44185. * @param onProgress The callback when the load progresses
  44186. * @param fileName Defines the name of the file to load
  44187. * @returns The loaded asset container
  44188. */
  44189. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44190. }
  44191. /**
  44192. * Class used to load scene from various file formats using registered plugins
  44193. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44194. */
  44195. export class SceneLoader {
  44196. /**
  44197. * No logging while loading
  44198. */
  44199. static readonly NO_LOGGING: number;
  44200. /**
  44201. * Minimal logging while loading
  44202. */
  44203. static readonly MINIMAL_LOGGING: number;
  44204. /**
  44205. * Summary logging while loading
  44206. */
  44207. static readonly SUMMARY_LOGGING: number;
  44208. /**
  44209. * Detailled logging while loading
  44210. */
  44211. static readonly DETAILED_LOGGING: number;
  44212. /**
  44213. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44214. */
  44215. static ForceFullSceneLoadingForIncremental: boolean;
  44216. /**
  44217. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44218. */
  44219. static ShowLoadingScreen: boolean;
  44220. /**
  44221. * Defines the current logging level (while loading the scene)
  44222. * @ignorenaming
  44223. */
  44224. static loggingLevel: number;
  44225. /**
  44226. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44227. */
  44228. static CleanBoneMatrixWeights: boolean;
  44229. /**
  44230. * Event raised when a plugin is used to load a scene
  44231. */
  44232. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44233. private static _registeredPlugins;
  44234. private static _getDefaultPlugin;
  44235. private static _getPluginForExtension;
  44236. private static _getPluginForDirectLoad;
  44237. private static _getPluginForFilename;
  44238. private static _getDirectLoad;
  44239. private static _loadData;
  44240. private static _getFileInfo;
  44241. /**
  44242. * Gets a plugin that can load the given extension
  44243. * @param extension defines the extension to load
  44244. * @returns a plugin or null if none works
  44245. */
  44246. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44247. /**
  44248. * Gets a boolean indicating that the given extension can be loaded
  44249. * @param extension defines the extension to load
  44250. * @returns true if the extension is supported
  44251. */
  44252. static IsPluginForExtensionAvailable(extension: string): boolean;
  44253. /**
  44254. * Adds a new plugin to the list of registered plugins
  44255. * @param plugin defines the plugin to add
  44256. */
  44257. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44258. /**
  44259. * Import meshes into a scene
  44260. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44261. * @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)
  44262. * @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)
  44263. * @param scene the instance of BABYLON.Scene to append to
  44264. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44265. * @param onProgress a callback with a progress event for each file being loaded
  44266. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44267. * @param pluginExtension the extension used to determine the plugin
  44268. * @returns The loaded plugin
  44269. */
  44270. 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>;
  44271. /**
  44272. * Import meshes into a scene
  44273. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44274. * @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)
  44275. * @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)
  44276. * @param scene the instance of BABYLON.Scene to append to
  44277. * @param onProgress a callback with a progress event for each file being loaded
  44278. * @param pluginExtension the extension used to determine the plugin
  44279. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44280. */
  44281. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44282. meshes: AbstractMesh[];
  44283. particleSystems: IParticleSystem[];
  44284. skeletons: Skeleton[];
  44285. animationGroups: AnimationGroup[];
  44286. }>;
  44287. /**
  44288. * Load a scene
  44289. * @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)
  44290. * @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)
  44291. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44292. * @param onSuccess a callback with the scene when import succeeds
  44293. * @param onProgress a callback with a progress event for each file being loaded
  44294. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44295. * @param pluginExtension the extension used to determine the plugin
  44296. * @returns The loaded plugin
  44297. */
  44298. 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>;
  44299. /**
  44300. * Load a scene
  44301. * @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)
  44302. * @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)
  44303. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44304. * @param onProgress a callback with a progress event for each file being loaded
  44305. * @param pluginExtension the extension used to determine the plugin
  44306. * @returns The loaded scene
  44307. */
  44308. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44309. /**
  44310. * Append a scene
  44311. * @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)
  44312. * @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)
  44313. * @param scene is the instance of BABYLON.Scene to append to
  44314. * @param onSuccess a callback with the scene when import succeeds
  44315. * @param onProgress a callback with a progress event for each file being loaded
  44316. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44317. * @param pluginExtension the extension used to determine the plugin
  44318. * @returns The loaded plugin
  44319. */
  44320. 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>;
  44321. /**
  44322. * Append a scene
  44323. * @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)
  44324. * @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)
  44325. * @param scene is the instance of BABYLON.Scene to append to
  44326. * @param onProgress a callback with a progress event for each file being loaded
  44327. * @param pluginExtension the extension used to determine the plugin
  44328. * @returns The given scene
  44329. */
  44330. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44331. /**
  44332. * Load a scene into an asset container
  44333. * @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)
  44334. * @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)
  44335. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44336. * @param onSuccess a callback with the scene when import succeeds
  44337. * @param onProgress a callback with a progress event for each file being loaded
  44338. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44339. * @param pluginExtension the extension used to determine the plugin
  44340. * @returns The loaded plugin
  44341. */
  44342. 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>;
  44343. /**
  44344. * Load a scene into an asset container
  44345. * @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)
  44346. * @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)
  44347. * @param scene is the instance of Scene to append to
  44348. * @param onProgress a callback with a progress event for each file being loaded
  44349. * @param pluginExtension the extension used to determine the plugin
  44350. * @returns The loaded asset container
  44351. */
  44352. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44353. }
  44354. }
  44355. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44356. import { Scene } from "babylonjs/scene";
  44357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44358. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44359. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44360. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44361. /**
  44362. * Google Daydream controller
  44363. */
  44364. export class DaydreamController extends WebVRController {
  44365. /**
  44366. * Base Url for the controller model.
  44367. */
  44368. static MODEL_BASE_URL: string;
  44369. /**
  44370. * File name for the controller model.
  44371. */
  44372. static MODEL_FILENAME: string;
  44373. /**
  44374. * Gamepad Id prefix used to identify Daydream Controller.
  44375. */
  44376. static readonly GAMEPAD_ID_PREFIX: string;
  44377. /**
  44378. * Creates a new DaydreamController from a gamepad
  44379. * @param vrGamepad the gamepad that the controller should be created from
  44380. */
  44381. constructor(vrGamepad: any);
  44382. /**
  44383. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44384. * @param scene scene in which to add meshes
  44385. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44386. */
  44387. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44388. /**
  44389. * Called once for each button that changed state since the last frame
  44390. * @param buttonIdx Which button index changed
  44391. * @param state New state of the button
  44392. * @param changes Which properties on the state changed since last frame
  44393. */
  44394. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44395. }
  44396. }
  44397. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44398. import { Scene } from "babylonjs/scene";
  44399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44400. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44401. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44402. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44403. /**
  44404. * Gear VR Controller
  44405. */
  44406. export class GearVRController extends WebVRController {
  44407. /**
  44408. * Base Url for the controller model.
  44409. */
  44410. static MODEL_BASE_URL: string;
  44411. /**
  44412. * File name for the controller model.
  44413. */
  44414. static MODEL_FILENAME: string;
  44415. /**
  44416. * Gamepad Id prefix used to identify this controller.
  44417. */
  44418. static readonly GAMEPAD_ID_PREFIX: string;
  44419. private readonly _buttonIndexToObservableNameMap;
  44420. /**
  44421. * Creates a new GearVRController from a gamepad
  44422. * @param vrGamepad the gamepad that the controller should be created from
  44423. */
  44424. constructor(vrGamepad: any);
  44425. /**
  44426. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44427. * @param scene scene in which to add meshes
  44428. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44429. */
  44430. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44431. /**
  44432. * Called once for each button that changed state since the last frame
  44433. * @param buttonIdx Which button index changed
  44434. * @param state New state of the button
  44435. * @param changes Which properties on the state changed since last frame
  44436. */
  44437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44438. }
  44439. }
  44440. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44441. import { Scene } from "babylonjs/scene";
  44442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44443. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44444. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44445. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44446. /**
  44447. * Generic Controller
  44448. */
  44449. export class GenericController extends WebVRController {
  44450. /**
  44451. * Base Url for the controller model.
  44452. */
  44453. static readonly MODEL_BASE_URL: string;
  44454. /**
  44455. * File name for the controller model.
  44456. */
  44457. static readonly MODEL_FILENAME: string;
  44458. /**
  44459. * Creates a new GenericController from a gamepad
  44460. * @param vrGamepad the gamepad that the controller should be created from
  44461. */
  44462. constructor(vrGamepad: any);
  44463. /**
  44464. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44465. * @param scene scene in which to add meshes
  44466. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44467. */
  44468. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44469. /**
  44470. * Called once for each button that changed state since the last frame
  44471. * @param buttonIdx Which button index changed
  44472. * @param state New state of the button
  44473. * @param changes Which properties on the state changed since last frame
  44474. */
  44475. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44476. }
  44477. }
  44478. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44479. import { Observable } from "babylonjs/Misc/observable";
  44480. import { Scene } from "babylonjs/scene";
  44481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44482. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44483. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44484. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44485. /**
  44486. * Oculus Touch Controller
  44487. */
  44488. export class OculusTouchController extends WebVRController {
  44489. /**
  44490. * Base Url for the controller model.
  44491. */
  44492. static MODEL_BASE_URL: string;
  44493. /**
  44494. * File name for the left controller model.
  44495. */
  44496. static MODEL_LEFT_FILENAME: string;
  44497. /**
  44498. * File name for the right controller model.
  44499. */
  44500. static MODEL_RIGHT_FILENAME: string;
  44501. /**
  44502. * Fired when the secondary trigger on this controller is modified
  44503. */
  44504. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44505. /**
  44506. * Fired when the thumb rest on this controller is modified
  44507. */
  44508. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44509. /**
  44510. * Creates a new OculusTouchController from a gamepad
  44511. * @param vrGamepad the gamepad that the controller should be created from
  44512. */
  44513. constructor(vrGamepad: any);
  44514. /**
  44515. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44516. * @param scene scene in which to add meshes
  44517. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44518. */
  44519. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44520. /**
  44521. * Fired when the A button on this controller is modified
  44522. */
  44523. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44524. /**
  44525. * Fired when the B button on this controller is modified
  44526. */
  44527. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44528. /**
  44529. * Fired when the X button on this controller is modified
  44530. */
  44531. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44532. /**
  44533. * Fired when the Y button on this controller is modified
  44534. */
  44535. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44536. /**
  44537. * Called once for each button that changed state since the last frame
  44538. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44539. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44540. * 2) secondary trigger (same)
  44541. * 3) A (right) X (left), touch, pressed = value
  44542. * 4) B / Y
  44543. * 5) thumb rest
  44544. * @param buttonIdx Which button index changed
  44545. * @param state New state of the button
  44546. * @param changes Which properties on the state changed since last frame
  44547. */
  44548. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44549. }
  44550. }
  44551. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44552. import { Scene } from "babylonjs/scene";
  44553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44554. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44555. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44556. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44557. import { Observable } from "babylonjs/Misc/observable";
  44558. /**
  44559. * Vive Controller
  44560. */
  44561. export class ViveController extends WebVRController {
  44562. /**
  44563. * Base Url for the controller model.
  44564. */
  44565. static MODEL_BASE_URL: string;
  44566. /**
  44567. * File name for the controller model.
  44568. */
  44569. static MODEL_FILENAME: string;
  44570. /**
  44571. * Creates a new ViveController from a gamepad
  44572. * @param vrGamepad the gamepad that the controller should be created from
  44573. */
  44574. constructor(vrGamepad: any);
  44575. /**
  44576. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44577. * @param scene scene in which to add meshes
  44578. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44579. */
  44580. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44581. /**
  44582. * Fired when the left button on this controller is modified
  44583. */
  44584. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44585. /**
  44586. * Fired when the right button on this controller is modified
  44587. */
  44588. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44589. /**
  44590. * Fired when the menu button on this controller is modified
  44591. */
  44592. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44593. /**
  44594. * Called once for each button that changed state since the last frame
  44595. * Vive mapping:
  44596. * 0: touchpad
  44597. * 1: trigger
  44598. * 2: left AND right buttons
  44599. * 3: menu button
  44600. * @param buttonIdx Which button index changed
  44601. * @param state New state of the button
  44602. * @param changes Which properties on the state changed since last frame
  44603. */
  44604. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44605. }
  44606. }
  44607. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44608. import { Observable } from "babylonjs/Misc/observable";
  44609. import { Scene } from "babylonjs/scene";
  44610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44611. import { Ray } from "babylonjs/Culling/ray";
  44612. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44613. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44614. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44615. /**
  44616. * Defines the WindowsMotionController object that the state of the windows motion controller
  44617. */
  44618. export class WindowsMotionController extends WebVRController {
  44619. /**
  44620. * The base url used to load the left and right controller models
  44621. */
  44622. static MODEL_BASE_URL: string;
  44623. /**
  44624. * The name of the left controller model file
  44625. */
  44626. static MODEL_LEFT_FILENAME: string;
  44627. /**
  44628. * The name of the right controller model file
  44629. */
  44630. static MODEL_RIGHT_FILENAME: string;
  44631. /**
  44632. * The controller name prefix for this controller type
  44633. */
  44634. static readonly GAMEPAD_ID_PREFIX: string;
  44635. /**
  44636. * The controller id pattern for this controller type
  44637. */
  44638. private static readonly GAMEPAD_ID_PATTERN;
  44639. private _loadedMeshInfo;
  44640. private readonly _mapping;
  44641. /**
  44642. * Fired when the trackpad on this controller is clicked
  44643. */
  44644. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44645. /**
  44646. * Fired when the trackpad on this controller is modified
  44647. */
  44648. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44649. /**
  44650. * The current x and y values of this controller's trackpad
  44651. */
  44652. trackpad: StickValues;
  44653. /**
  44654. * Creates a new WindowsMotionController from a gamepad
  44655. * @param vrGamepad the gamepad that the controller should be created from
  44656. */
  44657. constructor(vrGamepad: any);
  44658. /**
  44659. * Fired when the trigger on this controller is modified
  44660. */
  44661. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44662. /**
  44663. * Fired when the menu button on this controller is modified
  44664. */
  44665. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44666. /**
  44667. * Fired when the grip button on this controller is modified
  44668. */
  44669. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44670. /**
  44671. * Fired when the thumbstick button on this controller is modified
  44672. */
  44673. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44674. /**
  44675. * Fired when the touchpad button on this controller is modified
  44676. */
  44677. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44678. /**
  44679. * Fired when the touchpad values on this controller are modified
  44680. */
  44681. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44682. private _updateTrackpad;
  44683. /**
  44684. * Called once per frame by the engine.
  44685. */
  44686. update(): void;
  44687. /**
  44688. * Called once for each button that changed state since the last frame
  44689. * @param buttonIdx Which button index changed
  44690. * @param state New state of the button
  44691. * @param changes Which properties on the state changed since last frame
  44692. */
  44693. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44694. /**
  44695. * Moves the buttons on the controller mesh based on their current state
  44696. * @param buttonName the name of the button to move
  44697. * @param buttonValue the value of the button which determines the buttons new position
  44698. */
  44699. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44700. /**
  44701. * Moves the axis on the controller mesh based on its current state
  44702. * @param axis the index of the axis
  44703. * @param axisValue the value of the axis which determines the meshes new position
  44704. * @hidden
  44705. */
  44706. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44707. /**
  44708. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44709. * @param scene scene in which to add meshes
  44710. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44711. */
  44712. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44713. /**
  44714. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44715. * can be transformed by button presses and axes values, based on this._mapping.
  44716. *
  44717. * @param scene scene in which the meshes exist
  44718. * @param meshes list of meshes that make up the controller model to process
  44719. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44720. */
  44721. private processModel;
  44722. private createMeshInfo;
  44723. /**
  44724. * Gets the ray of the controller in the direction the controller is pointing
  44725. * @param length the length the resulting ray should be
  44726. * @returns a ray in the direction the controller is pointing
  44727. */
  44728. getForwardRay(length?: number): Ray;
  44729. /**
  44730. * Disposes of the controller
  44731. */
  44732. dispose(): void;
  44733. }
  44734. }
  44735. declare module "babylonjs/Gamepads/Controllers/index" {
  44736. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44737. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44738. export * from "babylonjs/Gamepads/Controllers/genericController";
  44739. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44740. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44741. export * from "babylonjs/Gamepads/Controllers/viveController";
  44742. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44743. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44744. }
  44745. declare module "babylonjs/Gamepads/index" {
  44746. export * from "babylonjs/Gamepads/Controllers/index";
  44747. export * from "babylonjs/Gamepads/gamepad";
  44748. export * from "babylonjs/Gamepads/gamepadManager";
  44749. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44750. export * from "babylonjs/Gamepads/xboxGamepad";
  44751. }
  44752. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44753. import { Scene } from "babylonjs/scene";
  44754. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44755. import { Mesh } from "babylonjs/Meshes/mesh";
  44756. import { Nullable } from "babylonjs/types";
  44757. /**
  44758. * Class containing static functions to help procedurally build meshes
  44759. */
  44760. export class PolyhedronBuilder {
  44761. /**
  44762. * Creates a polyhedron mesh
  44763. * * 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
  44764. * * The parameter `size` (positive float, default 1) sets the polygon size
  44765. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44766. * * 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`
  44767. * * 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
  44768. * * 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)`)
  44769. * * 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
  44770. * * 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
  44771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44774. * @param name defines the name of the mesh
  44775. * @param options defines the options used to create the mesh
  44776. * @param scene defines the hosting scene
  44777. * @returns the polyhedron mesh
  44778. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44779. */
  44780. static CreatePolyhedron(name: string, options: {
  44781. type?: number;
  44782. size?: number;
  44783. sizeX?: number;
  44784. sizeY?: number;
  44785. sizeZ?: number;
  44786. custom?: any;
  44787. faceUV?: Vector4[];
  44788. faceColors?: Color4[];
  44789. flat?: boolean;
  44790. updatable?: boolean;
  44791. sideOrientation?: number;
  44792. frontUVs?: Vector4;
  44793. backUVs?: Vector4;
  44794. }, scene?: Nullable<Scene>): Mesh;
  44795. }
  44796. }
  44797. declare module "babylonjs/Gizmos/scaleGizmo" {
  44798. import { Observable } from "babylonjs/Misc/observable";
  44799. import { Nullable } from "babylonjs/types";
  44800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44801. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44802. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44803. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44804. /**
  44805. * Gizmo that enables scaling a mesh along 3 axis
  44806. */
  44807. export class ScaleGizmo extends Gizmo {
  44808. /**
  44809. * Internal gizmo used for interactions on the x axis
  44810. */
  44811. xGizmo: AxisScaleGizmo;
  44812. /**
  44813. * Internal gizmo used for interactions on the y axis
  44814. */
  44815. yGizmo: AxisScaleGizmo;
  44816. /**
  44817. * Internal gizmo used for interactions on the z axis
  44818. */
  44819. zGizmo: AxisScaleGizmo;
  44820. /**
  44821. * Internal gizmo used to scale all axis equally
  44822. */
  44823. uniformScaleGizmo: AxisScaleGizmo;
  44824. private _meshAttached;
  44825. private _updateGizmoRotationToMatchAttachedMesh;
  44826. private _snapDistance;
  44827. private _scaleRatio;
  44828. private _uniformScalingMesh;
  44829. private _octahedron;
  44830. /** Fires an event when any of it's sub gizmos are dragged */
  44831. onDragStartObservable: Observable<unknown>;
  44832. /** Fires an event when any of it's sub gizmos are released from dragging */
  44833. onDragEndObservable: Observable<unknown>;
  44834. attachedMesh: Nullable<AbstractMesh>;
  44835. /**
  44836. * Creates a ScaleGizmo
  44837. * @param gizmoLayer The utility layer the gizmo will be added to
  44838. */
  44839. constructor(gizmoLayer?: UtilityLayerRenderer);
  44840. updateGizmoRotationToMatchAttachedMesh: boolean;
  44841. /**
  44842. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44843. */
  44844. snapDistance: number;
  44845. /**
  44846. * Ratio for the scale of the gizmo (Default: 1)
  44847. */
  44848. scaleRatio: number;
  44849. /**
  44850. * Disposes of the gizmo
  44851. */
  44852. dispose(): void;
  44853. }
  44854. }
  44855. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44856. import { Observable } from "babylonjs/Misc/observable";
  44857. import { Nullable } from "babylonjs/types";
  44858. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44860. import { Mesh } from "babylonjs/Meshes/mesh";
  44861. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44862. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44863. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44864. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44865. /**
  44866. * Single axis scale gizmo
  44867. */
  44868. export class AxisScaleGizmo extends Gizmo {
  44869. /**
  44870. * Drag behavior responsible for the gizmos dragging interactions
  44871. */
  44872. dragBehavior: PointerDragBehavior;
  44873. private _pointerObserver;
  44874. /**
  44875. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44876. */
  44877. snapDistance: number;
  44878. /**
  44879. * Event that fires each time the gizmo snaps to a new location.
  44880. * * snapDistance is the the change in distance
  44881. */
  44882. onSnapObservable: Observable<{
  44883. snapDistance: number;
  44884. }>;
  44885. /**
  44886. * If the scaling operation should be done on all axis (default: false)
  44887. */
  44888. uniformScaling: boolean;
  44889. private _isEnabled;
  44890. private _parent;
  44891. private _arrow;
  44892. private _coloredMaterial;
  44893. private _hoverMaterial;
  44894. /**
  44895. * Creates an AxisScaleGizmo
  44896. * @param gizmoLayer The utility layer the gizmo will be added to
  44897. * @param dragAxis The axis which the gizmo will be able to scale on
  44898. * @param color The color of the gizmo
  44899. */
  44900. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44901. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44902. /**
  44903. * If the gizmo is enabled
  44904. */
  44905. isEnabled: boolean;
  44906. /**
  44907. * Disposes of the gizmo
  44908. */
  44909. dispose(): void;
  44910. /**
  44911. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44912. * @param mesh The mesh to replace the default mesh of the gizmo
  44913. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44914. */
  44915. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44916. }
  44917. }
  44918. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44919. import { Observable } from "babylonjs/Misc/observable";
  44920. import { Nullable } from "babylonjs/types";
  44921. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44923. import { Mesh } from "babylonjs/Meshes/mesh";
  44924. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44925. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44926. import "babylonjs/Meshes/Builders/boxBuilder";
  44927. /**
  44928. * Bounding box gizmo
  44929. */
  44930. export class BoundingBoxGizmo extends Gizmo {
  44931. private _lineBoundingBox;
  44932. private _rotateSpheresParent;
  44933. private _scaleBoxesParent;
  44934. private _boundingDimensions;
  44935. private _renderObserver;
  44936. private _pointerObserver;
  44937. private _scaleDragSpeed;
  44938. private _tmpQuaternion;
  44939. private _tmpVector;
  44940. private _tmpRotationMatrix;
  44941. /**
  44942. * 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)
  44943. */
  44944. ignoreChildren: boolean;
  44945. /**
  44946. * 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)
  44947. */
  44948. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44949. /**
  44950. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44951. */
  44952. rotationSphereSize: number;
  44953. /**
  44954. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44955. */
  44956. scaleBoxSize: number;
  44957. /**
  44958. * 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)
  44959. */
  44960. fixedDragMeshScreenSize: boolean;
  44961. /**
  44962. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44963. */
  44964. fixedDragMeshScreenSizeDistanceFactor: number;
  44965. /**
  44966. * Fired when a rotation sphere or scale box is dragged
  44967. */
  44968. onDragStartObservable: Observable<{}>;
  44969. /**
  44970. * Fired when a scale box is dragged
  44971. */
  44972. onScaleBoxDragObservable: Observable<{}>;
  44973. /**
  44974. * Fired when a scale box drag is ended
  44975. */
  44976. onScaleBoxDragEndObservable: Observable<{}>;
  44977. /**
  44978. * Fired when a rotation sphere is dragged
  44979. */
  44980. onRotationSphereDragObservable: Observable<{}>;
  44981. /**
  44982. * Fired when a rotation sphere drag is ended
  44983. */
  44984. onRotationSphereDragEndObservable: Observable<{}>;
  44985. /**
  44986. * 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)
  44987. */
  44988. scalePivot: Nullable<Vector3>;
  44989. /**
  44990. * Mesh used as a pivot to rotate the attached mesh
  44991. */
  44992. private _anchorMesh;
  44993. private _existingMeshScale;
  44994. private _dragMesh;
  44995. private pointerDragBehavior;
  44996. private coloredMaterial;
  44997. private hoverColoredMaterial;
  44998. /**
  44999. * Sets the color of the bounding box gizmo
  45000. * @param color the color to set
  45001. */
  45002. setColor(color: Color3): void;
  45003. /**
  45004. * Creates an BoundingBoxGizmo
  45005. * @param gizmoLayer The utility layer the gizmo will be added to
  45006. * @param color The color of the gizmo
  45007. */
  45008. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45009. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45010. private _selectNode;
  45011. /**
  45012. * Updates the bounding box information for the Gizmo
  45013. */
  45014. updateBoundingBox(): void;
  45015. private _updateRotationSpheres;
  45016. private _updateScaleBoxes;
  45017. /**
  45018. * Enables rotation on the specified axis and disables rotation on the others
  45019. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45020. */
  45021. setEnabledRotationAxis(axis: string): void;
  45022. /**
  45023. * Enables/disables scaling
  45024. * @param enable if scaling should be enabled
  45025. */
  45026. setEnabledScaling(enable: boolean): void;
  45027. private _updateDummy;
  45028. /**
  45029. * Enables a pointer drag behavior on the bounding box of the gizmo
  45030. */
  45031. enableDragBehavior(): void;
  45032. /**
  45033. * Disposes of the gizmo
  45034. */
  45035. dispose(): void;
  45036. /**
  45037. * 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)
  45038. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45039. * @returns the bounding box mesh with the passed in mesh as a child
  45040. */
  45041. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45042. /**
  45043. * CustomMeshes are not supported by this gizmo
  45044. * @param mesh The mesh to replace the default mesh of the gizmo
  45045. */
  45046. setCustomMesh(mesh: Mesh): void;
  45047. }
  45048. }
  45049. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45050. import { Observable } from "babylonjs/Misc/observable";
  45051. import { Nullable } from "babylonjs/types";
  45052. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45054. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45055. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45056. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45057. import "babylonjs/Meshes/Builders/linesBuilder";
  45058. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45059. /**
  45060. * Single plane rotation gizmo
  45061. */
  45062. export class PlaneRotationGizmo extends Gizmo {
  45063. /**
  45064. * Drag behavior responsible for the gizmos dragging interactions
  45065. */
  45066. dragBehavior: PointerDragBehavior;
  45067. private _pointerObserver;
  45068. /**
  45069. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45070. */
  45071. snapDistance: number;
  45072. /**
  45073. * Event that fires each time the gizmo snaps to a new location.
  45074. * * snapDistance is the the change in distance
  45075. */
  45076. onSnapObservable: Observable<{
  45077. snapDistance: number;
  45078. }>;
  45079. private _isEnabled;
  45080. private _parent;
  45081. /**
  45082. * Creates a PlaneRotationGizmo
  45083. * @param gizmoLayer The utility layer the gizmo will be added to
  45084. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45085. * @param color The color of the gizmo
  45086. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45087. */
  45088. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45089. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45090. /**
  45091. * If the gizmo is enabled
  45092. */
  45093. isEnabled: boolean;
  45094. /**
  45095. * Disposes of the gizmo
  45096. */
  45097. dispose(): void;
  45098. }
  45099. }
  45100. declare module "babylonjs/Gizmos/rotationGizmo" {
  45101. import { Observable } from "babylonjs/Misc/observable";
  45102. import { Nullable } from "babylonjs/types";
  45103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45104. import { Mesh } from "babylonjs/Meshes/mesh";
  45105. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45106. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45107. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45108. /**
  45109. * Gizmo that enables rotating a mesh along 3 axis
  45110. */
  45111. export class RotationGizmo extends Gizmo {
  45112. /**
  45113. * Internal gizmo used for interactions on the x axis
  45114. */
  45115. xGizmo: PlaneRotationGizmo;
  45116. /**
  45117. * Internal gizmo used for interactions on the y axis
  45118. */
  45119. yGizmo: PlaneRotationGizmo;
  45120. /**
  45121. * Internal gizmo used for interactions on the z axis
  45122. */
  45123. zGizmo: PlaneRotationGizmo;
  45124. /** Fires an event when any of it's sub gizmos are dragged */
  45125. onDragStartObservable: Observable<unknown>;
  45126. /** Fires an event when any of it's sub gizmos are released from dragging */
  45127. onDragEndObservable: Observable<unknown>;
  45128. private _meshAttached;
  45129. attachedMesh: Nullable<AbstractMesh>;
  45130. /**
  45131. * Creates a RotationGizmo
  45132. * @param gizmoLayer The utility layer the gizmo will be added to
  45133. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45134. */
  45135. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45136. updateGizmoRotationToMatchAttachedMesh: boolean;
  45137. /**
  45138. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45139. */
  45140. snapDistance: number;
  45141. /**
  45142. * Ratio for the scale of the gizmo (Default: 1)
  45143. */
  45144. scaleRatio: number;
  45145. /**
  45146. * Disposes of the gizmo
  45147. */
  45148. dispose(): void;
  45149. /**
  45150. * CustomMeshes are not supported by this gizmo
  45151. * @param mesh The mesh to replace the default mesh of the gizmo
  45152. */
  45153. setCustomMesh(mesh: Mesh): void;
  45154. }
  45155. }
  45156. declare module "babylonjs/Gizmos/gizmoManager" {
  45157. import { Observable } from "babylonjs/Misc/observable";
  45158. import { Nullable } from "babylonjs/types";
  45159. import { Scene, IDisposable } from "babylonjs/scene";
  45160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45161. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45162. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45163. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45164. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45165. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45166. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45167. /**
  45168. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45169. */
  45170. export class GizmoManager implements IDisposable {
  45171. private scene;
  45172. /**
  45173. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45174. */
  45175. gizmos: {
  45176. positionGizmo: Nullable<PositionGizmo>;
  45177. rotationGizmo: Nullable<RotationGizmo>;
  45178. scaleGizmo: Nullable<ScaleGizmo>;
  45179. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45180. };
  45181. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45182. clearGizmoOnEmptyPointerEvent: boolean;
  45183. /** Fires an event when the manager is attached to a mesh */
  45184. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45185. private _gizmosEnabled;
  45186. private _pointerObserver;
  45187. private _attachedMesh;
  45188. private _boundingBoxColor;
  45189. private _defaultUtilityLayer;
  45190. private _defaultKeepDepthUtilityLayer;
  45191. /**
  45192. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45193. */
  45194. boundingBoxDragBehavior: SixDofDragBehavior;
  45195. /**
  45196. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45197. */
  45198. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45199. /**
  45200. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45201. */
  45202. usePointerToAttachGizmos: boolean;
  45203. /**
  45204. * Utility layer that the bounding box gizmo belongs to
  45205. */
  45206. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45207. /**
  45208. * Utility layer that all gizmos besides bounding box belong to
  45209. */
  45210. readonly utilityLayer: UtilityLayerRenderer;
  45211. /**
  45212. * Instatiates a gizmo manager
  45213. * @param scene the scene to overlay the gizmos on top of
  45214. */
  45215. constructor(scene: Scene);
  45216. /**
  45217. * Attaches a set of gizmos to the specified mesh
  45218. * @param mesh The mesh the gizmo's should be attached to
  45219. */
  45220. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45221. /**
  45222. * If the position gizmo is enabled
  45223. */
  45224. positionGizmoEnabled: boolean;
  45225. /**
  45226. * If the rotation gizmo is enabled
  45227. */
  45228. rotationGizmoEnabled: boolean;
  45229. /**
  45230. * If the scale gizmo is enabled
  45231. */
  45232. scaleGizmoEnabled: boolean;
  45233. /**
  45234. * If the boundingBox gizmo is enabled
  45235. */
  45236. boundingBoxGizmoEnabled: boolean;
  45237. /**
  45238. * Disposes of the gizmo manager
  45239. */
  45240. dispose(): void;
  45241. }
  45242. }
  45243. declare module "babylonjs/Lights/directionalLight" {
  45244. import { Camera } from "babylonjs/Cameras/camera";
  45245. import { Scene } from "babylonjs/scene";
  45246. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45248. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45249. import { Effect } from "babylonjs/Materials/effect";
  45250. /**
  45251. * A directional light is defined by a direction (what a surprise!).
  45252. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45253. * 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.
  45254. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45255. */
  45256. export class DirectionalLight extends ShadowLight {
  45257. private _shadowFrustumSize;
  45258. /**
  45259. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45260. */
  45261. /**
  45262. * Specifies a fix frustum size for the shadow generation.
  45263. */
  45264. shadowFrustumSize: number;
  45265. private _shadowOrthoScale;
  45266. /**
  45267. * Gets the shadow projection scale against the optimal computed one.
  45268. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45269. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45270. */
  45271. /**
  45272. * Sets the shadow projection scale against the optimal computed one.
  45273. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45274. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45275. */
  45276. shadowOrthoScale: number;
  45277. /**
  45278. * Automatically compute the projection matrix to best fit (including all the casters)
  45279. * on each frame.
  45280. */
  45281. autoUpdateExtends: boolean;
  45282. private _orthoLeft;
  45283. private _orthoRight;
  45284. private _orthoTop;
  45285. private _orthoBottom;
  45286. /**
  45287. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45288. * The directional light is emitted from everywhere in the given direction.
  45289. * It can cast shadows.
  45290. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45291. * @param name The friendly name of the light
  45292. * @param direction The direction of the light
  45293. * @param scene The scene the light belongs to
  45294. */
  45295. constructor(name: string, direction: Vector3, scene: Scene);
  45296. /**
  45297. * Returns the string "DirectionalLight".
  45298. * @return The class name
  45299. */
  45300. getClassName(): string;
  45301. /**
  45302. * Returns the integer 1.
  45303. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45304. */
  45305. getTypeID(): number;
  45306. /**
  45307. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45308. * Returns the DirectionalLight Shadow projection matrix.
  45309. */
  45310. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45311. /**
  45312. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45313. * Returns the DirectionalLight Shadow projection matrix.
  45314. */
  45315. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45316. /**
  45317. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45318. * Returns the DirectionalLight Shadow projection matrix.
  45319. */
  45320. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45321. protected _buildUniformLayout(): void;
  45322. /**
  45323. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45324. * @param effect The effect to update
  45325. * @param lightIndex The index of the light in the effect to update
  45326. * @returns The directional light
  45327. */
  45328. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45329. /**
  45330. * Gets the minZ used for shadow according to both the scene and the light.
  45331. *
  45332. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45333. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45334. * @param activeCamera The camera we are returning the min for
  45335. * @returns the depth min z
  45336. */
  45337. getDepthMinZ(activeCamera: Camera): number;
  45338. /**
  45339. * Gets the maxZ used for shadow according to both the scene and the light.
  45340. *
  45341. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45342. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45343. * @param activeCamera The camera we are returning the max for
  45344. * @returns the depth max z
  45345. */
  45346. getDepthMaxZ(activeCamera: Camera): number;
  45347. /**
  45348. * Prepares the list of defines specific to the light type.
  45349. * @param defines the list of defines
  45350. * @param lightIndex defines the index of the light for the effect
  45351. */
  45352. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45353. }
  45354. }
  45355. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45356. import { Mesh } from "babylonjs/Meshes/mesh";
  45357. /**
  45358. * Class containing static functions to help procedurally build meshes
  45359. */
  45360. export class HemisphereBuilder {
  45361. /**
  45362. * Creates a hemisphere mesh
  45363. * @param name defines the name of the mesh
  45364. * @param options defines the options used to create the mesh
  45365. * @param scene defines the hosting scene
  45366. * @returns the hemisphere mesh
  45367. */
  45368. static CreateHemisphere(name: string, options: {
  45369. segments?: number;
  45370. diameter?: number;
  45371. sideOrientation?: number;
  45372. }, scene: any): Mesh;
  45373. }
  45374. }
  45375. declare module "babylonjs/Lights/spotLight" {
  45376. import { Nullable } from "babylonjs/types";
  45377. import { Scene } from "babylonjs/scene";
  45378. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45380. import { Effect } from "babylonjs/Materials/effect";
  45381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45382. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45383. /**
  45384. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45385. * These values define a cone of light starting from the position, emitting toward the direction.
  45386. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45387. * and the exponent defines the speed of the decay of the light with distance (reach).
  45388. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45389. */
  45390. export class SpotLight extends ShadowLight {
  45391. private _angle;
  45392. private _innerAngle;
  45393. private _cosHalfAngle;
  45394. private _lightAngleScale;
  45395. private _lightAngleOffset;
  45396. /**
  45397. * Gets the cone angle of the spot light in Radians.
  45398. */
  45399. /**
  45400. * Sets the cone angle of the spot light in Radians.
  45401. */
  45402. angle: number;
  45403. /**
  45404. * Only used in gltf falloff mode, this defines the angle where
  45405. * the directional falloff will start before cutting at angle which could be seen
  45406. * as outer angle.
  45407. */
  45408. /**
  45409. * Only used in gltf falloff mode, this defines the angle where
  45410. * the directional falloff will start before cutting at angle which could be seen
  45411. * as outer angle.
  45412. */
  45413. innerAngle: number;
  45414. private _shadowAngleScale;
  45415. /**
  45416. * Allows scaling the angle of the light for shadow generation only.
  45417. */
  45418. /**
  45419. * Allows scaling the angle of the light for shadow generation only.
  45420. */
  45421. shadowAngleScale: number;
  45422. /**
  45423. * The light decay speed with the distance from the emission spot.
  45424. */
  45425. exponent: number;
  45426. private _projectionTextureMatrix;
  45427. /**
  45428. * Allows reading the projecton texture
  45429. */
  45430. readonly projectionTextureMatrix: Matrix;
  45431. protected _projectionTextureLightNear: number;
  45432. /**
  45433. * Gets the near clip of the Spotlight for texture projection.
  45434. */
  45435. /**
  45436. * Sets the near clip of the Spotlight for texture projection.
  45437. */
  45438. projectionTextureLightNear: number;
  45439. protected _projectionTextureLightFar: number;
  45440. /**
  45441. * Gets the far clip of the Spotlight for texture projection.
  45442. */
  45443. /**
  45444. * Sets the far clip of the Spotlight for texture projection.
  45445. */
  45446. projectionTextureLightFar: number;
  45447. protected _projectionTextureUpDirection: Vector3;
  45448. /**
  45449. * Gets the Up vector of the Spotlight for texture projection.
  45450. */
  45451. /**
  45452. * Sets the Up vector of the Spotlight for texture projection.
  45453. */
  45454. projectionTextureUpDirection: Vector3;
  45455. private _projectionTexture;
  45456. /**
  45457. * Gets the projection texture of the light.
  45458. */
  45459. /**
  45460. * Sets the projection texture of the light.
  45461. */
  45462. projectionTexture: Nullable<BaseTexture>;
  45463. private _projectionTextureViewLightDirty;
  45464. private _projectionTextureProjectionLightDirty;
  45465. private _projectionTextureDirty;
  45466. private _projectionTextureViewTargetVector;
  45467. private _projectionTextureViewLightMatrix;
  45468. private _projectionTextureProjectionLightMatrix;
  45469. private _projectionTextureScalingMatrix;
  45470. /**
  45471. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45472. * It can cast shadows.
  45473. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45474. * @param name The light friendly name
  45475. * @param position The position of the spot light in the scene
  45476. * @param direction The direction of the light in the scene
  45477. * @param angle The cone angle of the light in Radians
  45478. * @param exponent The light decay speed with the distance from the emission spot
  45479. * @param scene The scene the lights belongs to
  45480. */
  45481. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45482. /**
  45483. * Returns the string "SpotLight".
  45484. * @returns the class name
  45485. */
  45486. getClassName(): string;
  45487. /**
  45488. * Returns the integer 2.
  45489. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45490. */
  45491. getTypeID(): number;
  45492. /**
  45493. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45494. */
  45495. protected _setDirection(value: Vector3): void;
  45496. /**
  45497. * Overrides the position setter to recompute the projection texture view light Matrix.
  45498. */
  45499. protected _setPosition(value: Vector3): void;
  45500. /**
  45501. * 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.
  45502. * Returns the SpotLight.
  45503. */
  45504. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45505. protected _computeProjectionTextureViewLightMatrix(): void;
  45506. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45507. /**
  45508. * Main function for light texture projection matrix computing.
  45509. */
  45510. protected _computeProjectionTextureMatrix(): void;
  45511. protected _buildUniformLayout(): void;
  45512. private _computeAngleValues;
  45513. /**
  45514. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45515. * @param effect The effect to update
  45516. * @param lightIndex The index of the light in the effect to update
  45517. * @returns The spot light
  45518. */
  45519. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45520. /**
  45521. * Disposes the light and the associated resources.
  45522. */
  45523. dispose(): void;
  45524. /**
  45525. * Prepares the list of defines specific to the light type.
  45526. * @param defines the list of defines
  45527. * @param lightIndex defines the index of the light for the effect
  45528. */
  45529. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45530. }
  45531. }
  45532. declare module "babylonjs/Gizmos/lightGizmo" {
  45533. import { Nullable } from "babylonjs/types";
  45534. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45535. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45536. import { Light } from "babylonjs/Lights/light";
  45537. /**
  45538. * Gizmo that enables viewing a light
  45539. */
  45540. export class LightGizmo extends Gizmo {
  45541. private _lightMesh;
  45542. private _material;
  45543. private cachedPosition;
  45544. private cachedForward;
  45545. /**
  45546. * Creates a LightGizmo
  45547. * @param gizmoLayer The utility layer the gizmo will be added to
  45548. */
  45549. constructor(gizmoLayer?: UtilityLayerRenderer);
  45550. private _light;
  45551. /**
  45552. * The light that the gizmo is attached to
  45553. */
  45554. light: Nullable<Light>;
  45555. /**
  45556. * @hidden
  45557. * Updates the gizmo to match the attached mesh's position/rotation
  45558. */
  45559. protected _update(): void;
  45560. private static _Scale;
  45561. /**
  45562. * Creates the lines for a light mesh
  45563. */
  45564. private static _createLightLines;
  45565. /**
  45566. * Disposes of the light gizmo
  45567. */
  45568. dispose(): void;
  45569. private static _CreateHemisphericLightMesh;
  45570. private static _CreatePointLightMesh;
  45571. private static _CreateSpotLightMesh;
  45572. private static _CreateDirectionalLightMesh;
  45573. }
  45574. }
  45575. declare module "babylonjs/Gizmos/index" {
  45576. export * from "babylonjs/Gizmos/axisDragGizmo";
  45577. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45578. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45579. export * from "babylonjs/Gizmos/gizmo";
  45580. export * from "babylonjs/Gizmos/gizmoManager";
  45581. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45582. export * from "babylonjs/Gizmos/positionGizmo";
  45583. export * from "babylonjs/Gizmos/rotationGizmo";
  45584. export * from "babylonjs/Gizmos/scaleGizmo";
  45585. export * from "babylonjs/Gizmos/lightGizmo";
  45586. }
  45587. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45588. /** @hidden */
  45589. export var backgroundFragmentDeclaration: {
  45590. name: string;
  45591. shader: string;
  45592. };
  45593. }
  45594. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45595. /** @hidden */
  45596. export var backgroundUboDeclaration: {
  45597. name: string;
  45598. shader: string;
  45599. };
  45600. }
  45601. declare module "babylonjs/Shaders/background.fragment" {
  45602. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45603. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45604. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45605. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45606. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45607. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45608. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45609. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45610. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45611. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45612. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45613. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45615. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45616. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45617. /** @hidden */
  45618. export var backgroundPixelShader: {
  45619. name: string;
  45620. shader: string;
  45621. };
  45622. }
  45623. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45624. /** @hidden */
  45625. export var backgroundVertexDeclaration: {
  45626. name: string;
  45627. shader: string;
  45628. };
  45629. }
  45630. declare module "babylonjs/Shaders/background.vertex" {
  45631. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45632. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45633. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45634. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45635. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45636. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45637. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45638. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45639. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45640. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45641. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45642. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45643. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45644. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45645. /** @hidden */
  45646. export var backgroundVertexShader: {
  45647. name: string;
  45648. shader: string;
  45649. };
  45650. }
  45651. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45652. import { Nullable, int, float } from "babylonjs/types";
  45653. import { Scene } from "babylonjs/scene";
  45654. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45655. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45657. import { Mesh } from "babylonjs/Meshes/mesh";
  45658. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45659. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45660. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45662. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45663. import "babylonjs/Shaders/background.fragment";
  45664. import "babylonjs/Shaders/background.vertex";
  45665. /**
  45666. * Background material used to create an efficient environement around your scene.
  45667. */
  45668. export class BackgroundMaterial extends PushMaterial {
  45669. /**
  45670. * Standard reflectance value at parallel view angle.
  45671. */
  45672. static StandardReflectance0: number;
  45673. /**
  45674. * Standard reflectance value at grazing angle.
  45675. */
  45676. static StandardReflectance90: number;
  45677. protected _primaryColor: Color3;
  45678. /**
  45679. * Key light Color (multiply against the environement texture)
  45680. */
  45681. primaryColor: Color3;
  45682. protected __perceptualColor: Nullable<Color3>;
  45683. /**
  45684. * Experimental Internal Use Only.
  45685. *
  45686. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45687. * This acts as a helper to set the primary color to a more "human friendly" value.
  45688. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45689. * output color as close as possible from the chosen value.
  45690. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45691. * part of lighting setup.)
  45692. */
  45693. _perceptualColor: Nullable<Color3>;
  45694. protected _primaryColorShadowLevel: float;
  45695. /**
  45696. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45697. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45698. */
  45699. primaryColorShadowLevel: float;
  45700. protected _primaryColorHighlightLevel: float;
  45701. /**
  45702. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45703. * The primary color is used at the level chosen to define what the white area would look.
  45704. */
  45705. primaryColorHighlightLevel: float;
  45706. protected _reflectionTexture: Nullable<BaseTexture>;
  45707. /**
  45708. * Reflection Texture used in the material.
  45709. * Should be author in a specific way for the best result (refer to the documentation).
  45710. */
  45711. reflectionTexture: Nullable<BaseTexture>;
  45712. protected _reflectionBlur: float;
  45713. /**
  45714. * Reflection Texture level of blur.
  45715. *
  45716. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45717. * texture twice.
  45718. */
  45719. reflectionBlur: float;
  45720. protected _diffuseTexture: Nullable<BaseTexture>;
  45721. /**
  45722. * Diffuse Texture used in the material.
  45723. * Should be author in a specific way for the best result (refer to the documentation).
  45724. */
  45725. diffuseTexture: Nullable<BaseTexture>;
  45726. protected _shadowLights: Nullable<IShadowLight[]>;
  45727. /**
  45728. * Specify the list of lights casting shadow on the material.
  45729. * All scene shadow lights will be included if null.
  45730. */
  45731. shadowLights: Nullable<IShadowLight[]>;
  45732. protected _shadowLevel: float;
  45733. /**
  45734. * Helps adjusting the shadow to a softer level if required.
  45735. * 0 means black shadows and 1 means no shadows.
  45736. */
  45737. shadowLevel: float;
  45738. protected _sceneCenter: Vector3;
  45739. /**
  45740. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45741. * It is usually zero but might be interesting to modify according to your setup.
  45742. */
  45743. sceneCenter: Vector3;
  45744. protected _opacityFresnel: boolean;
  45745. /**
  45746. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45747. * This helps ensuring a nice transition when the camera goes under the ground.
  45748. */
  45749. opacityFresnel: boolean;
  45750. protected _reflectionFresnel: boolean;
  45751. /**
  45752. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45753. * This helps adding a mirror texture on the ground.
  45754. */
  45755. reflectionFresnel: boolean;
  45756. protected _reflectionFalloffDistance: number;
  45757. /**
  45758. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45759. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45760. */
  45761. reflectionFalloffDistance: number;
  45762. protected _reflectionAmount: number;
  45763. /**
  45764. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45765. */
  45766. reflectionAmount: number;
  45767. protected _reflectionReflectance0: number;
  45768. /**
  45769. * This specifies the weight of the reflection at grazing angle.
  45770. */
  45771. reflectionReflectance0: number;
  45772. protected _reflectionReflectance90: number;
  45773. /**
  45774. * This specifies the weight of the reflection at a perpendicular point of view.
  45775. */
  45776. reflectionReflectance90: number;
  45777. /**
  45778. * Sets the reflection reflectance fresnel values according to the default standard
  45779. * empirically know to work well :-)
  45780. */
  45781. reflectionStandardFresnelWeight: number;
  45782. protected _useRGBColor: boolean;
  45783. /**
  45784. * Helps to directly use the maps channels instead of their level.
  45785. */
  45786. useRGBColor: boolean;
  45787. protected _enableNoise: boolean;
  45788. /**
  45789. * This helps reducing the banding effect that could occur on the background.
  45790. */
  45791. enableNoise: boolean;
  45792. /**
  45793. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45794. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45795. * Recommended to be keep at 1.0 except for special cases.
  45796. */
  45797. fovMultiplier: number;
  45798. private _fovMultiplier;
  45799. /**
  45800. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45801. */
  45802. useEquirectangularFOV: boolean;
  45803. private _maxSimultaneousLights;
  45804. /**
  45805. * Number of Simultaneous lights allowed on the material.
  45806. */
  45807. maxSimultaneousLights: int;
  45808. /**
  45809. * Default configuration related to image processing available in the Background Material.
  45810. */
  45811. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45812. /**
  45813. * Keep track of the image processing observer to allow dispose and replace.
  45814. */
  45815. private _imageProcessingObserver;
  45816. /**
  45817. * Attaches a new image processing configuration to the PBR Material.
  45818. * @param configuration (if null the scene configuration will be use)
  45819. */
  45820. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45821. /**
  45822. * Gets the image processing configuration used either in this material.
  45823. */
  45824. /**
  45825. * Sets the Default image processing configuration used either in the this material.
  45826. *
  45827. * If sets to null, the scene one is in use.
  45828. */
  45829. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45830. /**
  45831. * Gets wether the color curves effect is enabled.
  45832. */
  45833. /**
  45834. * Sets wether the color curves effect is enabled.
  45835. */
  45836. cameraColorCurvesEnabled: boolean;
  45837. /**
  45838. * Gets wether the color grading effect is enabled.
  45839. */
  45840. /**
  45841. * Gets wether the color grading effect is enabled.
  45842. */
  45843. cameraColorGradingEnabled: boolean;
  45844. /**
  45845. * Gets wether tonemapping is enabled or not.
  45846. */
  45847. /**
  45848. * Sets wether tonemapping is enabled or not
  45849. */
  45850. cameraToneMappingEnabled: boolean;
  45851. /**
  45852. * The camera exposure used on this material.
  45853. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45854. * This corresponds to a photographic exposure.
  45855. */
  45856. /**
  45857. * The camera exposure used on this material.
  45858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45859. * This corresponds to a photographic exposure.
  45860. */
  45861. cameraExposure: float;
  45862. /**
  45863. * Gets The camera contrast used on this material.
  45864. */
  45865. /**
  45866. * Sets The camera contrast used on this material.
  45867. */
  45868. cameraContrast: float;
  45869. /**
  45870. * Gets the Color Grading 2D Lookup Texture.
  45871. */
  45872. /**
  45873. * Sets the Color Grading 2D Lookup Texture.
  45874. */
  45875. cameraColorGradingTexture: Nullable<BaseTexture>;
  45876. /**
  45877. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45878. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45879. * 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;
  45880. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45881. */
  45882. /**
  45883. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45884. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45885. * 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;
  45886. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45887. */
  45888. cameraColorCurves: Nullable<ColorCurves>;
  45889. /**
  45890. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45891. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45892. */
  45893. switchToBGR: boolean;
  45894. private _renderTargets;
  45895. private _reflectionControls;
  45896. private _white;
  45897. private _primaryShadowColor;
  45898. private _primaryHighlightColor;
  45899. /**
  45900. * Instantiates a Background Material in the given scene
  45901. * @param name The friendly name of the material
  45902. * @param scene The scene to add the material to
  45903. */
  45904. constructor(name: string, scene: Scene);
  45905. /**
  45906. * Gets a boolean indicating that current material needs to register RTT
  45907. */
  45908. readonly hasRenderTargetTextures: boolean;
  45909. /**
  45910. * The entire material has been created in order to prevent overdraw.
  45911. * @returns false
  45912. */
  45913. needAlphaTesting(): boolean;
  45914. /**
  45915. * The entire material has been created in order to prevent overdraw.
  45916. * @returns true if blending is enable
  45917. */
  45918. needAlphaBlending(): boolean;
  45919. /**
  45920. * Checks wether the material is ready to be rendered for a given mesh.
  45921. * @param mesh The mesh to render
  45922. * @param subMesh The submesh to check against
  45923. * @param useInstances Specify wether or not the material is used with instances
  45924. * @returns true if all the dependencies are ready (Textures, Effects...)
  45925. */
  45926. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45927. /**
  45928. * Compute the primary color according to the chosen perceptual color.
  45929. */
  45930. private _computePrimaryColorFromPerceptualColor;
  45931. /**
  45932. * Compute the highlights and shadow colors according to their chosen levels.
  45933. */
  45934. private _computePrimaryColors;
  45935. /**
  45936. * Build the uniform buffer used in the material.
  45937. */
  45938. buildUniformLayout(): void;
  45939. /**
  45940. * Unbind the material.
  45941. */
  45942. unbind(): void;
  45943. /**
  45944. * Bind only the world matrix to the material.
  45945. * @param world The world matrix to bind.
  45946. */
  45947. bindOnlyWorldMatrix(world: Matrix): void;
  45948. /**
  45949. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45950. * @param world The world matrix to bind.
  45951. * @param subMesh The submesh to bind for.
  45952. */
  45953. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45954. /**
  45955. * Dispose the material.
  45956. * @param forceDisposeEffect Force disposal of the associated effect.
  45957. * @param forceDisposeTextures Force disposal of the associated textures.
  45958. */
  45959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45960. /**
  45961. * Clones the material.
  45962. * @param name The cloned name.
  45963. * @returns The cloned material.
  45964. */
  45965. clone(name: string): BackgroundMaterial;
  45966. /**
  45967. * Serializes the current material to its JSON representation.
  45968. * @returns The JSON representation.
  45969. */
  45970. serialize(): any;
  45971. /**
  45972. * Gets the class name of the material
  45973. * @returns "BackgroundMaterial"
  45974. */
  45975. getClassName(): string;
  45976. /**
  45977. * Parse a JSON input to create back a background material.
  45978. * @param source The JSON data to parse
  45979. * @param scene The scene to create the parsed material in
  45980. * @param rootUrl The root url of the assets the material depends upon
  45981. * @returns the instantiated BackgroundMaterial.
  45982. */
  45983. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45984. }
  45985. }
  45986. declare module "babylonjs/Helpers/environmentHelper" {
  45987. import { Observable } from "babylonjs/Misc/observable";
  45988. import { Nullable } from "babylonjs/types";
  45989. import { Scene } from "babylonjs/scene";
  45990. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45992. import { Mesh } from "babylonjs/Meshes/mesh";
  45993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45994. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45995. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45996. import "babylonjs/Meshes/Builders/planeBuilder";
  45997. import "babylonjs/Meshes/Builders/boxBuilder";
  45998. /**
  45999. * Represents the different options available during the creation of
  46000. * a Environment helper.
  46001. *
  46002. * This can control the default ground, skybox and image processing setup of your scene.
  46003. */
  46004. export interface IEnvironmentHelperOptions {
  46005. /**
  46006. * Specifies wether or not to create a ground.
  46007. * True by default.
  46008. */
  46009. createGround: boolean;
  46010. /**
  46011. * Specifies the ground size.
  46012. * 15 by default.
  46013. */
  46014. groundSize: number;
  46015. /**
  46016. * The texture used on the ground for the main color.
  46017. * Comes from the BabylonJS CDN by default.
  46018. *
  46019. * Remarks: Can be either a texture or a url.
  46020. */
  46021. groundTexture: string | BaseTexture;
  46022. /**
  46023. * The color mixed in the ground texture by default.
  46024. * BabylonJS clearColor by default.
  46025. */
  46026. groundColor: Color3;
  46027. /**
  46028. * Specifies the ground opacity.
  46029. * 1 by default.
  46030. */
  46031. groundOpacity: number;
  46032. /**
  46033. * Enables the ground to receive shadows.
  46034. * True by default.
  46035. */
  46036. enableGroundShadow: boolean;
  46037. /**
  46038. * Helps preventing the shadow to be fully black on the ground.
  46039. * 0.5 by default.
  46040. */
  46041. groundShadowLevel: number;
  46042. /**
  46043. * Creates a mirror texture attach to the ground.
  46044. * false by default.
  46045. */
  46046. enableGroundMirror: boolean;
  46047. /**
  46048. * Specifies the ground mirror size ratio.
  46049. * 0.3 by default as the default kernel is 64.
  46050. */
  46051. groundMirrorSizeRatio: number;
  46052. /**
  46053. * Specifies the ground mirror blur kernel size.
  46054. * 64 by default.
  46055. */
  46056. groundMirrorBlurKernel: number;
  46057. /**
  46058. * Specifies the ground mirror visibility amount.
  46059. * 1 by default
  46060. */
  46061. groundMirrorAmount: number;
  46062. /**
  46063. * Specifies the ground mirror reflectance weight.
  46064. * This uses the standard weight of the background material to setup the fresnel effect
  46065. * of the mirror.
  46066. * 1 by default.
  46067. */
  46068. groundMirrorFresnelWeight: number;
  46069. /**
  46070. * Specifies the ground mirror Falloff distance.
  46071. * This can helps reducing the size of the reflection.
  46072. * 0 by Default.
  46073. */
  46074. groundMirrorFallOffDistance: number;
  46075. /**
  46076. * Specifies the ground mirror texture type.
  46077. * Unsigned Int by Default.
  46078. */
  46079. groundMirrorTextureType: number;
  46080. /**
  46081. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46082. * the shown objects.
  46083. */
  46084. groundYBias: number;
  46085. /**
  46086. * Specifies wether or not to create a skybox.
  46087. * True by default.
  46088. */
  46089. createSkybox: boolean;
  46090. /**
  46091. * Specifies the skybox size.
  46092. * 20 by default.
  46093. */
  46094. skyboxSize: number;
  46095. /**
  46096. * The texture used on the skybox for the main color.
  46097. * Comes from the BabylonJS CDN by default.
  46098. *
  46099. * Remarks: Can be either a texture or a url.
  46100. */
  46101. skyboxTexture: string | BaseTexture;
  46102. /**
  46103. * The color mixed in the skybox texture by default.
  46104. * BabylonJS clearColor by default.
  46105. */
  46106. skyboxColor: Color3;
  46107. /**
  46108. * The background rotation around the Y axis of the scene.
  46109. * This helps aligning the key lights of your scene with the background.
  46110. * 0 by default.
  46111. */
  46112. backgroundYRotation: number;
  46113. /**
  46114. * Compute automatically the size of the elements to best fit with the scene.
  46115. */
  46116. sizeAuto: boolean;
  46117. /**
  46118. * Default position of the rootMesh if autoSize is not true.
  46119. */
  46120. rootPosition: Vector3;
  46121. /**
  46122. * Sets up the image processing in the scene.
  46123. * true by default.
  46124. */
  46125. setupImageProcessing: boolean;
  46126. /**
  46127. * The texture used as your environment texture in the scene.
  46128. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46129. *
  46130. * Remarks: Can be either a texture or a url.
  46131. */
  46132. environmentTexture: string | BaseTexture;
  46133. /**
  46134. * The value of the exposure to apply to the scene.
  46135. * 0.6 by default if setupImageProcessing is true.
  46136. */
  46137. cameraExposure: number;
  46138. /**
  46139. * The value of the contrast to apply to the scene.
  46140. * 1.6 by default if setupImageProcessing is true.
  46141. */
  46142. cameraContrast: number;
  46143. /**
  46144. * Specifies wether or not tonemapping should be enabled in the scene.
  46145. * true by default if setupImageProcessing is true.
  46146. */
  46147. toneMappingEnabled: boolean;
  46148. }
  46149. /**
  46150. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46151. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46152. * It also helps with the default setup of your imageProcessing configuration.
  46153. */
  46154. export class EnvironmentHelper {
  46155. /**
  46156. * Default ground texture URL.
  46157. */
  46158. private static _groundTextureCDNUrl;
  46159. /**
  46160. * Default skybox texture URL.
  46161. */
  46162. private static _skyboxTextureCDNUrl;
  46163. /**
  46164. * Default environment texture URL.
  46165. */
  46166. private static _environmentTextureCDNUrl;
  46167. /**
  46168. * Creates the default options for the helper.
  46169. */
  46170. private static _getDefaultOptions;
  46171. private _rootMesh;
  46172. /**
  46173. * Gets the root mesh created by the helper.
  46174. */
  46175. readonly rootMesh: Mesh;
  46176. private _skybox;
  46177. /**
  46178. * Gets the skybox created by the helper.
  46179. */
  46180. readonly skybox: Nullable<Mesh>;
  46181. private _skyboxTexture;
  46182. /**
  46183. * Gets the skybox texture created by the helper.
  46184. */
  46185. readonly skyboxTexture: Nullable<BaseTexture>;
  46186. private _skyboxMaterial;
  46187. /**
  46188. * Gets the skybox material created by the helper.
  46189. */
  46190. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46191. private _ground;
  46192. /**
  46193. * Gets the ground mesh created by the helper.
  46194. */
  46195. readonly ground: Nullable<Mesh>;
  46196. private _groundTexture;
  46197. /**
  46198. * Gets the ground texture created by the helper.
  46199. */
  46200. readonly groundTexture: Nullable<BaseTexture>;
  46201. private _groundMirror;
  46202. /**
  46203. * Gets the ground mirror created by the helper.
  46204. */
  46205. readonly groundMirror: Nullable<MirrorTexture>;
  46206. /**
  46207. * Gets the ground mirror render list to helps pushing the meshes
  46208. * you wish in the ground reflection.
  46209. */
  46210. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46211. private _groundMaterial;
  46212. /**
  46213. * Gets the ground material created by the helper.
  46214. */
  46215. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46216. /**
  46217. * Stores the creation options.
  46218. */
  46219. private readonly _scene;
  46220. private _options;
  46221. /**
  46222. * This observable will be notified with any error during the creation of the environment,
  46223. * mainly texture creation errors.
  46224. */
  46225. onErrorObservable: Observable<{
  46226. message?: string;
  46227. exception?: any;
  46228. }>;
  46229. /**
  46230. * constructor
  46231. * @param options Defines the options we want to customize the helper
  46232. * @param scene The scene to add the material to
  46233. */
  46234. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46235. /**
  46236. * Updates the background according to the new options
  46237. * @param options
  46238. */
  46239. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46240. /**
  46241. * Sets the primary color of all the available elements.
  46242. * @param color the main color to affect to the ground and the background
  46243. */
  46244. setMainColor(color: Color3): void;
  46245. /**
  46246. * Setup the image processing according to the specified options.
  46247. */
  46248. private _setupImageProcessing;
  46249. /**
  46250. * Setup the environment texture according to the specified options.
  46251. */
  46252. private _setupEnvironmentTexture;
  46253. /**
  46254. * Setup the background according to the specified options.
  46255. */
  46256. private _setupBackground;
  46257. /**
  46258. * Get the scene sizes according to the setup.
  46259. */
  46260. private _getSceneSize;
  46261. /**
  46262. * Setup the ground according to the specified options.
  46263. */
  46264. private _setupGround;
  46265. /**
  46266. * Setup the ground material according to the specified options.
  46267. */
  46268. private _setupGroundMaterial;
  46269. /**
  46270. * Setup the ground diffuse texture according to the specified options.
  46271. */
  46272. private _setupGroundDiffuseTexture;
  46273. /**
  46274. * Setup the ground mirror texture according to the specified options.
  46275. */
  46276. private _setupGroundMirrorTexture;
  46277. /**
  46278. * Setup the ground to receive the mirror texture.
  46279. */
  46280. private _setupMirrorInGroundMaterial;
  46281. /**
  46282. * Setup the skybox according to the specified options.
  46283. */
  46284. private _setupSkybox;
  46285. /**
  46286. * Setup the skybox material according to the specified options.
  46287. */
  46288. private _setupSkyboxMaterial;
  46289. /**
  46290. * Setup the skybox reflection texture according to the specified options.
  46291. */
  46292. private _setupSkyboxReflectionTexture;
  46293. private _errorHandler;
  46294. /**
  46295. * Dispose all the elements created by the Helper.
  46296. */
  46297. dispose(): void;
  46298. }
  46299. }
  46300. declare module "babylonjs/Helpers/photoDome" {
  46301. import { Observable } from "babylonjs/Misc/observable";
  46302. import { Nullable } from "babylonjs/types";
  46303. import { Scene } from "babylonjs/scene";
  46304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46305. import { Mesh } from "babylonjs/Meshes/mesh";
  46306. import { Texture } from "babylonjs/Materials/Textures/texture";
  46307. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46308. import "babylonjs/Meshes/Builders/sphereBuilder";
  46309. /**
  46310. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46311. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46312. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46313. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46314. */
  46315. export class PhotoDome extends TransformNode {
  46316. /**
  46317. * Define the image as a Monoscopic panoramic 360 image.
  46318. */
  46319. static readonly MODE_MONOSCOPIC: number;
  46320. /**
  46321. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46322. */
  46323. static readonly MODE_TOPBOTTOM: number;
  46324. /**
  46325. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46326. */
  46327. static readonly MODE_SIDEBYSIDE: number;
  46328. private _useDirectMapping;
  46329. /**
  46330. * The texture being displayed on the sphere
  46331. */
  46332. protected _photoTexture: Texture;
  46333. /**
  46334. * Gets or sets the texture being displayed on the sphere
  46335. */
  46336. photoTexture: Texture;
  46337. /**
  46338. * Observable raised when an error occured while loading the 360 image
  46339. */
  46340. onLoadErrorObservable: Observable<string>;
  46341. /**
  46342. * The skybox material
  46343. */
  46344. protected _material: BackgroundMaterial;
  46345. /**
  46346. * The surface used for the skybox
  46347. */
  46348. protected _mesh: Mesh;
  46349. /**
  46350. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46351. * Also see the options.resolution property.
  46352. */
  46353. fovMultiplier: number;
  46354. private _imageMode;
  46355. /**
  46356. * Gets or set the current video mode for the video. It can be:
  46357. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46358. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46359. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46360. */
  46361. imageMode: number;
  46362. /**
  46363. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46364. * @param name Element's name, child elements will append suffixes for their own names.
  46365. * @param urlsOfPhoto defines the url of the photo to display
  46366. * @param options defines an object containing optional or exposed sub element properties
  46367. * @param onError defines a callback called when an error occured while loading the texture
  46368. */
  46369. constructor(name: string, urlOfPhoto: string, options: {
  46370. resolution?: number;
  46371. size?: number;
  46372. useDirectMapping?: boolean;
  46373. faceForward?: boolean;
  46374. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46375. private _onBeforeCameraRenderObserver;
  46376. private _changeImageMode;
  46377. /**
  46378. * Releases resources associated with this node.
  46379. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46380. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46381. */
  46382. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46383. }
  46384. }
  46385. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46386. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46387. /** @hidden */
  46388. export var rgbdDecodePixelShader: {
  46389. name: string;
  46390. shader: string;
  46391. };
  46392. }
  46393. declare module "babylonjs/Misc/brdfTextureTools" {
  46394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46395. import { Scene } from "babylonjs/scene";
  46396. import "babylonjs/Shaders/rgbdDecode.fragment";
  46397. /**
  46398. * Class used to host texture specific utilities
  46399. */
  46400. export class BRDFTextureTools {
  46401. /**
  46402. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46403. * @param texture the texture to expand.
  46404. */
  46405. private static _ExpandDefaultBRDFTexture;
  46406. /**
  46407. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46408. * @param scene defines the hosting scene
  46409. * @returns the environment BRDF texture
  46410. */
  46411. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46412. private static _environmentBRDFBase64Texture;
  46413. }
  46414. }
  46415. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46416. import { Nullable } from "babylonjs/types";
  46417. import { IAnimatable } from "babylonjs/Misc/tools";
  46418. import { Color3 } from "babylonjs/Maths/math";
  46419. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46420. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46421. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46422. import { Engine } from "babylonjs/Engines/engine";
  46423. import { Scene } from "babylonjs/scene";
  46424. /**
  46425. * @hidden
  46426. */
  46427. export interface IMaterialClearCoatDefines {
  46428. CLEARCOAT: boolean;
  46429. CLEARCOAT_DEFAULTIOR: boolean;
  46430. CLEARCOAT_TEXTURE: boolean;
  46431. CLEARCOAT_TEXTUREDIRECTUV: number;
  46432. CLEARCOAT_BUMP: boolean;
  46433. CLEARCOAT_BUMPDIRECTUV: number;
  46434. CLEARCOAT_TINT: boolean;
  46435. CLEARCOAT_TINT_TEXTURE: boolean;
  46436. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46437. /** @hidden */
  46438. _areTexturesDirty: boolean;
  46439. }
  46440. /**
  46441. * Define the code related to the clear coat parameters of the pbr material.
  46442. */
  46443. export class PBRClearCoatConfiguration {
  46444. /**
  46445. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46446. * The default fits with a polyurethane material.
  46447. */
  46448. private static readonly _DefaultIndexOfRefraction;
  46449. private _isEnabled;
  46450. /**
  46451. * Defines if the clear coat is enabled in the material.
  46452. */
  46453. isEnabled: boolean;
  46454. /**
  46455. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46456. */
  46457. intensity: number;
  46458. /**
  46459. * Defines the clear coat layer roughness.
  46460. */
  46461. roughness: number;
  46462. private _indexOfRefraction;
  46463. /**
  46464. * Defines the index of refraction of the clear coat.
  46465. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46466. * The default fits with a polyurethane material.
  46467. * Changing the default value is more performance intensive.
  46468. */
  46469. indexOfRefraction: number;
  46470. private _texture;
  46471. /**
  46472. * Stores the clear coat values in a texture.
  46473. */
  46474. texture: Nullable<BaseTexture>;
  46475. private _bumpTexture;
  46476. /**
  46477. * Define the clear coat specific bump texture.
  46478. */
  46479. bumpTexture: Nullable<BaseTexture>;
  46480. private _isTintEnabled;
  46481. /**
  46482. * Defines if the clear coat tint is enabled in the material.
  46483. */
  46484. isTintEnabled: boolean;
  46485. /**
  46486. * Defines the clear coat tint of the material.
  46487. * This is only use if tint is enabled
  46488. */
  46489. tintColor: Color3;
  46490. /**
  46491. * Defines the distance at which the tint color should be found in the
  46492. * clear coat media.
  46493. * This is only use if tint is enabled
  46494. */
  46495. tintColorAtDistance: number;
  46496. /**
  46497. * Defines the clear coat layer thickness.
  46498. * This is only use if tint is enabled
  46499. */
  46500. tintThickness: number;
  46501. private _tintTexture;
  46502. /**
  46503. * Stores the clear tint values in a texture.
  46504. * rgb is tint
  46505. * a is a thickness factor
  46506. */
  46507. tintTexture: Nullable<BaseTexture>;
  46508. /** @hidden */
  46509. private _internalMarkAllSubMeshesAsTexturesDirty;
  46510. /** @hidden */
  46511. _markAllSubMeshesAsTexturesDirty(): void;
  46512. /**
  46513. * Instantiate a new istance of clear coat configuration.
  46514. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46515. */
  46516. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46517. /**
  46518. * Gets wehter the submesh is ready to be used or not.
  46519. * @param defines the list of "defines" to update.
  46520. * @param scene defines the scene the material belongs to.
  46521. * @param engine defines the engine the material belongs to.
  46522. * @param disableBumpMap defines wether the material disables bump or not.
  46523. * @returns - boolean indicating that the submesh is ready or not.
  46524. */
  46525. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46526. /**
  46527. * Checks to see if a texture is used in the material.
  46528. * @param defines the list of "defines" to update.
  46529. * @param scene defines the scene to the material belongs to.
  46530. */
  46531. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46532. /**
  46533. * Binds the material data.
  46534. * @param uniformBuffer defines the Uniform buffer to fill in.
  46535. * @param scene defines the scene the material belongs to.
  46536. * @param engine defines the engine the material belongs to.
  46537. * @param disableBumpMap defines wether the material disables bump or not.
  46538. * @param isFrozen defines wether the material is frozen or not.
  46539. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46540. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46541. */
  46542. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46543. /**
  46544. * Checks to see if a texture is used in the material.
  46545. * @param texture - Base texture to use.
  46546. * @returns - Boolean specifying if a texture is used in the material.
  46547. */
  46548. hasTexture(texture: BaseTexture): boolean;
  46549. /**
  46550. * Returns an array of the actively used textures.
  46551. * @param activeTextures Array of BaseTextures
  46552. */
  46553. getActiveTextures(activeTextures: BaseTexture[]): void;
  46554. /**
  46555. * Returns the animatable textures.
  46556. * @param animatables Array of animatable textures.
  46557. */
  46558. getAnimatables(animatables: IAnimatable[]): void;
  46559. /**
  46560. * Disposes the resources of the material.
  46561. * @param forceDisposeTextures - Forces the disposal of all textures.
  46562. */
  46563. dispose(forceDisposeTextures?: boolean): void;
  46564. /**
  46565. * Get the current class name of the texture useful for serialization or dynamic coding.
  46566. * @returns "PBRClearCoatConfiguration"
  46567. */
  46568. getClassName(): string;
  46569. /**
  46570. * Add fallbacks to the effect fallbacks list.
  46571. * @param defines defines the Base texture to use.
  46572. * @param fallbacks defines the current fallback list.
  46573. * @param currentRank defines the current fallback rank.
  46574. * @returns the new fallback rank.
  46575. */
  46576. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46577. /**
  46578. * Add the required uniforms to the current list.
  46579. * @param uniforms defines the current uniform list.
  46580. */
  46581. static AddUniforms(uniforms: string[]): void;
  46582. /**
  46583. * Add the required samplers to the current list.
  46584. * @param samplers defines the current sampler list.
  46585. */
  46586. static AddSamplers(samplers: string[]): void;
  46587. /**
  46588. * Add the required uniforms to the current buffer.
  46589. * @param uniformBuffer defines the current uniform buffer.
  46590. */
  46591. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46592. /**
  46593. * Makes a duplicate of the current configuration into another one.
  46594. * @param clearCoatConfiguration define the config where to copy the info
  46595. */
  46596. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46597. /**
  46598. * Serializes this clear coat configuration.
  46599. * @returns - An object with the serialized config.
  46600. */
  46601. serialize(): any;
  46602. /**
  46603. * Parses a anisotropy Configuration from a serialized object.
  46604. * @param source - Serialized object.
  46605. * @param scene Defines the scene we are parsing for
  46606. * @param rootUrl Defines the rootUrl to load from
  46607. */
  46608. parse(source: any, scene: Scene, rootUrl: string): void;
  46609. }
  46610. }
  46611. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46612. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46613. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46615. import { Vector2 } from "babylonjs/Maths/math";
  46616. import { Scene } from "babylonjs/scene";
  46617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46618. import { IAnimatable } from "babylonjs/Misc/tools";
  46619. import { Nullable } from "babylonjs/types";
  46620. /**
  46621. * @hidden
  46622. */
  46623. export interface IMaterialAnisotropicDefines {
  46624. ANISOTROPIC: boolean;
  46625. ANISOTROPIC_TEXTURE: boolean;
  46626. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46627. MAINUV1: boolean;
  46628. _areTexturesDirty: boolean;
  46629. _needUVs: boolean;
  46630. }
  46631. /**
  46632. * Define the code related to the anisotropic parameters of the pbr material.
  46633. */
  46634. export class PBRAnisotropicConfiguration {
  46635. private _isEnabled;
  46636. /**
  46637. * Defines if the anisotropy is enabled in the material.
  46638. */
  46639. isEnabled: boolean;
  46640. /**
  46641. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46642. */
  46643. intensity: number;
  46644. /**
  46645. * Defines if the effect is along the tangents, bitangents or in between.
  46646. * By default, the effect is "strectching" the highlights along the tangents.
  46647. */
  46648. direction: Vector2;
  46649. private _texture;
  46650. /**
  46651. * Stores the anisotropy values in a texture.
  46652. * rg is direction (like normal from -1 to 1)
  46653. * b is a intensity
  46654. */
  46655. texture: Nullable<BaseTexture>;
  46656. /** @hidden */
  46657. private _internalMarkAllSubMeshesAsTexturesDirty;
  46658. /** @hidden */
  46659. _markAllSubMeshesAsTexturesDirty(): void;
  46660. /**
  46661. * Instantiate a new istance of anisotropy configuration.
  46662. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46663. */
  46664. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46665. /**
  46666. * Specifies that the submesh is ready to be used.
  46667. * @param defines the list of "defines" to update.
  46668. * @param scene defines the scene the material belongs to.
  46669. * @returns - boolean indicating that the submesh is ready or not.
  46670. */
  46671. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46672. /**
  46673. * Checks to see if a texture is used in the material.
  46674. * @param defines the list of "defines" to update.
  46675. * @param mesh the mesh we are preparing the defines for.
  46676. * @param scene defines the scene the material belongs to.
  46677. */
  46678. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46679. /**
  46680. * Binds the material data.
  46681. * @param uniformBuffer defines the Uniform buffer to fill in.
  46682. * @param scene defines the scene the material belongs to.
  46683. * @param isFrozen defines wether the material is frozen or not.
  46684. */
  46685. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46686. /**
  46687. * Checks to see if a texture is used in the material.
  46688. * @param texture - Base texture to use.
  46689. * @returns - Boolean specifying if a texture is used in the material.
  46690. */
  46691. hasTexture(texture: BaseTexture): boolean;
  46692. /**
  46693. * Returns an array of the actively used textures.
  46694. * @param activeTextures Array of BaseTextures
  46695. */
  46696. getActiveTextures(activeTextures: BaseTexture[]): void;
  46697. /**
  46698. * Returns the animatable textures.
  46699. * @param animatables Array of animatable textures.
  46700. */
  46701. getAnimatables(animatables: IAnimatable[]): void;
  46702. /**
  46703. * Disposes the resources of the material.
  46704. * @param forceDisposeTextures - Forces the disposal of all textures.
  46705. */
  46706. dispose(forceDisposeTextures?: boolean): void;
  46707. /**
  46708. * Get the current class name of the texture useful for serialization or dynamic coding.
  46709. * @returns "PBRAnisotropicConfiguration"
  46710. */
  46711. getClassName(): string;
  46712. /**
  46713. * Add fallbacks to the effect fallbacks list.
  46714. * @param defines defines the Base texture to use.
  46715. * @param fallbacks defines the current fallback list.
  46716. * @param currentRank defines the current fallback rank.
  46717. * @returns the new fallback rank.
  46718. */
  46719. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46720. /**
  46721. * Add the required uniforms to the current list.
  46722. * @param uniforms defines the current uniform list.
  46723. */
  46724. static AddUniforms(uniforms: string[]): void;
  46725. /**
  46726. * Add the required uniforms to the current buffer.
  46727. * @param uniformBuffer defines the current uniform buffer.
  46728. */
  46729. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46730. /**
  46731. * Add the required samplers to the current list.
  46732. * @param samplers defines the current sampler list.
  46733. */
  46734. static AddSamplers(samplers: string[]): void;
  46735. /**
  46736. * Makes a duplicate of the current configuration into another one.
  46737. * @param anisotropicConfiguration define the config where to copy the info
  46738. */
  46739. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46740. /**
  46741. * Serializes this anisotropy configuration.
  46742. * @returns - An object with the serialized config.
  46743. */
  46744. serialize(): any;
  46745. /**
  46746. * Parses a anisotropy Configuration from a serialized object.
  46747. * @param source - Serialized object.
  46748. * @param scene Defines the scene we are parsing for
  46749. * @param rootUrl Defines the rootUrl to load from
  46750. */
  46751. parse(source: any, scene: Scene, rootUrl: string): void;
  46752. }
  46753. }
  46754. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46755. import { Scene } from "babylonjs/scene";
  46756. /**
  46757. * @hidden
  46758. */
  46759. export interface IMaterialBRDFDefines {
  46760. BRDF_V_HEIGHT_CORRELATED: boolean;
  46761. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46762. SPHERICAL_HARMONICS: boolean;
  46763. /** @hidden */
  46764. _areMiscDirty: boolean;
  46765. }
  46766. /**
  46767. * Define the code related to the BRDF parameters of the pbr material.
  46768. */
  46769. export class PBRBRDFConfiguration {
  46770. /**
  46771. * Default value used for the energy conservation.
  46772. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46773. */
  46774. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46775. /**
  46776. * Default value used for the Smith Visibility Height Correlated mode.
  46777. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46778. */
  46779. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46780. /**
  46781. * Default value used for the IBL diffuse part.
  46782. * This can help switching back to the polynomials mode globally which is a tiny bit
  46783. * less GPU intensive at the drawback of a lower quality.
  46784. */
  46785. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46786. private _useEnergyConservation;
  46787. /**
  46788. * Defines if the material uses energy conservation.
  46789. */
  46790. useEnergyConservation: boolean;
  46791. private _useSmithVisibilityHeightCorrelated;
  46792. /**
  46793. * LEGACY Mode set to false
  46794. * Defines if the material uses height smith correlated visibility term.
  46795. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46796. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46797. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46798. * Not relying on height correlated will also disable energy conservation.
  46799. */
  46800. useSmithVisibilityHeightCorrelated: boolean;
  46801. private _useSphericalHarmonics;
  46802. /**
  46803. * LEGACY Mode set to false
  46804. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46805. * diffuse part of the IBL.
  46806. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46807. * to the ground truth.
  46808. */
  46809. useSphericalHarmonics: boolean;
  46810. /** @hidden */
  46811. private _internalMarkAllSubMeshesAsMiscDirty;
  46812. /** @hidden */
  46813. _markAllSubMeshesAsMiscDirty(): void;
  46814. /**
  46815. * Instantiate a new istance of clear coat configuration.
  46816. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46817. */
  46818. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46819. /**
  46820. * Checks to see if a texture is used in the material.
  46821. * @param defines the list of "defines" to update.
  46822. */
  46823. prepareDefines(defines: IMaterialBRDFDefines): void;
  46824. /**
  46825. * Get the current class name of the texture useful for serialization or dynamic coding.
  46826. * @returns "PBRClearCoatConfiguration"
  46827. */
  46828. getClassName(): string;
  46829. /**
  46830. * Makes a duplicate of the current configuration into another one.
  46831. * @param brdfConfiguration define the config where to copy the info
  46832. */
  46833. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46834. /**
  46835. * Serializes this BRDF configuration.
  46836. * @returns - An object with the serialized config.
  46837. */
  46838. serialize(): any;
  46839. /**
  46840. * Parses a anisotropy Configuration from a serialized object.
  46841. * @param source - Serialized object.
  46842. * @param scene Defines the scene we are parsing for
  46843. * @param rootUrl Defines the rootUrl to load from
  46844. */
  46845. parse(source: any, scene: Scene, rootUrl: string): void;
  46846. }
  46847. }
  46848. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46849. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46850. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46851. import { Color3 } from "babylonjs/Maths/math";
  46852. import { Scene } from "babylonjs/scene";
  46853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46854. import { IAnimatable } from "babylonjs/Misc/tools";
  46855. import { Nullable } from "babylonjs/types";
  46856. /**
  46857. * @hidden
  46858. */
  46859. export interface IMaterialSheenDefines {
  46860. SHEEN: boolean;
  46861. SHEEN_TEXTURE: boolean;
  46862. SHEEN_TEXTUREDIRECTUV: number;
  46863. SHEEN_LINKWITHALBEDO: boolean;
  46864. /** @hidden */
  46865. _areTexturesDirty: boolean;
  46866. }
  46867. /**
  46868. * Define the code related to the Sheen parameters of the pbr material.
  46869. */
  46870. export class PBRSheenConfiguration {
  46871. private _isEnabled;
  46872. /**
  46873. * Defines if the material uses sheen.
  46874. */
  46875. isEnabled: boolean;
  46876. private _linkSheenWithAlbedo;
  46877. /**
  46878. * Defines if the sheen is linked to the sheen color.
  46879. */
  46880. linkSheenWithAlbedo: boolean;
  46881. /**
  46882. * Defines the sheen intensity.
  46883. */
  46884. intensity: number;
  46885. /**
  46886. * Defines the sheen color.
  46887. */
  46888. color: Color3;
  46889. private _texture;
  46890. /**
  46891. * Stores the sheen tint values in a texture.
  46892. * rgb is tint
  46893. * a is a intensity
  46894. */
  46895. texture: Nullable<BaseTexture>;
  46896. /** @hidden */
  46897. private _internalMarkAllSubMeshesAsTexturesDirty;
  46898. /** @hidden */
  46899. _markAllSubMeshesAsTexturesDirty(): void;
  46900. /**
  46901. * Instantiate a new istance of clear coat configuration.
  46902. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46903. */
  46904. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46905. /**
  46906. * Specifies that the submesh is ready to be used.
  46907. * @param defines the list of "defines" to update.
  46908. * @param scene defines the scene the material belongs to.
  46909. * @returns - boolean indicating that the submesh is ready or not.
  46910. */
  46911. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46912. /**
  46913. * Checks to see if a texture is used in the material.
  46914. * @param defines the list of "defines" to update.
  46915. * @param scene defines the scene the material belongs to.
  46916. */
  46917. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46918. /**
  46919. * Binds the material data.
  46920. * @param uniformBuffer defines the Uniform buffer to fill in.
  46921. * @param scene defines the scene the material belongs to.
  46922. * @param isFrozen defines wether the material is frozen or not.
  46923. */
  46924. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46925. /**
  46926. * Checks to see if a texture is used in the material.
  46927. * @param texture - Base texture to use.
  46928. * @returns - Boolean specifying if a texture is used in the material.
  46929. */
  46930. hasTexture(texture: BaseTexture): boolean;
  46931. /**
  46932. * Returns an array of the actively used textures.
  46933. * @param activeTextures Array of BaseTextures
  46934. */
  46935. getActiveTextures(activeTextures: BaseTexture[]): void;
  46936. /**
  46937. * Returns the animatable textures.
  46938. * @param animatables Array of animatable textures.
  46939. */
  46940. getAnimatables(animatables: IAnimatable[]): void;
  46941. /**
  46942. * Disposes the resources of the material.
  46943. * @param forceDisposeTextures - Forces the disposal of all textures.
  46944. */
  46945. dispose(forceDisposeTextures?: boolean): void;
  46946. /**
  46947. * Get the current class name of the texture useful for serialization or dynamic coding.
  46948. * @returns "PBRSheenConfiguration"
  46949. */
  46950. getClassName(): string;
  46951. /**
  46952. * Add fallbacks to the effect fallbacks list.
  46953. * @param defines defines the Base texture to use.
  46954. * @param fallbacks defines the current fallback list.
  46955. * @param currentRank defines the current fallback rank.
  46956. * @returns the new fallback rank.
  46957. */
  46958. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46959. /**
  46960. * Add the required uniforms to the current list.
  46961. * @param uniforms defines the current uniform list.
  46962. */
  46963. static AddUniforms(uniforms: string[]): void;
  46964. /**
  46965. * Add the required uniforms to the current buffer.
  46966. * @param uniformBuffer defines the current uniform buffer.
  46967. */
  46968. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46969. /**
  46970. * Add the required samplers to the current list.
  46971. * @param samplers defines the current sampler list.
  46972. */
  46973. static AddSamplers(samplers: string[]): void;
  46974. /**
  46975. * Makes a duplicate of the current configuration into another one.
  46976. * @param sheenConfiguration define the config where to copy the info
  46977. */
  46978. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46979. /**
  46980. * Serializes this BRDF configuration.
  46981. * @returns - An object with the serialized config.
  46982. */
  46983. serialize(): any;
  46984. /**
  46985. * Parses a anisotropy Configuration from a serialized object.
  46986. * @param source - Serialized object.
  46987. * @param scene Defines the scene we are parsing for
  46988. * @param rootUrl Defines the rootUrl to load from
  46989. */
  46990. parse(source: any, scene: Scene, rootUrl: string): void;
  46991. }
  46992. }
  46993. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46994. import { Nullable } from "babylonjs/types";
  46995. import { IAnimatable } from "babylonjs/Misc/tools";
  46996. import { Color3 } from "babylonjs/Maths/math";
  46997. import { SmartArray } from "babylonjs/Misc/smartArray";
  46998. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47000. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47001. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47002. import { Engine } from "babylonjs/Engines/engine";
  47003. import { Scene } from "babylonjs/scene";
  47004. /**
  47005. * @hidden
  47006. */
  47007. export interface IMaterialSubSurfaceDefines {
  47008. SUBSURFACE: boolean;
  47009. SS_REFRACTION: boolean;
  47010. SS_TRANSLUCENCY: boolean;
  47011. SS_SCATERRING: boolean;
  47012. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47013. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47014. SS_REFRACTIONMAP_3D: boolean;
  47015. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47016. SS_LODINREFRACTIONALPHA: boolean;
  47017. SS_GAMMAREFRACTION: boolean;
  47018. SS_RGBDREFRACTION: boolean;
  47019. SS_LINEARSPECULARREFRACTION: boolean;
  47020. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47021. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47022. /** @hidden */
  47023. _areTexturesDirty: boolean;
  47024. }
  47025. /**
  47026. * Define the code related to the sub surface parameters of the pbr material.
  47027. */
  47028. export class PBRSubSurfaceConfiguration {
  47029. private _isRefractionEnabled;
  47030. /**
  47031. * Defines if the refraction is enabled in the material.
  47032. */
  47033. isRefractionEnabled: boolean;
  47034. private _isTranslucencyEnabled;
  47035. /**
  47036. * Defines if the translucency is enabled in the material.
  47037. */
  47038. isTranslucencyEnabled: boolean;
  47039. private _isScatteringEnabled;
  47040. /**
  47041. * Defines the refraction intensity of the material.
  47042. * The refraction when enabled replaces the Diffuse part of the material.
  47043. * The intensity helps transitionning between diffuse and refraction.
  47044. */
  47045. refractionIntensity: number;
  47046. /**
  47047. * Defines the translucency intensity of the material.
  47048. * When translucency has been enabled, this defines how much of the "translucency"
  47049. * is addded to the diffuse part of the material.
  47050. */
  47051. translucencyIntensity: number;
  47052. /**
  47053. * Defines the scattering intensity of the material.
  47054. * When scattering has been enabled, this defines how much of the "scattered light"
  47055. * is addded to the diffuse part of the material.
  47056. */
  47057. scatteringIntensity: number;
  47058. private _thicknessTexture;
  47059. /**
  47060. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47061. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47062. * 0 would mean minimumThickness
  47063. * 1 would mean maximumThickness
  47064. * The other channels might be use as a mask to vary the different effects intensity.
  47065. */
  47066. thicknessTexture: Nullable<BaseTexture>;
  47067. private _refractionTexture;
  47068. /**
  47069. * Defines the texture to use for refraction.
  47070. */
  47071. refractionTexture: Nullable<BaseTexture>;
  47072. private _indexOfRefraction;
  47073. /**
  47074. * Defines the index of refraction used in the material.
  47075. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47076. */
  47077. indexOfRefraction: number;
  47078. private _invertRefractionY;
  47079. /**
  47080. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47081. */
  47082. invertRefractionY: boolean;
  47083. private _linkRefractionWithTransparency;
  47084. /**
  47085. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47086. * Materials half opaque for instance using refraction could benefit from this control.
  47087. */
  47088. linkRefractionWithTransparency: boolean;
  47089. /**
  47090. * Defines the minimum thickness stored in the thickness map.
  47091. * If no thickness map is defined, this value will be used to simulate thickness.
  47092. */
  47093. minimumThickness: number;
  47094. /**
  47095. * Defines the maximum thickness stored in the thickness map.
  47096. */
  47097. maximumThickness: number;
  47098. /**
  47099. * Defines the volume tint of the material.
  47100. * This is used for both translucency and scattering.
  47101. */
  47102. tintColor: Color3;
  47103. /**
  47104. * Defines the distance at which the tint color should be found in the media.
  47105. * This is used for refraction only.
  47106. */
  47107. tintColorAtDistance: number;
  47108. /**
  47109. * Defines how far each channel transmit through the media.
  47110. * It is defined as a color to simplify it selection.
  47111. */
  47112. diffusionDistance: Color3;
  47113. private _useMaskFromThicknessTexture;
  47114. /**
  47115. * Stores the intensity of the different subsurface effects in the thickness texture.
  47116. * * the green channel is the translucency intensity.
  47117. * * the blue channel is the scattering intensity.
  47118. * * the alpha channel is the refraction intensity.
  47119. */
  47120. useMaskFromThicknessTexture: boolean;
  47121. /** @hidden */
  47122. private _internalMarkAllSubMeshesAsTexturesDirty;
  47123. /** @hidden */
  47124. _markAllSubMeshesAsTexturesDirty(): void;
  47125. /**
  47126. * Instantiate a new istance of sub surface configuration.
  47127. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47128. */
  47129. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47130. /**
  47131. * Gets wehter the submesh is ready to be used or not.
  47132. * @param defines the list of "defines" to update.
  47133. * @param scene defines the scene the material belongs to.
  47134. * @returns - boolean indicating that the submesh is ready or not.
  47135. */
  47136. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47137. /**
  47138. * Checks to see if a texture is used in the material.
  47139. * @param defines the list of "defines" to update.
  47140. * @param scene defines the scene to the material belongs to.
  47141. */
  47142. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47143. /**
  47144. * Binds the material data.
  47145. * @param uniformBuffer defines the Uniform buffer to fill in.
  47146. * @param scene defines the scene the material belongs to.
  47147. * @param engine defines the engine the material belongs to.
  47148. * @param isFrozen defines wether the material is frozen or not.
  47149. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47150. */
  47151. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47152. /**
  47153. * Unbinds the material from the mesh.
  47154. * @param activeEffect defines the effect that should be unbound from.
  47155. * @returns true if unbound, otherwise false
  47156. */
  47157. unbind(activeEffect: Effect): boolean;
  47158. /**
  47159. * Returns the texture used for refraction or null if none is used.
  47160. * @param scene defines the scene the material belongs to.
  47161. * @returns - Refraction texture if present. If no refraction texture and refraction
  47162. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47163. */
  47164. private _getRefractionTexture;
  47165. /**
  47166. * Returns true if alpha blending should be disabled.
  47167. */
  47168. readonly disableAlphaBlending: boolean;
  47169. /**
  47170. * Fills the list of render target textures.
  47171. * @param renderTargets the list of render targets to update
  47172. */
  47173. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47174. /**
  47175. * Checks to see if a texture is used in the material.
  47176. * @param texture - Base texture to use.
  47177. * @returns - Boolean specifying if a texture is used in the material.
  47178. */
  47179. hasTexture(texture: BaseTexture): boolean;
  47180. /**
  47181. * Gets a boolean indicating that current material needs to register RTT
  47182. * @returns true if this uses a render target otherwise false.
  47183. */
  47184. hasRenderTargetTextures(): boolean;
  47185. /**
  47186. * Returns an array of the actively used textures.
  47187. * @param activeTextures Array of BaseTextures
  47188. */
  47189. getActiveTextures(activeTextures: BaseTexture[]): void;
  47190. /**
  47191. * Returns the animatable textures.
  47192. * @param animatables Array of animatable textures.
  47193. */
  47194. getAnimatables(animatables: IAnimatable[]): void;
  47195. /**
  47196. * Disposes the resources of the material.
  47197. * @param forceDisposeTextures - Forces the disposal of all textures.
  47198. */
  47199. dispose(forceDisposeTextures?: boolean): void;
  47200. /**
  47201. * Get the current class name of the texture useful for serialization or dynamic coding.
  47202. * @returns "PBRSubSurfaceConfiguration"
  47203. */
  47204. getClassName(): string;
  47205. /**
  47206. * Add fallbacks to the effect fallbacks list.
  47207. * @param defines defines the Base texture to use.
  47208. * @param fallbacks defines the current fallback list.
  47209. * @param currentRank defines the current fallback rank.
  47210. * @returns the new fallback rank.
  47211. */
  47212. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47213. /**
  47214. * Add the required uniforms to the current list.
  47215. * @param uniforms defines the current uniform list.
  47216. */
  47217. static AddUniforms(uniforms: string[]): void;
  47218. /**
  47219. * Add the required samplers to the current list.
  47220. * @param samplers defines the current sampler list.
  47221. */
  47222. static AddSamplers(samplers: string[]): void;
  47223. /**
  47224. * Add the required uniforms to the current buffer.
  47225. * @param uniformBuffer defines the current uniform buffer.
  47226. */
  47227. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47228. /**
  47229. * Makes a duplicate of the current configuration into another one.
  47230. * @param configuration define the config where to copy the info
  47231. */
  47232. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47233. /**
  47234. * Serializes this Sub Surface configuration.
  47235. * @returns - An object with the serialized config.
  47236. */
  47237. serialize(): any;
  47238. /**
  47239. * Parses a anisotropy Configuration from a serialized object.
  47240. * @param source - Serialized object.
  47241. * @param scene Defines the scene we are parsing for
  47242. * @param rootUrl Defines the rootUrl to load from
  47243. */
  47244. parse(source: any, scene: Scene, rootUrl: string): void;
  47245. }
  47246. }
  47247. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47248. /** @hidden */
  47249. export var pbrFragmentDeclaration: {
  47250. name: string;
  47251. shader: string;
  47252. };
  47253. }
  47254. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47255. /** @hidden */
  47256. export var pbrUboDeclaration: {
  47257. name: string;
  47258. shader: string;
  47259. };
  47260. }
  47261. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47262. /** @hidden */
  47263. export var pbrFragmentExtraDeclaration: {
  47264. name: string;
  47265. shader: string;
  47266. };
  47267. }
  47268. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47269. /** @hidden */
  47270. export var pbrFragmentSamplersDeclaration: {
  47271. name: string;
  47272. shader: string;
  47273. };
  47274. }
  47275. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47276. /** @hidden */
  47277. export var pbrHelperFunctions: {
  47278. name: string;
  47279. shader: string;
  47280. };
  47281. }
  47282. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47283. /** @hidden */
  47284. export var harmonicsFunctions: {
  47285. name: string;
  47286. shader: string;
  47287. };
  47288. }
  47289. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47290. /** @hidden */
  47291. export var pbrDirectLightingSetupFunctions: {
  47292. name: string;
  47293. shader: string;
  47294. };
  47295. }
  47296. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47297. /** @hidden */
  47298. export var pbrDirectLightingFalloffFunctions: {
  47299. name: string;
  47300. shader: string;
  47301. };
  47302. }
  47303. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47304. /** @hidden */
  47305. export var pbrBRDFFunctions: {
  47306. name: string;
  47307. shader: string;
  47308. };
  47309. }
  47310. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47311. /** @hidden */
  47312. export var pbrDirectLightingFunctions: {
  47313. name: string;
  47314. shader: string;
  47315. };
  47316. }
  47317. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47318. /** @hidden */
  47319. export var pbrIBLFunctions: {
  47320. name: string;
  47321. shader: string;
  47322. };
  47323. }
  47324. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47325. /** @hidden */
  47326. export var pbrDebug: {
  47327. name: string;
  47328. shader: string;
  47329. };
  47330. }
  47331. declare module "babylonjs/Shaders/pbr.fragment" {
  47332. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47333. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47334. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47335. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47336. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47337. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47338. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47339. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47340. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47341. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47342. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47343. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47344. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47345. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47346. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47347. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47348. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47349. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47350. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47351. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47352. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47353. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47354. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47355. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47356. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47357. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47358. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47359. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47360. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47361. /** @hidden */
  47362. export var pbrPixelShader: {
  47363. name: string;
  47364. shader: string;
  47365. };
  47366. }
  47367. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47368. /** @hidden */
  47369. export var pbrVertexDeclaration: {
  47370. name: string;
  47371. shader: string;
  47372. };
  47373. }
  47374. declare module "babylonjs/Shaders/pbr.vertex" {
  47375. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47376. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47377. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47378. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47379. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47380. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47381. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47382. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47383. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47384. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47385. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47386. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47388. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47389. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47390. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47391. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47392. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47393. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47394. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47395. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47396. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47397. /** @hidden */
  47398. export var pbrVertexShader: {
  47399. name: string;
  47400. shader: string;
  47401. };
  47402. }
  47403. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47404. import { IAnimatable } from "babylonjs/Misc/tools";
  47405. import { Nullable } from "babylonjs/types";
  47406. import { Scene } from "babylonjs/scene";
  47407. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47408. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47410. import { Mesh } from "babylonjs/Meshes/mesh";
  47411. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47412. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47413. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47414. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47415. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47416. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47417. import { Material } from "babylonjs/Materials/material";
  47418. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47419. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47421. import "babylonjs/Shaders/pbr.fragment";
  47422. import "babylonjs/Shaders/pbr.vertex";
  47423. /**
  47424. * Manages the defines for the PBR Material.
  47425. * @hidden
  47426. */
  47427. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47428. PBR: boolean;
  47429. MAINUV1: boolean;
  47430. MAINUV2: boolean;
  47431. UV1: boolean;
  47432. UV2: boolean;
  47433. ALBEDO: boolean;
  47434. ALBEDODIRECTUV: number;
  47435. VERTEXCOLOR: boolean;
  47436. AMBIENT: boolean;
  47437. AMBIENTDIRECTUV: number;
  47438. AMBIENTINGRAYSCALE: boolean;
  47439. OPACITY: boolean;
  47440. VERTEXALPHA: boolean;
  47441. OPACITYDIRECTUV: number;
  47442. OPACITYRGB: boolean;
  47443. ALPHATEST: boolean;
  47444. DEPTHPREPASS: boolean;
  47445. ALPHABLEND: boolean;
  47446. ALPHAFROMALBEDO: boolean;
  47447. ALPHATESTVALUE: string;
  47448. SPECULAROVERALPHA: boolean;
  47449. RADIANCEOVERALPHA: boolean;
  47450. ALPHAFRESNEL: boolean;
  47451. LINEARALPHAFRESNEL: boolean;
  47452. PREMULTIPLYALPHA: boolean;
  47453. EMISSIVE: boolean;
  47454. EMISSIVEDIRECTUV: number;
  47455. REFLECTIVITY: boolean;
  47456. REFLECTIVITYDIRECTUV: number;
  47457. SPECULARTERM: boolean;
  47458. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47459. MICROSURFACEAUTOMATIC: boolean;
  47460. LODBASEDMICROSFURACE: boolean;
  47461. MICROSURFACEMAP: boolean;
  47462. MICROSURFACEMAPDIRECTUV: number;
  47463. METALLICWORKFLOW: boolean;
  47464. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47465. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47466. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47467. AOSTOREINMETALMAPRED: boolean;
  47468. ENVIRONMENTBRDF: boolean;
  47469. ENVIRONMENTBRDF_RGBD: boolean;
  47470. NORMAL: boolean;
  47471. TANGENT: boolean;
  47472. BUMP: boolean;
  47473. BUMPDIRECTUV: number;
  47474. OBJECTSPACE_NORMALMAP: boolean;
  47475. PARALLAX: boolean;
  47476. PARALLAXOCCLUSION: boolean;
  47477. NORMALXYSCALE: boolean;
  47478. LIGHTMAP: boolean;
  47479. LIGHTMAPDIRECTUV: number;
  47480. USELIGHTMAPASSHADOWMAP: boolean;
  47481. GAMMALIGHTMAP: boolean;
  47482. REFLECTION: boolean;
  47483. REFLECTIONMAP_3D: boolean;
  47484. REFLECTIONMAP_SPHERICAL: boolean;
  47485. REFLECTIONMAP_PLANAR: boolean;
  47486. REFLECTIONMAP_CUBIC: boolean;
  47487. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47488. REFLECTIONMAP_PROJECTION: boolean;
  47489. REFLECTIONMAP_SKYBOX: boolean;
  47490. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47491. REFLECTIONMAP_EXPLICIT: boolean;
  47492. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47493. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47494. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47495. INVERTCUBICMAP: boolean;
  47496. USESPHERICALFROMREFLECTIONMAP: boolean;
  47497. USEIRRADIANCEMAP: boolean;
  47498. SPHERICAL_HARMONICS: boolean;
  47499. USESPHERICALINVERTEX: boolean;
  47500. REFLECTIONMAP_OPPOSITEZ: boolean;
  47501. LODINREFLECTIONALPHA: boolean;
  47502. GAMMAREFLECTION: boolean;
  47503. RGBDREFLECTION: boolean;
  47504. LINEARSPECULARREFLECTION: boolean;
  47505. RADIANCEOCCLUSION: boolean;
  47506. HORIZONOCCLUSION: boolean;
  47507. INSTANCES: boolean;
  47508. NUM_BONE_INFLUENCERS: number;
  47509. BonesPerMesh: number;
  47510. BONETEXTURE: boolean;
  47511. NONUNIFORMSCALING: boolean;
  47512. MORPHTARGETS: boolean;
  47513. MORPHTARGETS_NORMAL: boolean;
  47514. MORPHTARGETS_TANGENT: boolean;
  47515. MORPHTARGETS_UV: boolean;
  47516. NUM_MORPH_INFLUENCERS: number;
  47517. IMAGEPROCESSING: boolean;
  47518. VIGNETTE: boolean;
  47519. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47520. VIGNETTEBLENDMODEOPAQUE: boolean;
  47521. TONEMAPPING: boolean;
  47522. TONEMAPPING_ACES: boolean;
  47523. CONTRAST: boolean;
  47524. COLORCURVES: boolean;
  47525. COLORGRADING: boolean;
  47526. COLORGRADING3D: boolean;
  47527. SAMPLER3DGREENDEPTH: boolean;
  47528. SAMPLER3DBGRMAP: boolean;
  47529. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47530. EXPOSURE: boolean;
  47531. MULTIVIEW: boolean;
  47532. USEPHYSICALLIGHTFALLOFF: boolean;
  47533. USEGLTFLIGHTFALLOFF: boolean;
  47534. TWOSIDEDLIGHTING: boolean;
  47535. SHADOWFLOAT: boolean;
  47536. CLIPPLANE: boolean;
  47537. CLIPPLANE2: boolean;
  47538. CLIPPLANE3: boolean;
  47539. CLIPPLANE4: boolean;
  47540. POINTSIZE: boolean;
  47541. FOG: boolean;
  47542. LOGARITHMICDEPTH: boolean;
  47543. FORCENORMALFORWARD: boolean;
  47544. SPECULARAA: boolean;
  47545. CLEARCOAT: boolean;
  47546. CLEARCOAT_DEFAULTIOR: boolean;
  47547. CLEARCOAT_TEXTURE: boolean;
  47548. CLEARCOAT_TEXTUREDIRECTUV: number;
  47549. CLEARCOAT_BUMP: boolean;
  47550. CLEARCOAT_BUMPDIRECTUV: number;
  47551. CLEARCOAT_TINT: boolean;
  47552. CLEARCOAT_TINT_TEXTURE: boolean;
  47553. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47554. ANISOTROPIC: boolean;
  47555. ANISOTROPIC_TEXTURE: boolean;
  47556. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47557. BRDF_V_HEIGHT_CORRELATED: boolean;
  47558. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47559. SHEEN: boolean;
  47560. SHEEN_TEXTURE: boolean;
  47561. SHEEN_TEXTUREDIRECTUV: number;
  47562. SHEEN_LINKWITHALBEDO: boolean;
  47563. SUBSURFACE: boolean;
  47564. SS_REFRACTION: boolean;
  47565. SS_TRANSLUCENCY: boolean;
  47566. SS_SCATERRING: boolean;
  47567. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47568. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47569. SS_REFRACTIONMAP_3D: boolean;
  47570. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47571. SS_LODINREFRACTIONALPHA: boolean;
  47572. SS_GAMMAREFRACTION: boolean;
  47573. SS_RGBDREFRACTION: boolean;
  47574. SS_LINEARSPECULARREFRACTION: boolean;
  47575. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47576. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47577. UNLIT: boolean;
  47578. DEBUGMODE: number;
  47579. /**
  47580. * Initializes the PBR Material defines.
  47581. */
  47582. constructor();
  47583. /**
  47584. * Resets the PBR Material defines.
  47585. */
  47586. reset(): void;
  47587. }
  47588. /**
  47589. * The Physically based material base class of BJS.
  47590. *
  47591. * This offers the main features of a standard PBR material.
  47592. * For more information, please refer to the documentation :
  47593. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47594. */
  47595. export abstract class PBRBaseMaterial extends PushMaterial {
  47596. /**
  47597. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47598. */
  47599. static readonly PBRMATERIAL_OPAQUE: number;
  47600. /**
  47601. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47602. */
  47603. static readonly PBRMATERIAL_ALPHATEST: number;
  47604. /**
  47605. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47606. */
  47607. static readonly PBRMATERIAL_ALPHABLEND: number;
  47608. /**
  47609. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47610. * They are also discarded below the alpha cutoff threshold to improve performances.
  47611. */
  47612. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47613. /**
  47614. * Defines the default value of how much AO map is occluding the analytical lights
  47615. * (point spot...).
  47616. */
  47617. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47618. /**
  47619. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47620. */
  47621. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47622. /**
  47623. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47624. * to enhance interoperability with other engines.
  47625. */
  47626. static readonly LIGHTFALLOFF_GLTF: number;
  47627. /**
  47628. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47629. * to enhance interoperability with other materials.
  47630. */
  47631. static readonly LIGHTFALLOFF_STANDARD: number;
  47632. /**
  47633. * Intensity of the direct lights e.g. the four lights available in your scene.
  47634. * This impacts both the direct diffuse and specular highlights.
  47635. */
  47636. protected _directIntensity: number;
  47637. /**
  47638. * Intensity of the emissive part of the material.
  47639. * This helps controlling the emissive effect without modifying the emissive color.
  47640. */
  47641. protected _emissiveIntensity: number;
  47642. /**
  47643. * Intensity of the environment e.g. how much the environment will light the object
  47644. * either through harmonics for rough material or through the refelction for shiny ones.
  47645. */
  47646. protected _environmentIntensity: number;
  47647. /**
  47648. * This is a special control allowing the reduction of the specular highlights coming from the
  47649. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47650. */
  47651. protected _specularIntensity: number;
  47652. /**
  47653. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47654. */
  47655. private _lightingInfos;
  47656. /**
  47657. * Debug Control allowing disabling the bump map on this material.
  47658. */
  47659. protected _disableBumpMap: boolean;
  47660. /**
  47661. * AKA Diffuse Texture in standard nomenclature.
  47662. */
  47663. protected _albedoTexture: Nullable<BaseTexture>;
  47664. /**
  47665. * AKA Occlusion Texture in other nomenclature.
  47666. */
  47667. protected _ambientTexture: Nullable<BaseTexture>;
  47668. /**
  47669. * AKA Occlusion Texture Intensity in other nomenclature.
  47670. */
  47671. protected _ambientTextureStrength: number;
  47672. /**
  47673. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47674. * 1 means it completely occludes it
  47675. * 0 mean it has no impact
  47676. */
  47677. protected _ambientTextureImpactOnAnalyticalLights: number;
  47678. /**
  47679. * Stores the alpha values in a texture.
  47680. */
  47681. protected _opacityTexture: Nullable<BaseTexture>;
  47682. /**
  47683. * Stores the reflection values in a texture.
  47684. */
  47685. protected _reflectionTexture: Nullable<BaseTexture>;
  47686. /**
  47687. * Stores the emissive values in a texture.
  47688. */
  47689. protected _emissiveTexture: Nullable<BaseTexture>;
  47690. /**
  47691. * AKA Specular texture in other nomenclature.
  47692. */
  47693. protected _reflectivityTexture: Nullable<BaseTexture>;
  47694. /**
  47695. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47696. */
  47697. protected _metallicTexture: Nullable<BaseTexture>;
  47698. /**
  47699. * Specifies the metallic scalar of the metallic/roughness workflow.
  47700. * Can also be used to scale the metalness values of the metallic texture.
  47701. */
  47702. protected _metallic: Nullable<number>;
  47703. /**
  47704. * Specifies the roughness scalar of the metallic/roughness workflow.
  47705. * Can also be used to scale the roughness values of the metallic texture.
  47706. */
  47707. protected _roughness: Nullable<number>;
  47708. /**
  47709. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47710. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47711. */
  47712. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47713. /**
  47714. * Stores surface normal data used to displace a mesh in a texture.
  47715. */
  47716. protected _bumpTexture: Nullable<BaseTexture>;
  47717. /**
  47718. * Stores the pre-calculated light information of a mesh in a texture.
  47719. */
  47720. protected _lightmapTexture: Nullable<BaseTexture>;
  47721. /**
  47722. * The color of a material in ambient lighting.
  47723. */
  47724. protected _ambientColor: Color3;
  47725. /**
  47726. * AKA Diffuse Color in other nomenclature.
  47727. */
  47728. protected _albedoColor: Color3;
  47729. /**
  47730. * AKA Specular Color in other nomenclature.
  47731. */
  47732. protected _reflectivityColor: Color3;
  47733. /**
  47734. * The color applied when light is reflected from a material.
  47735. */
  47736. protected _reflectionColor: Color3;
  47737. /**
  47738. * The color applied when light is emitted from a material.
  47739. */
  47740. protected _emissiveColor: Color3;
  47741. /**
  47742. * AKA Glossiness in other nomenclature.
  47743. */
  47744. protected _microSurface: number;
  47745. /**
  47746. * Specifies that the material will use the light map as a show map.
  47747. */
  47748. protected _useLightmapAsShadowmap: boolean;
  47749. /**
  47750. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47751. * makes the reflect vector face the model (under horizon).
  47752. */
  47753. protected _useHorizonOcclusion: boolean;
  47754. /**
  47755. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47756. * too much the area relying on ambient texture to define their ambient occlusion.
  47757. */
  47758. protected _useRadianceOcclusion: boolean;
  47759. /**
  47760. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47761. */
  47762. protected _useAlphaFromAlbedoTexture: boolean;
  47763. /**
  47764. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47765. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47766. */
  47767. protected _useSpecularOverAlpha: boolean;
  47768. /**
  47769. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47770. */
  47771. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47772. /**
  47773. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47774. */
  47775. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47776. /**
  47777. * Specifies if the metallic texture contains the roughness information in its green channel.
  47778. */
  47779. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47780. /**
  47781. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47782. */
  47783. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47784. /**
  47785. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47786. */
  47787. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47788. /**
  47789. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47790. */
  47791. protected _useAmbientInGrayScale: boolean;
  47792. /**
  47793. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47794. * The material will try to infer what glossiness each pixel should be.
  47795. */
  47796. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47797. /**
  47798. * Defines the falloff type used in this material.
  47799. * It by default is Physical.
  47800. */
  47801. protected _lightFalloff: number;
  47802. /**
  47803. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47804. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47805. */
  47806. protected _useRadianceOverAlpha: boolean;
  47807. /**
  47808. * Allows using an object space normal map (instead of tangent space).
  47809. */
  47810. protected _useObjectSpaceNormalMap: boolean;
  47811. /**
  47812. * Allows using the bump map in parallax mode.
  47813. */
  47814. protected _useParallax: boolean;
  47815. /**
  47816. * Allows using the bump map in parallax occlusion mode.
  47817. */
  47818. protected _useParallaxOcclusion: boolean;
  47819. /**
  47820. * Controls the scale bias of the parallax mode.
  47821. */
  47822. protected _parallaxScaleBias: number;
  47823. /**
  47824. * If sets to true, disables all the lights affecting the material.
  47825. */
  47826. protected _disableLighting: boolean;
  47827. /**
  47828. * Number of Simultaneous lights allowed on the material.
  47829. */
  47830. protected _maxSimultaneousLights: number;
  47831. /**
  47832. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47833. */
  47834. protected _invertNormalMapX: boolean;
  47835. /**
  47836. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47837. */
  47838. protected _invertNormalMapY: boolean;
  47839. /**
  47840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47841. */
  47842. protected _twoSidedLighting: boolean;
  47843. /**
  47844. * Defines the alpha limits in alpha test mode.
  47845. */
  47846. protected _alphaCutOff: number;
  47847. /**
  47848. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47849. */
  47850. protected _forceAlphaTest: boolean;
  47851. /**
  47852. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47853. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47854. */
  47855. protected _useAlphaFresnel: boolean;
  47856. /**
  47857. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47858. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47859. */
  47860. protected _useLinearAlphaFresnel: boolean;
  47861. /**
  47862. * The transparency mode of the material.
  47863. */
  47864. protected _transparencyMode: Nullable<number>;
  47865. /**
  47866. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47867. * from cos thetav and roughness:
  47868. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47869. */
  47870. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47871. /**
  47872. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47873. */
  47874. protected _forceIrradianceInFragment: boolean;
  47875. /**
  47876. * Force normal to face away from face.
  47877. */
  47878. protected _forceNormalForward: boolean;
  47879. /**
  47880. * Enables specular anti aliasing in the PBR shader.
  47881. * It will both interacts on the Geometry for analytical and IBL lighting.
  47882. * It also prefilter the roughness map based on the bump values.
  47883. */
  47884. protected _enableSpecularAntiAliasing: boolean;
  47885. /**
  47886. * Default configuration related to image processing available in the PBR Material.
  47887. */
  47888. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47889. /**
  47890. * Keep track of the image processing observer to allow dispose and replace.
  47891. */
  47892. private _imageProcessingObserver;
  47893. /**
  47894. * Attaches a new image processing configuration to the PBR Material.
  47895. * @param configuration
  47896. */
  47897. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47898. /**
  47899. * Stores the available render targets.
  47900. */
  47901. private _renderTargets;
  47902. /**
  47903. * Sets the global ambient color for the material used in lighting calculations.
  47904. */
  47905. private _globalAmbientColor;
  47906. /**
  47907. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47908. */
  47909. private _useLogarithmicDepth;
  47910. /**
  47911. * If set to true, no lighting calculations will be applied.
  47912. */
  47913. private _unlit;
  47914. private _debugMode;
  47915. /**
  47916. * @hidden
  47917. * This is reserved for the inspector.
  47918. * Defines the material debug mode.
  47919. * It helps seeing only some components of the material while troubleshooting.
  47920. */
  47921. debugMode: number;
  47922. /**
  47923. * @hidden
  47924. * This is reserved for the inspector.
  47925. * Specify from where on screen the debug mode should start.
  47926. * The value goes from -1 (full screen) to 1 (not visible)
  47927. * It helps with side by side comparison against the final render
  47928. * This defaults to -1
  47929. */
  47930. private debugLimit;
  47931. /**
  47932. * @hidden
  47933. * This is reserved for the inspector.
  47934. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47935. * You can use the factor to better multiply the final value.
  47936. */
  47937. private debugFactor;
  47938. /**
  47939. * Defines the clear coat layer parameters for the material.
  47940. */
  47941. readonly clearCoat: PBRClearCoatConfiguration;
  47942. /**
  47943. * Defines the anisotropic parameters for the material.
  47944. */
  47945. readonly anisotropy: PBRAnisotropicConfiguration;
  47946. /**
  47947. * Defines the BRDF parameters for the material.
  47948. */
  47949. readonly brdf: PBRBRDFConfiguration;
  47950. /**
  47951. * Defines the Sheen parameters for the material.
  47952. */
  47953. readonly sheen: PBRSheenConfiguration;
  47954. /**
  47955. * Defines the SubSurface parameters for the material.
  47956. */
  47957. readonly subSurface: PBRSubSurfaceConfiguration;
  47958. /**
  47959. * Custom callback helping to override the default shader used in the material.
  47960. */
  47961. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47962. /**
  47963. * Instantiates a new PBRMaterial instance.
  47964. *
  47965. * @param name The material name
  47966. * @param scene The scene the material will be use in.
  47967. */
  47968. constructor(name: string, scene: Scene);
  47969. /**
  47970. * Gets a boolean indicating that current material needs to register RTT
  47971. */
  47972. readonly hasRenderTargetTextures: boolean;
  47973. /**
  47974. * Gets the name of the material class.
  47975. */
  47976. getClassName(): string;
  47977. /**
  47978. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47979. */
  47980. /**
  47981. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47982. */
  47983. useLogarithmicDepth: boolean;
  47984. /**
  47985. * Gets the current transparency mode.
  47986. */
  47987. /**
  47988. * Sets the transparency mode of the material.
  47989. *
  47990. * | Value | Type | Description |
  47991. * | ----- | ----------------------------------- | ----------- |
  47992. * | 0 | OPAQUE | |
  47993. * | 1 | ALPHATEST | |
  47994. * | 2 | ALPHABLEND | |
  47995. * | 3 | ALPHATESTANDBLEND | |
  47996. *
  47997. */
  47998. transparencyMode: Nullable<number>;
  47999. /**
  48000. * Returns true if alpha blending should be disabled.
  48001. */
  48002. private readonly _disableAlphaBlending;
  48003. /**
  48004. * Specifies whether or not this material should be rendered in alpha blend mode.
  48005. */
  48006. needAlphaBlending(): boolean;
  48007. /**
  48008. * Specifies if the mesh will require alpha blending.
  48009. * @param mesh - BJS mesh.
  48010. */
  48011. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48012. /**
  48013. * Specifies whether or not this material should be rendered in alpha test mode.
  48014. */
  48015. needAlphaTesting(): boolean;
  48016. /**
  48017. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48018. */
  48019. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48020. /**
  48021. * Gets the texture used for the alpha test.
  48022. */
  48023. getAlphaTestTexture(): Nullable<BaseTexture>;
  48024. /**
  48025. * Specifies that the submesh is ready to be used.
  48026. * @param mesh - BJS mesh.
  48027. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48028. * @param useInstances - Specifies that instances should be used.
  48029. * @returns - boolean indicating that the submesh is ready or not.
  48030. */
  48031. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48032. /**
  48033. * Specifies if the material uses metallic roughness workflow.
  48034. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48035. */
  48036. isMetallicWorkflow(): boolean;
  48037. private _prepareEffect;
  48038. private _prepareDefines;
  48039. /**
  48040. * Force shader compilation
  48041. */
  48042. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48043. clipPlane: boolean;
  48044. }>): void;
  48045. /**
  48046. * Initializes the uniform buffer layout for the shader.
  48047. */
  48048. buildUniformLayout(): void;
  48049. /**
  48050. * Unbinds the material from the mesh
  48051. */
  48052. unbind(): void;
  48053. /**
  48054. * Binds the submesh data.
  48055. * @param world - The world matrix.
  48056. * @param mesh - The BJS mesh.
  48057. * @param subMesh - A submesh of the BJS mesh.
  48058. */
  48059. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48060. /**
  48061. * Returns the animatable textures.
  48062. * @returns - Array of animatable textures.
  48063. */
  48064. getAnimatables(): IAnimatable[];
  48065. /**
  48066. * Returns the texture used for reflections.
  48067. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48068. */
  48069. private _getReflectionTexture;
  48070. /**
  48071. * Returns an array of the actively used textures.
  48072. * @returns - Array of BaseTextures
  48073. */
  48074. getActiveTextures(): BaseTexture[];
  48075. /**
  48076. * Checks to see if a texture is used in the material.
  48077. * @param texture - Base texture to use.
  48078. * @returns - Boolean specifying if a texture is used in the material.
  48079. */
  48080. hasTexture(texture: BaseTexture): boolean;
  48081. /**
  48082. * Disposes the resources of the material.
  48083. * @param forceDisposeEffect - Forces the disposal of effects.
  48084. * @param forceDisposeTextures - Forces the disposal of all textures.
  48085. */
  48086. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48087. }
  48088. }
  48089. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48090. import { Nullable } from "babylonjs/types";
  48091. import { Scene } from "babylonjs/scene";
  48092. import { Color3 } from "babylonjs/Maths/math";
  48093. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48094. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48096. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48097. /**
  48098. * The Physically based material of BJS.
  48099. *
  48100. * This offers the main features of a standard PBR material.
  48101. * For more information, please refer to the documentation :
  48102. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48103. */
  48104. export class PBRMaterial extends PBRBaseMaterial {
  48105. /**
  48106. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48107. */
  48108. static readonly PBRMATERIAL_OPAQUE: number;
  48109. /**
  48110. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48111. */
  48112. static readonly PBRMATERIAL_ALPHATEST: number;
  48113. /**
  48114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48115. */
  48116. static readonly PBRMATERIAL_ALPHABLEND: number;
  48117. /**
  48118. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48119. * They are also discarded below the alpha cutoff threshold to improve performances.
  48120. */
  48121. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48122. /**
  48123. * Defines the default value of how much AO map is occluding the analytical lights
  48124. * (point spot...).
  48125. */
  48126. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48127. /**
  48128. * Intensity of the direct lights e.g. the four lights available in your scene.
  48129. * This impacts both the direct diffuse and specular highlights.
  48130. */
  48131. directIntensity: number;
  48132. /**
  48133. * Intensity of the emissive part of the material.
  48134. * This helps controlling the emissive effect without modifying the emissive color.
  48135. */
  48136. emissiveIntensity: number;
  48137. /**
  48138. * Intensity of the environment e.g. how much the environment will light the object
  48139. * either through harmonics for rough material or through the refelction for shiny ones.
  48140. */
  48141. environmentIntensity: number;
  48142. /**
  48143. * This is a special control allowing the reduction of the specular highlights coming from the
  48144. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48145. */
  48146. specularIntensity: number;
  48147. /**
  48148. * Debug Control allowing disabling the bump map on this material.
  48149. */
  48150. disableBumpMap: boolean;
  48151. /**
  48152. * AKA Diffuse Texture in standard nomenclature.
  48153. */
  48154. albedoTexture: BaseTexture;
  48155. /**
  48156. * AKA Occlusion Texture in other nomenclature.
  48157. */
  48158. ambientTexture: BaseTexture;
  48159. /**
  48160. * AKA Occlusion Texture Intensity in other nomenclature.
  48161. */
  48162. ambientTextureStrength: number;
  48163. /**
  48164. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48165. * 1 means it completely occludes it
  48166. * 0 mean it has no impact
  48167. */
  48168. ambientTextureImpactOnAnalyticalLights: number;
  48169. /**
  48170. * Stores the alpha values in a texture.
  48171. */
  48172. opacityTexture: BaseTexture;
  48173. /**
  48174. * Stores the reflection values in a texture.
  48175. */
  48176. reflectionTexture: Nullable<BaseTexture>;
  48177. /**
  48178. * Stores the emissive values in a texture.
  48179. */
  48180. emissiveTexture: BaseTexture;
  48181. /**
  48182. * AKA Specular texture in other nomenclature.
  48183. */
  48184. reflectivityTexture: BaseTexture;
  48185. /**
  48186. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48187. */
  48188. metallicTexture: BaseTexture;
  48189. /**
  48190. * Specifies the metallic scalar of the metallic/roughness workflow.
  48191. * Can also be used to scale the metalness values of the metallic texture.
  48192. */
  48193. metallic: Nullable<number>;
  48194. /**
  48195. * Specifies the roughness scalar of the metallic/roughness workflow.
  48196. * Can also be used to scale the roughness values of the metallic texture.
  48197. */
  48198. roughness: Nullable<number>;
  48199. /**
  48200. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48201. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48202. */
  48203. microSurfaceTexture: BaseTexture;
  48204. /**
  48205. * Stores surface normal data used to displace a mesh in a texture.
  48206. */
  48207. bumpTexture: BaseTexture;
  48208. /**
  48209. * Stores the pre-calculated light information of a mesh in a texture.
  48210. */
  48211. lightmapTexture: BaseTexture;
  48212. /**
  48213. * Stores the refracted light information in a texture.
  48214. */
  48215. refractionTexture: Nullable<BaseTexture>;
  48216. /**
  48217. * The color of a material in ambient lighting.
  48218. */
  48219. ambientColor: Color3;
  48220. /**
  48221. * AKA Diffuse Color in other nomenclature.
  48222. */
  48223. albedoColor: Color3;
  48224. /**
  48225. * AKA Specular Color in other nomenclature.
  48226. */
  48227. reflectivityColor: Color3;
  48228. /**
  48229. * The color reflected from the material.
  48230. */
  48231. reflectionColor: Color3;
  48232. /**
  48233. * The color emitted from the material.
  48234. */
  48235. emissiveColor: Color3;
  48236. /**
  48237. * AKA Glossiness in other nomenclature.
  48238. */
  48239. microSurface: number;
  48240. /**
  48241. * source material index of refraction (IOR)' / 'destination material IOR.
  48242. */
  48243. indexOfRefraction: number;
  48244. /**
  48245. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48246. */
  48247. invertRefractionY: boolean;
  48248. /**
  48249. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48250. * Materials half opaque for instance using refraction could benefit from this control.
  48251. */
  48252. linkRefractionWithTransparency: boolean;
  48253. /**
  48254. * If true, the light map contains occlusion information instead of lighting info.
  48255. */
  48256. useLightmapAsShadowmap: boolean;
  48257. /**
  48258. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48259. */
  48260. useAlphaFromAlbedoTexture: boolean;
  48261. /**
  48262. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48263. */
  48264. forceAlphaTest: boolean;
  48265. /**
  48266. * Defines the alpha limits in alpha test mode.
  48267. */
  48268. alphaCutOff: number;
  48269. /**
  48270. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48271. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48272. */
  48273. useSpecularOverAlpha: boolean;
  48274. /**
  48275. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48276. */
  48277. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48278. /**
  48279. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48280. */
  48281. useRoughnessFromMetallicTextureAlpha: boolean;
  48282. /**
  48283. * Specifies if the metallic texture contains the roughness information in its green channel.
  48284. */
  48285. useRoughnessFromMetallicTextureGreen: boolean;
  48286. /**
  48287. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48288. */
  48289. useMetallnessFromMetallicTextureBlue: boolean;
  48290. /**
  48291. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48292. */
  48293. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48294. /**
  48295. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48296. */
  48297. useAmbientInGrayScale: boolean;
  48298. /**
  48299. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48300. * The material will try to infer what glossiness each pixel should be.
  48301. */
  48302. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48303. /**
  48304. * BJS is using an harcoded light falloff based on a manually sets up range.
  48305. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48306. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48307. */
  48308. /**
  48309. * BJS is using an harcoded light falloff based on a manually sets up range.
  48310. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48311. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48312. */
  48313. usePhysicalLightFalloff: boolean;
  48314. /**
  48315. * In order to support the falloff compatibility with gltf, a special mode has been added
  48316. * to reproduce the gltf light falloff.
  48317. */
  48318. /**
  48319. * In order to support the falloff compatibility with gltf, a special mode has been added
  48320. * to reproduce the gltf light falloff.
  48321. */
  48322. useGLTFLightFalloff: boolean;
  48323. /**
  48324. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48325. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48326. */
  48327. useRadianceOverAlpha: boolean;
  48328. /**
  48329. * Allows using an object space normal map (instead of tangent space).
  48330. */
  48331. useObjectSpaceNormalMap: boolean;
  48332. /**
  48333. * Allows using the bump map in parallax mode.
  48334. */
  48335. useParallax: boolean;
  48336. /**
  48337. * Allows using the bump map in parallax occlusion mode.
  48338. */
  48339. useParallaxOcclusion: boolean;
  48340. /**
  48341. * Controls the scale bias of the parallax mode.
  48342. */
  48343. parallaxScaleBias: number;
  48344. /**
  48345. * If sets to true, disables all the lights affecting the material.
  48346. */
  48347. disableLighting: boolean;
  48348. /**
  48349. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48350. */
  48351. forceIrradianceInFragment: boolean;
  48352. /**
  48353. * Number of Simultaneous lights allowed on the material.
  48354. */
  48355. maxSimultaneousLights: number;
  48356. /**
  48357. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48358. */
  48359. invertNormalMapX: boolean;
  48360. /**
  48361. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48362. */
  48363. invertNormalMapY: boolean;
  48364. /**
  48365. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48366. */
  48367. twoSidedLighting: boolean;
  48368. /**
  48369. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48370. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48371. */
  48372. useAlphaFresnel: boolean;
  48373. /**
  48374. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48375. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48376. */
  48377. useLinearAlphaFresnel: boolean;
  48378. /**
  48379. * Let user defines the brdf lookup texture used for IBL.
  48380. * A default 8bit version is embedded but you could point at :
  48381. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48382. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48383. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48384. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48385. */
  48386. environmentBRDFTexture: Nullable<BaseTexture>;
  48387. /**
  48388. * Force normal to face away from face.
  48389. */
  48390. forceNormalForward: boolean;
  48391. /**
  48392. * Enables specular anti aliasing in the PBR shader.
  48393. * It will both interacts on the Geometry for analytical and IBL lighting.
  48394. * It also prefilter the roughness map based on the bump values.
  48395. */
  48396. enableSpecularAntiAliasing: boolean;
  48397. /**
  48398. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48399. * makes the reflect vector face the model (under horizon).
  48400. */
  48401. useHorizonOcclusion: boolean;
  48402. /**
  48403. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48404. * too much the area relying on ambient texture to define their ambient occlusion.
  48405. */
  48406. useRadianceOcclusion: boolean;
  48407. /**
  48408. * If set to true, no lighting calculations will be applied.
  48409. */
  48410. unlit: boolean;
  48411. /**
  48412. * Gets the image processing configuration used either in this material.
  48413. */
  48414. /**
  48415. * Sets the Default image processing configuration used either in the this material.
  48416. *
  48417. * If sets to null, the scene one is in use.
  48418. */
  48419. imageProcessingConfiguration: ImageProcessingConfiguration;
  48420. /**
  48421. * Gets wether the color curves effect is enabled.
  48422. */
  48423. /**
  48424. * Sets wether the color curves effect is enabled.
  48425. */
  48426. cameraColorCurvesEnabled: boolean;
  48427. /**
  48428. * Gets wether the color grading effect is enabled.
  48429. */
  48430. /**
  48431. * Gets wether the color grading effect is enabled.
  48432. */
  48433. cameraColorGradingEnabled: boolean;
  48434. /**
  48435. * Gets wether tonemapping is enabled or not.
  48436. */
  48437. /**
  48438. * Sets wether tonemapping is enabled or not
  48439. */
  48440. cameraToneMappingEnabled: boolean;
  48441. /**
  48442. * The camera exposure used on this material.
  48443. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48444. * This corresponds to a photographic exposure.
  48445. */
  48446. /**
  48447. * The camera exposure used on this material.
  48448. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48449. * This corresponds to a photographic exposure.
  48450. */
  48451. cameraExposure: number;
  48452. /**
  48453. * Gets The camera contrast used on this material.
  48454. */
  48455. /**
  48456. * Sets The camera contrast used on this material.
  48457. */
  48458. cameraContrast: number;
  48459. /**
  48460. * Gets the Color Grading 2D Lookup Texture.
  48461. */
  48462. /**
  48463. * Sets the Color Grading 2D Lookup Texture.
  48464. */
  48465. cameraColorGradingTexture: Nullable<BaseTexture>;
  48466. /**
  48467. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48468. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48469. * 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;
  48470. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48471. */
  48472. /**
  48473. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48474. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48475. * 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;
  48476. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48477. */
  48478. cameraColorCurves: Nullable<ColorCurves>;
  48479. /**
  48480. * Instantiates a new PBRMaterial instance.
  48481. *
  48482. * @param name The material name
  48483. * @param scene The scene the material will be use in.
  48484. */
  48485. constructor(name: string, scene: Scene);
  48486. /**
  48487. * Returns the name of this material class.
  48488. */
  48489. getClassName(): string;
  48490. /**
  48491. * Makes a duplicate of the current material.
  48492. * @param name - name to use for the new material.
  48493. */
  48494. clone(name: string): PBRMaterial;
  48495. /**
  48496. * Serializes this PBR Material.
  48497. * @returns - An object with the serialized material.
  48498. */
  48499. serialize(): any;
  48500. /**
  48501. * Parses a PBR Material from a serialized object.
  48502. * @param source - Serialized object.
  48503. * @param scene - BJS scene instance.
  48504. * @param rootUrl - url for the scene object
  48505. * @returns - PBRMaterial
  48506. */
  48507. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48508. }
  48509. }
  48510. declare module "babylonjs/Misc/dds" {
  48511. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48512. import { Engine } from "babylonjs/Engines/engine";
  48513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48514. import { Nullable } from "babylonjs/types";
  48515. import { Scene } from "babylonjs/scene";
  48516. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48517. /**
  48518. * Direct draw surface info
  48519. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48520. */
  48521. export interface DDSInfo {
  48522. /**
  48523. * Width of the texture
  48524. */
  48525. width: number;
  48526. /**
  48527. * Width of the texture
  48528. */
  48529. height: number;
  48530. /**
  48531. * Number of Mipmaps for the texture
  48532. * @see https://en.wikipedia.org/wiki/Mipmap
  48533. */
  48534. mipmapCount: number;
  48535. /**
  48536. * If the textures format is a known fourCC format
  48537. * @see https://www.fourcc.org/
  48538. */
  48539. isFourCC: boolean;
  48540. /**
  48541. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48542. */
  48543. isRGB: boolean;
  48544. /**
  48545. * If the texture is a lumincance format
  48546. */
  48547. isLuminance: boolean;
  48548. /**
  48549. * If this is a cube texture
  48550. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48551. */
  48552. isCube: boolean;
  48553. /**
  48554. * If the texture is a compressed format eg. FOURCC_DXT1
  48555. */
  48556. isCompressed: boolean;
  48557. /**
  48558. * The dxgiFormat of the texture
  48559. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48560. */
  48561. dxgiFormat: number;
  48562. /**
  48563. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48564. */
  48565. textureType: number;
  48566. /**
  48567. * Sphericle polynomial created for the dds texture
  48568. */
  48569. sphericalPolynomial?: SphericalPolynomial;
  48570. }
  48571. /**
  48572. * Class used to provide DDS decompression tools
  48573. */
  48574. export class DDSTools {
  48575. /**
  48576. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48577. */
  48578. static StoreLODInAlphaChannel: boolean;
  48579. /**
  48580. * Gets DDS information from an array buffer
  48581. * @param arrayBuffer defines the array buffer to read data from
  48582. * @returns the DDS information
  48583. */
  48584. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48585. private static _FloatView;
  48586. private static _Int32View;
  48587. private static _ToHalfFloat;
  48588. private static _FromHalfFloat;
  48589. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48590. private static _GetHalfFloatRGBAArrayBuffer;
  48591. private static _GetFloatRGBAArrayBuffer;
  48592. private static _GetFloatAsUIntRGBAArrayBuffer;
  48593. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48594. private static _GetRGBAArrayBuffer;
  48595. private static _ExtractLongWordOrder;
  48596. private static _GetRGBArrayBuffer;
  48597. private static _GetLuminanceArrayBuffer;
  48598. /**
  48599. * Uploads DDS Levels to a Babylon Texture
  48600. * @hidden
  48601. */
  48602. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48603. }
  48604. module "babylonjs/Engines/engine" {
  48605. interface Engine {
  48606. /**
  48607. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48608. * @param rootUrl defines the url where the file to load is located
  48609. * @param scene defines the current scene
  48610. * @param lodScale defines scale to apply to the mip map selection
  48611. * @param lodOffset defines offset to apply to the mip map selection
  48612. * @param onLoad defines an optional callback raised when the texture is loaded
  48613. * @param onError defines an optional callback raised if there is an issue to load the texture
  48614. * @param format defines the format of the data
  48615. * @param forcedExtension defines the extension to use to pick the right loader
  48616. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48617. * @returns the cube texture as an InternalTexture
  48618. */
  48619. 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;
  48620. }
  48621. }
  48622. }
  48623. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48624. import { Nullable } from "babylonjs/types";
  48625. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48626. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48627. /**
  48628. * Implementation of the DDS Texture Loader.
  48629. * @hidden
  48630. */
  48631. export class _DDSTextureLoader implements IInternalTextureLoader {
  48632. /**
  48633. * Defines wether the loader supports cascade loading the different faces.
  48634. */
  48635. readonly supportCascades: boolean;
  48636. /**
  48637. * This returns if the loader support the current file information.
  48638. * @param extension defines the file extension of the file being loaded
  48639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48640. * @param fallback defines the fallback internal texture if any
  48641. * @param isBase64 defines whether the texture is encoded as a base64
  48642. * @param isBuffer defines whether the texture data are stored as a buffer
  48643. * @returns true if the loader can load the specified file
  48644. */
  48645. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48646. /**
  48647. * Transform the url before loading if required.
  48648. * @param rootUrl the url of the texture
  48649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48650. * @returns the transformed texture
  48651. */
  48652. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48653. /**
  48654. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48655. * @param rootUrl the url of the texture
  48656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48657. * @returns the fallback texture
  48658. */
  48659. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48660. /**
  48661. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48662. * @param data contains the texture data
  48663. * @param texture defines the BabylonJS internal texture
  48664. * @param createPolynomials will be true if polynomials have been requested
  48665. * @param onLoad defines the callback to trigger once the texture is ready
  48666. * @param onError defines the callback to trigger in case of error
  48667. */
  48668. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48669. /**
  48670. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48671. * @param data contains the texture data
  48672. * @param texture defines the BabylonJS internal texture
  48673. * @param callback defines the method to call once ready to upload
  48674. */
  48675. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48676. }
  48677. }
  48678. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48679. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48680. /** @hidden */
  48681. export var rgbdEncodePixelShader: {
  48682. name: string;
  48683. shader: string;
  48684. };
  48685. }
  48686. declare module "babylonjs/Misc/environmentTextureTools" {
  48687. import { Nullable } from "babylonjs/types";
  48688. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48689. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48690. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48691. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48692. import "babylonjs/Shaders/rgbdEncode.fragment";
  48693. import "babylonjs/Shaders/rgbdDecode.fragment";
  48694. /**
  48695. * Raw texture data and descriptor sufficient for WebGL texture upload
  48696. */
  48697. export interface EnvironmentTextureInfo {
  48698. /**
  48699. * Version of the environment map
  48700. */
  48701. version: number;
  48702. /**
  48703. * Width of image
  48704. */
  48705. width: number;
  48706. /**
  48707. * Irradiance information stored in the file.
  48708. */
  48709. irradiance: any;
  48710. /**
  48711. * Specular information stored in the file.
  48712. */
  48713. specular: any;
  48714. }
  48715. /**
  48716. * Sets of helpers addressing the serialization and deserialization of environment texture
  48717. * stored in a BabylonJS env file.
  48718. * Those files are usually stored as .env files.
  48719. */
  48720. export class EnvironmentTextureTools {
  48721. /**
  48722. * Magic number identifying the env file.
  48723. */
  48724. private static _MagicBytes;
  48725. /**
  48726. * Gets the environment info from an env file.
  48727. * @param data The array buffer containing the .env bytes.
  48728. * @returns the environment file info (the json header) if successfully parsed.
  48729. */
  48730. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48731. /**
  48732. * Creates an environment texture from a loaded cube texture.
  48733. * @param texture defines the cube texture to convert in env file
  48734. * @return a promise containing the environment data if succesfull.
  48735. */
  48736. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48737. /**
  48738. * Creates a JSON representation of the spherical data.
  48739. * @param texture defines the texture containing the polynomials
  48740. * @return the JSON representation of the spherical info
  48741. */
  48742. private static _CreateEnvTextureIrradiance;
  48743. /**
  48744. * Uploads the texture info contained in the env file to the GPU.
  48745. * @param texture defines the internal texture to upload to
  48746. * @param arrayBuffer defines the buffer cotaining the data to load
  48747. * @param info defines the texture info retrieved through the GetEnvInfo method
  48748. * @returns a promise
  48749. */
  48750. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48751. /**
  48752. * Uploads the levels of image data to the GPU.
  48753. * @param texture defines the internal texture to upload to
  48754. * @param imageData defines the array buffer views of image data [mipmap][face]
  48755. * @returns a promise
  48756. */
  48757. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48758. /**
  48759. * Uploads spherical polynomials information to the texture.
  48760. * @param texture defines the texture we are trying to upload the information to
  48761. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48762. */
  48763. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48764. /** @hidden */
  48765. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48766. }
  48767. }
  48768. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48769. import { Nullable } from "babylonjs/types";
  48770. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48771. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48772. /**
  48773. * Implementation of the ENV Texture Loader.
  48774. * @hidden
  48775. */
  48776. export class _ENVTextureLoader implements IInternalTextureLoader {
  48777. /**
  48778. * Defines wether the loader supports cascade loading the different faces.
  48779. */
  48780. readonly supportCascades: boolean;
  48781. /**
  48782. * This returns if the loader support the current file information.
  48783. * @param extension defines the file extension of the file being loaded
  48784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48785. * @param fallback defines the fallback internal texture if any
  48786. * @param isBase64 defines whether the texture is encoded as a base64
  48787. * @param isBuffer defines whether the texture data are stored as a buffer
  48788. * @returns true if the loader can load the specified file
  48789. */
  48790. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48791. /**
  48792. * Transform the url before loading if required.
  48793. * @param rootUrl the url of the texture
  48794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48795. * @returns the transformed texture
  48796. */
  48797. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48798. /**
  48799. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48800. * @param rootUrl the url of the texture
  48801. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48802. * @returns the fallback texture
  48803. */
  48804. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48805. /**
  48806. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48807. * @param data contains the texture data
  48808. * @param texture defines the BabylonJS internal texture
  48809. * @param createPolynomials will be true if polynomials have been requested
  48810. * @param onLoad defines the callback to trigger once the texture is ready
  48811. * @param onError defines the callback to trigger in case of error
  48812. */
  48813. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48814. /**
  48815. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48816. * @param data contains the texture data
  48817. * @param texture defines the BabylonJS internal texture
  48818. * @param callback defines the method to call once ready to upload
  48819. */
  48820. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48821. }
  48822. }
  48823. declare module "babylonjs/Misc/khronosTextureContainer" {
  48824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48825. /**
  48826. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48827. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48828. */
  48829. export class KhronosTextureContainer {
  48830. /** contents of the KTX container file */
  48831. arrayBuffer: any;
  48832. private static HEADER_LEN;
  48833. private static COMPRESSED_2D;
  48834. private static COMPRESSED_3D;
  48835. private static TEX_2D;
  48836. private static TEX_3D;
  48837. /**
  48838. * Gets the openGL type
  48839. */
  48840. glType: number;
  48841. /**
  48842. * Gets the openGL type size
  48843. */
  48844. glTypeSize: number;
  48845. /**
  48846. * Gets the openGL format
  48847. */
  48848. glFormat: number;
  48849. /**
  48850. * Gets the openGL internal format
  48851. */
  48852. glInternalFormat: number;
  48853. /**
  48854. * Gets the base internal format
  48855. */
  48856. glBaseInternalFormat: number;
  48857. /**
  48858. * Gets image width in pixel
  48859. */
  48860. pixelWidth: number;
  48861. /**
  48862. * Gets image height in pixel
  48863. */
  48864. pixelHeight: number;
  48865. /**
  48866. * Gets image depth in pixels
  48867. */
  48868. pixelDepth: number;
  48869. /**
  48870. * Gets the number of array elements
  48871. */
  48872. numberOfArrayElements: number;
  48873. /**
  48874. * Gets the number of faces
  48875. */
  48876. numberOfFaces: number;
  48877. /**
  48878. * Gets the number of mipmap levels
  48879. */
  48880. numberOfMipmapLevels: number;
  48881. /**
  48882. * Gets the bytes of key value data
  48883. */
  48884. bytesOfKeyValueData: number;
  48885. /**
  48886. * Gets the load type
  48887. */
  48888. loadType: number;
  48889. /**
  48890. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48891. */
  48892. isInvalid: boolean;
  48893. /**
  48894. * Creates a new KhronosTextureContainer
  48895. * @param arrayBuffer contents of the KTX container file
  48896. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48897. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48898. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48899. */
  48900. constructor(
  48901. /** contents of the KTX container file */
  48902. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48903. /**
  48904. * Uploads KTX content to a Babylon Texture.
  48905. * It is assumed that the texture has already been created & is currently bound
  48906. * @hidden
  48907. */
  48908. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48909. private _upload2DCompressedLevels;
  48910. }
  48911. }
  48912. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48913. import { Nullable } from "babylonjs/types";
  48914. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48915. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48916. /**
  48917. * Implementation of the KTX Texture Loader.
  48918. * @hidden
  48919. */
  48920. export class _KTXTextureLoader implements IInternalTextureLoader {
  48921. /**
  48922. * Defines wether the loader supports cascade loading the different faces.
  48923. */
  48924. readonly supportCascades: boolean;
  48925. /**
  48926. * This returns if the loader support the current file information.
  48927. * @param extension defines the file extension of the file being loaded
  48928. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48929. * @param fallback defines the fallback internal texture if any
  48930. * @param isBase64 defines whether the texture is encoded as a base64
  48931. * @param isBuffer defines whether the texture data are stored as a buffer
  48932. * @returns true if the loader can load the specified file
  48933. */
  48934. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48935. /**
  48936. * Transform the url before loading if required.
  48937. * @param rootUrl the url of the texture
  48938. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48939. * @returns the transformed texture
  48940. */
  48941. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48942. /**
  48943. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48944. * @param rootUrl the url of the texture
  48945. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48946. * @returns the fallback texture
  48947. */
  48948. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48949. /**
  48950. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48951. * @param data contains the texture data
  48952. * @param texture defines the BabylonJS internal texture
  48953. * @param createPolynomials will be true if polynomials have been requested
  48954. * @param onLoad defines the callback to trigger once the texture is ready
  48955. * @param onError defines the callback to trigger in case of error
  48956. */
  48957. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48958. /**
  48959. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48960. * @param data contains the texture data
  48961. * @param texture defines the BabylonJS internal texture
  48962. * @param callback defines the method to call once ready to upload
  48963. */
  48964. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48965. }
  48966. }
  48967. declare module "babylonjs/Helpers/sceneHelpers" {
  48968. import { Nullable } from "babylonjs/types";
  48969. import { Mesh } from "babylonjs/Meshes/mesh";
  48970. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48971. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48972. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48973. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48974. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48975. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48976. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48977. import "babylonjs/Meshes/Builders/boxBuilder";
  48978. /** @hidden */
  48979. export var _forceSceneHelpersToBundle: boolean;
  48980. module "babylonjs/scene" {
  48981. interface Scene {
  48982. /**
  48983. * Creates a default light for the scene.
  48984. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48985. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48986. */
  48987. createDefaultLight(replace?: boolean): void;
  48988. /**
  48989. * Creates a default camera for the scene.
  48990. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48991. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48992. * @param replace has default false, when true replaces the active camera in the scene
  48993. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48994. */
  48995. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48996. /**
  48997. * Creates a default camera and a default light.
  48998. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48999. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49000. * @param replace has the default false, when true replaces the active camera/light in the scene
  49001. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49002. */
  49003. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49004. /**
  49005. * Creates a new sky box
  49006. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49007. * @param environmentTexture defines the texture to use as environment texture
  49008. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49009. * @param scale defines the overall scale of the skybox
  49010. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49011. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49012. * @returns a new mesh holding the sky box
  49013. */
  49014. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49015. /**
  49016. * Creates a new environment
  49017. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49018. * @param options defines the options you can use to configure the environment
  49019. * @returns the new EnvironmentHelper
  49020. */
  49021. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49022. /**
  49023. * Creates a new VREXperienceHelper
  49024. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49025. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49026. * @returns a new VREXperienceHelper
  49027. */
  49028. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49029. /**
  49030. * Creates a new XREXperienceHelper
  49031. * @see http://doc.babylonjs.com/how_to/webxr
  49032. * @returns a promise for a new XREXperienceHelper
  49033. */
  49034. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  49035. }
  49036. }
  49037. }
  49038. declare module "babylonjs/Helpers/videoDome" {
  49039. import { Scene } from "babylonjs/scene";
  49040. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49041. import { Mesh } from "babylonjs/Meshes/mesh";
  49042. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49043. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49044. import "babylonjs/Meshes/Builders/sphereBuilder";
  49045. /**
  49046. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49047. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49048. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49049. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49050. */
  49051. export class VideoDome extends TransformNode {
  49052. /**
  49053. * Define the video source as a Monoscopic panoramic 360 video.
  49054. */
  49055. static readonly MODE_MONOSCOPIC: number;
  49056. /**
  49057. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49058. */
  49059. static readonly MODE_TOPBOTTOM: number;
  49060. /**
  49061. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49062. */
  49063. static readonly MODE_SIDEBYSIDE: number;
  49064. private _useDirectMapping;
  49065. /**
  49066. * The video texture being displayed on the sphere
  49067. */
  49068. protected _videoTexture: VideoTexture;
  49069. /**
  49070. * Gets the video texture being displayed on the sphere
  49071. */
  49072. readonly videoTexture: VideoTexture;
  49073. /**
  49074. * The skybox material
  49075. */
  49076. protected _material: BackgroundMaterial;
  49077. /**
  49078. * The surface used for the skybox
  49079. */
  49080. protected _mesh: Mesh;
  49081. /**
  49082. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49083. * Also see the options.resolution property.
  49084. */
  49085. fovMultiplier: number;
  49086. private _videoMode;
  49087. /**
  49088. * Gets or set the current video mode for the video. It can be:
  49089. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49090. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49091. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49092. */
  49093. videoMode: number;
  49094. /**
  49095. * Oberserver used in Stereoscopic VR Mode.
  49096. */
  49097. private _onBeforeCameraRenderObserver;
  49098. /**
  49099. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49100. * @param name Element's name, child elements will append suffixes for their own names.
  49101. * @param urlsOrVideo defines the url(s) or the video element to use
  49102. * @param options An object containing optional or exposed sub element properties
  49103. */
  49104. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49105. resolution?: number;
  49106. clickToPlay?: boolean;
  49107. autoPlay?: boolean;
  49108. loop?: boolean;
  49109. size?: number;
  49110. poster?: string;
  49111. faceForward?: boolean;
  49112. useDirectMapping?: boolean;
  49113. }, scene: Scene);
  49114. private _changeVideoMode;
  49115. /**
  49116. * Releases resources associated with this node.
  49117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49119. */
  49120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49121. }
  49122. }
  49123. declare module "babylonjs/Helpers/index" {
  49124. export * from "babylonjs/Helpers/environmentHelper";
  49125. export * from "babylonjs/Helpers/photoDome";
  49126. export * from "babylonjs/Helpers/sceneHelpers";
  49127. export * from "babylonjs/Helpers/videoDome";
  49128. }
  49129. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49130. import { PerfCounter } from "babylonjs/Misc/tools";
  49131. import { IDisposable } from "babylonjs/scene";
  49132. import { Engine } from "babylonjs/Engines/engine";
  49133. /**
  49134. * This class can be used to get instrumentation data from a Babylon engine
  49135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49136. */
  49137. export class EngineInstrumentation implements IDisposable {
  49138. /**
  49139. * Define the instrumented engine.
  49140. */
  49141. engine: Engine;
  49142. private _captureGPUFrameTime;
  49143. private _gpuFrameTimeToken;
  49144. private _gpuFrameTime;
  49145. private _captureShaderCompilationTime;
  49146. private _shaderCompilationTime;
  49147. private _onBeginFrameObserver;
  49148. private _onEndFrameObserver;
  49149. private _onBeforeShaderCompilationObserver;
  49150. private _onAfterShaderCompilationObserver;
  49151. /**
  49152. * Gets the perf counter used for GPU frame time
  49153. */
  49154. readonly gpuFrameTimeCounter: PerfCounter;
  49155. /**
  49156. * Gets the GPU frame time capture status
  49157. */
  49158. /**
  49159. * Enable or disable the GPU frame time capture
  49160. */
  49161. captureGPUFrameTime: boolean;
  49162. /**
  49163. * Gets the perf counter used for shader compilation time
  49164. */
  49165. readonly shaderCompilationTimeCounter: PerfCounter;
  49166. /**
  49167. * Gets the shader compilation time capture status
  49168. */
  49169. /**
  49170. * Enable or disable the shader compilation time capture
  49171. */
  49172. captureShaderCompilationTime: boolean;
  49173. /**
  49174. * Instantiates a new engine instrumentation.
  49175. * This class can be used to get instrumentation data from a Babylon engine
  49176. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49177. * @param engine Defines the engine to instrument
  49178. */
  49179. constructor(
  49180. /**
  49181. * Define the instrumented engine.
  49182. */
  49183. engine: Engine);
  49184. /**
  49185. * Dispose and release associated resources.
  49186. */
  49187. dispose(): void;
  49188. }
  49189. }
  49190. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49191. import { PerfCounter } from "babylonjs/Misc/tools";
  49192. import { Scene, IDisposable } from "babylonjs/scene";
  49193. /**
  49194. * This class can be used to get instrumentation data from a Babylon engine
  49195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49196. */
  49197. export class SceneInstrumentation implements IDisposable {
  49198. /**
  49199. * Defines the scene to instrument
  49200. */
  49201. scene: Scene;
  49202. private _captureActiveMeshesEvaluationTime;
  49203. private _activeMeshesEvaluationTime;
  49204. private _captureRenderTargetsRenderTime;
  49205. private _renderTargetsRenderTime;
  49206. private _captureFrameTime;
  49207. private _frameTime;
  49208. private _captureRenderTime;
  49209. private _renderTime;
  49210. private _captureInterFrameTime;
  49211. private _interFrameTime;
  49212. private _captureParticlesRenderTime;
  49213. private _particlesRenderTime;
  49214. private _captureSpritesRenderTime;
  49215. private _spritesRenderTime;
  49216. private _capturePhysicsTime;
  49217. private _physicsTime;
  49218. private _captureAnimationsTime;
  49219. private _animationsTime;
  49220. private _captureCameraRenderTime;
  49221. private _cameraRenderTime;
  49222. private _onBeforeActiveMeshesEvaluationObserver;
  49223. private _onAfterActiveMeshesEvaluationObserver;
  49224. private _onBeforeRenderTargetsRenderObserver;
  49225. private _onAfterRenderTargetsRenderObserver;
  49226. private _onAfterRenderObserver;
  49227. private _onBeforeDrawPhaseObserver;
  49228. private _onAfterDrawPhaseObserver;
  49229. private _onBeforeAnimationsObserver;
  49230. private _onBeforeParticlesRenderingObserver;
  49231. private _onAfterParticlesRenderingObserver;
  49232. private _onBeforeSpritesRenderingObserver;
  49233. private _onAfterSpritesRenderingObserver;
  49234. private _onBeforePhysicsObserver;
  49235. private _onAfterPhysicsObserver;
  49236. private _onAfterAnimationsObserver;
  49237. private _onBeforeCameraRenderObserver;
  49238. private _onAfterCameraRenderObserver;
  49239. /**
  49240. * Gets the perf counter used for active meshes evaluation time
  49241. */
  49242. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49243. /**
  49244. * Gets the active meshes evaluation time capture status
  49245. */
  49246. /**
  49247. * Enable or disable the active meshes evaluation time capture
  49248. */
  49249. captureActiveMeshesEvaluationTime: boolean;
  49250. /**
  49251. * Gets the perf counter used for render targets render time
  49252. */
  49253. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49254. /**
  49255. * Gets the render targets render time capture status
  49256. */
  49257. /**
  49258. * Enable or disable the render targets render time capture
  49259. */
  49260. captureRenderTargetsRenderTime: boolean;
  49261. /**
  49262. * Gets the perf counter used for particles render time
  49263. */
  49264. readonly particlesRenderTimeCounter: PerfCounter;
  49265. /**
  49266. * Gets the particles render time capture status
  49267. */
  49268. /**
  49269. * Enable or disable the particles render time capture
  49270. */
  49271. captureParticlesRenderTime: boolean;
  49272. /**
  49273. * Gets the perf counter used for sprites render time
  49274. */
  49275. readonly spritesRenderTimeCounter: PerfCounter;
  49276. /**
  49277. * Gets the sprites render time capture status
  49278. */
  49279. /**
  49280. * Enable or disable the sprites render time capture
  49281. */
  49282. captureSpritesRenderTime: boolean;
  49283. /**
  49284. * Gets the perf counter used for physics time
  49285. */
  49286. readonly physicsTimeCounter: PerfCounter;
  49287. /**
  49288. * Gets the physics time capture status
  49289. */
  49290. /**
  49291. * Enable or disable the physics time capture
  49292. */
  49293. capturePhysicsTime: boolean;
  49294. /**
  49295. * Gets the perf counter used for animations time
  49296. */
  49297. readonly animationsTimeCounter: PerfCounter;
  49298. /**
  49299. * Gets the animations time capture status
  49300. */
  49301. /**
  49302. * Enable or disable the animations time capture
  49303. */
  49304. captureAnimationsTime: boolean;
  49305. /**
  49306. * Gets the perf counter used for frame time capture
  49307. */
  49308. readonly frameTimeCounter: PerfCounter;
  49309. /**
  49310. * Gets the frame time capture status
  49311. */
  49312. /**
  49313. * Enable or disable the frame time capture
  49314. */
  49315. captureFrameTime: boolean;
  49316. /**
  49317. * Gets the perf counter used for inter-frames time capture
  49318. */
  49319. readonly interFrameTimeCounter: PerfCounter;
  49320. /**
  49321. * Gets the inter-frames time capture status
  49322. */
  49323. /**
  49324. * Enable or disable the inter-frames time capture
  49325. */
  49326. captureInterFrameTime: boolean;
  49327. /**
  49328. * Gets the perf counter used for render time capture
  49329. */
  49330. readonly renderTimeCounter: PerfCounter;
  49331. /**
  49332. * Gets the render time capture status
  49333. */
  49334. /**
  49335. * Enable or disable the render time capture
  49336. */
  49337. captureRenderTime: boolean;
  49338. /**
  49339. * Gets the perf counter used for camera render time capture
  49340. */
  49341. readonly cameraRenderTimeCounter: PerfCounter;
  49342. /**
  49343. * Gets the camera render time capture status
  49344. */
  49345. /**
  49346. * Enable or disable the camera render time capture
  49347. */
  49348. captureCameraRenderTime: boolean;
  49349. /**
  49350. * Gets the perf counter used for draw calls
  49351. */
  49352. readonly drawCallsCounter: PerfCounter;
  49353. /**
  49354. * Instantiates a new scene instrumentation.
  49355. * This class can be used to get instrumentation data from a Babylon engine
  49356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49357. * @param scene Defines the scene to instrument
  49358. */
  49359. constructor(
  49360. /**
  49361. * Defines the scene to instrument
  49362. */
  49363. scene: Scene);
  49364. /**
  49365. * Dispose and release associated resources.
  49366. */
  49367. dispose(): void;
  49368. }
  49369. }
  49370. declare module "babylonjs/Instrumentation/index" {
  49371. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49372. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49373. export * from "babylonjs/Instrumentation/timeToken";
  49374. }
  49375. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49376. /** @hidden */
  49377. export var glowMapGenerationPixelShader: {
  49378. name: string;
  49379. shader: string;
  49380. };
  49381. }
  49382. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49383. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49384. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49386. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49388. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49389. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49390. /** @hidden */
  49391. export var glowMapGenerationVertexShader: {
  49392. name: string;
  49393. shader: string;
  49394. };
  49395. }
  49396. declare module "babylonjs/Layers/effectLayer" {
  49397. import { Observable } from "babylonjs/Misc/observable";
  49398. import { Nullable } from "babylonjs/types";
  49399. import { Camera } from "babylonjs/Cameras/camera";
  49400. import { Scene } from "babylonjs/scene";
  49401. import { Color4, ISize } from "babylonjs/Maths/math";
  49402. import { Engine } from "babylonjs/Engines/engine";
  49403. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49405. import { Mesh } from "babylonjs/Meshes/mesh";
  49406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49408. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49409. import { Effect } from "babylonjs/Materials/effect";
  49410. import { Material } from "babylonjs/Materials/material";
  49411. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49412. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49413. /**
  49414. * Effect layer options. This helps customizing the behaviour
  49415. * of the effect layer.
  49416. */
  49417. export interface IEffectLayerOptions {
  49418. /**
  49419. * Multiplication factor apply to the canvas size to compute the render target size
  49420. * used to generated the objects (the smaller the faster).
  49421. */
  49422. mainTextureRatio: number;
  49423. /**
  49424. * Enforces a fixed size texture to ensure effect stability across devices.
  49425. */
  49426. mainTextureFixedSize?: number;
  49427. /**
  49428. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49429. */
  49430. alphaBlendingMode: number;
  49431. /**
  49432. * The camera attached to the layer.
  49433. */
  49434. camera: Nullable<Camera>;
  49435. /**
  49436. * The rendering group to draw the layer in.
  49437. */
  49438. renderingGroupId: number;
  49439. }
  49440. /**
  49441. * The effect layer Helps adding post process effect blended with the main pass.
  49442. *
  49443. * This can be for instance use to generate glow or higlight effects on the scene.
  49444. *
  49445. * The effect layer class can not be used directly and is intented to inherited from to be
  49446. * customized per effects.
  49447. */
  49448. export abstract class EffectLayer {
  49449. private _vertexBuffers;
  49450. private _indexBuffer;
  49451. private _cachedDefines;
  49452. private _effectLayerMapGenerationEffect;
  49453. private _effectLayerOptions;
  49454. private _mergeEffect;
  49455. protected _scene: Scene;
  49456. protected _engine: Engine;
  49457. protected _maxSize: number;
  49458. protected _mainTextureDesiredSize: ISize;
  49459. protected _mainTexture: RenderTargetTexture;
  49460. protected _shouldRender: boolean;
  49461. protected _postProcesses: PostProcess[];
  49462. protected _textures: BaseTexture[];
  49463. protected _emissiveTextureAndColor: {
  49464. texture: Nullable<BaseTexture>;
  49465. color: Color4;
  49466. };
  49467. /**
  49468. * The name of the layer
  49469. */
  49470. name: string;
  49471. /**
  49472. * The clear color of the texture used to generate the glow map.
  49473. */
  49474. neutralColor: Color4;
  49475. /**
  49476. * Specifies wether the highlight layer is enabled or not.
  49477. */
  49478. isEnabled: boolean;
  49479. /**
  49480. * Gets the camera attached to the layer.
  49481. */
  49482. readonly camera: Nullable<Camera>;
  49483. /**
  49484. * Gets the rendering group id the layer should render in.
  49485. */
  49486. readonly renderingGroupId: number;
  49487. /**
  49488. * An event triggered when the effect layer has been disposed.
  49489. */
  49490. onDisposeObservable: Observable<EffectLayer>;
  49491. /**
  49492. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49493. */
  49494. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49495. /**
  49496. * An event triggered when the generated texture is being merged in the scene.
  49497. */
  49498. onBeforeComposeObservable: Observable<EffectLayer>;
  49499. /**
  49500. * An event triggered when the generated texture has been merged in the scene.
  49501. */
  49502. onAfterComposeObservable: Observable<EffectLayer>;
  49503. /**
  49504. * An event triggered when the efffect layer changes its size.
  49505. */
  49506. onSizeChangedObservable: Observable<EffectLayer>;
  49507. /** @hidden */
  49508. static _SceneComponentInitialization: (scene: Scene) => void;
  49509. /**
  49510. * Instantiates a new effect Layer and references it in the scene.
  49511. * @param name The name of the layer
  49512. * @param scene The scene to use the layer in
  49513. */
  49514. constructor(
  49515. /** The Friendly of the effect in the scene */
  49516. name: string, scene: Scene);
  49517. /**
  49518. * Get the effect name of the layer.
  49519. * @return The effect name
  49520. */
  49521. abstract getEffectName(): string;
  49522. /**
  49523. * Checks for the readiness of the element composing the layer.
  49524. * @param subMesh the mesh to check for
  49525. * @param useInstances specify wether or not to use instances to render the mesh
  49526. * @return true if ready otherwise, false
  49527. */
  49528. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49529. /**
  49530. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49531. * @returns true if the effect requires stencil during the main canvas render pass.
  49532. */
  49533. abstract needStencil(): boolean;
  49534. /**
  49535. * Create the merge effect. This is the shader use to blit the information back
  49536. * to the main canvas at the end of the scene rendering.
  49537. * @returns The effect containing the shader used to merge the effect on the main canvas
  49538. */
  49539. protected abstract _createMergeEffect(): Effect;
  49540. /**
  49541. * Creates the render target textures and post processes used in the effect layer.
  49542. */
  49543. protected abstract _createTextureAndPostProcesses(): void;
  49544. /**
  49545. * Implementation specific of rendering the generating effect on the main canvas.
  49546. * @param effect The effect used to render through
  49547. */
  49548. protected abstract _internalRender(effect: Effect): void;
  49549. /**
  49550. * Sets the required values for both the emissive texture and and the main color.
  49551. */
  49552. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49553. /**
  49554. * Free any resources and references associated to a mesh.
  49555. * Internal use
  49556. * @param mesh The mesh to free.
  49557. */
  49558. abstract _disposeMesh(mesh: Mesh): void;
  49559. /**
  49560. * Serializes this layer (Glow or Highlight for example)
  49561. * @returns a serialized layer object
  49562. */
  49563. abstract serialize?(): any;
  49564. /**
  49565. * Initializes the effect layer with the required options.
  49566. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49567. */
  49568. protected _init(options: Partial<IEffectLayerOptions>): void;
  49569. /**
  49570. * Generates the index buffer of the full screen quad blending to the main canvas.
  49571. */
  49572. private _generateIndexBuffer;
  49573. /**
  49574. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49575. */
  49576. private _generateVertexBuffer;
  49577. /**
  49578. * Sets the main texture desired size which is the closest power of two
  49579. * of the engine canvas size.
  49580. */
  49581. private _setMainTextureSize;
  49582. /**
  49583. * Creates the main texture for the effect layer.
  49584. */
  49585. protected _createMainTexture(): void;
  49586. /**
  49587. * Adds specific effects defines.
  49588. * @param defines The defines to add specifics to.
  49589. */
  49590. protected _addCustomEffectDefines(defines: string[]): void;
  49591. /**
  49592. * Checks for the readiness of the element composing the layer.
  49593. * @param subMesh the mesh to check for
  49594. * @param useInstances specify wether or not to use instances to render the mesh
  49595. * @param emissiveTexture the associated emissive texture used to generate the glow
  49596. * @return true if ready otherwise, false
  49597. */
  49598. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49599. /**
  49600. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49601. */
  49602. render(): void;
  49603. /**
  49604. * Determine if a given mesh will be used in the current effect.
  49605. * @param mesh mesh to test
  49606. * @returns true if the mesh will be used
  49607. */
  49608. hasMesh(mesh: AbstractMesh): boolean;
  49609. /**
  49610. * Returns true if the layer contains information to display, otherwise false.
  49611. * @returns true if the glow layer should be rendered
  49612. */
  49613. shouldRender(): boolean;
  49614. /**
  49615. * Returns true if the mesh should render, otherwise false.
  49616. * @param mesh The mesh to render
  49617. * @returns true if it should render otherwise false
  49618. */
  49619. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49620. /**
  49621. * Returns true if the mesh can be rendered, otherwise false.
  49622. * @param mesh The mesh to render
  49623. * @param material The material used on the mesh
  49624. * @returns true if it can be rendered otherwise false
  49625. */
  49626. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49627. /**
  49628. * Returns true if the mesh should render, otherwise false.
  49629. * @param mesh The mesh to render
  49630. * @returns true if it should render otherwise false
  49631. */
  49632. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49633. /**
  49634. * Renders the submesh passed in parameter to the generation map.
  49635. */
  49636. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49637. /**
  49638. * Rebuild the required buffers.
  49639. * @hidden Internal use only.
  49640. */
  49641. _rebuild(): void;
  49642. /**
  49643. * Dispose only the render target textures and post process.
  49644. */
  49645. private _disposeTextureAndPostProcesses;
  49646. /**
  49647. * Dispose the highlight layer and free resources.
  49648. */
  49649. dispose(): void;
  49650. /**
  49651. * Gets the class name of the effect layer
  49652. * @returns the string with the class name of the effect layer
  49653. */
  49654. getClassName(): string;
  49655. /**
  49656. * Creates an effect layer from parsed effect layer data
  49657. * @param parsedEffectLayer defines effect layer data
  49658. * @param scene defines the current scene
  49659. * @param rootUrl defines the root URL containing the effect layer information
  49660. * @returns a parsed effect Layer
  49661. */
  49662. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49663. }
  49664. }
  49665. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49666. import { Scene } from "babylonjs/scene";
  49667. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49668. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49669. import { AbstractScene } from "babylonjs/abstractScene";
  49670. module "babylonjs/abstractScene" {
  49671. interface AbstractScene {
  49672. /**
  49673. * The list of effect layers (highlights/glow) added to the scene
  49674. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49675. * @see http://doc.babylonjs.com/how_to/glow_layer
  49676. */
  49677. effectLayers: Array<EffectLayer>;
  49678. /**
  49679. * Removes the given effect layer from this scene.
  49680. * @param toRemove defines the effect layer to remove
  49681. * @returns the index of the removed effect layer
  49682. */
  49683. removeEffectLayer(toRemove: EffectLayer): number;
  49684. /**
  49685. * Adds the given effect layer to this scene
  49686. * @param newEffectLayer defines the effect layer to add
  49687. */
  49688. addEffectLayer(newEffectLayer: EffectLayer): void;
  49689. }
  49690. }
  49691. /**
  49692. * Defines the layer scene component responsible to manage any effect layers
  49693. * in a given scene.
  49694. */
  49695. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49696. /**
  49697. * The component name helpfull to identify the component in the list of scene components.
  49698. */
  49699. readonly name: string;
  49700. /**
  49701. * The scene the component belongs to.
  49702. */
  49703. scene: Scene;
  49704. private _engine;
  49705. private _renderEffects;
  49706. private _needStencil;
  49707. private _previousStencilState;
  49708. /**
  49709. * Creates a new instance of the component for the given scene
  49710. * @param scene Defines the scene to register the component in
  49711. */
  49712. constructor(scene: Scene);
  49713. /**
  49714. * Registers the component in a given scene
  49715. */
  49716. register(): void;
  49717. /**
  49718. * Rebuilds the elements related to this component in case of
  49719. * context lost for instance.
  49720. */
  49721. rebuild(): void;
  49722. /**
  49723. * Serializes the component data to the specified json object
  49724. * @param serializationObject The object to serialize to
  49725. */
  49726. serialize(serializationObject: any): void;
  49727. /**
  49728. * Adds all the elements from the container to the scene
  49729. * @param container the container holding the elements
  49730. */
  49731. addFromContainer(container: AbstractScene): void;
  49732. /**
  49733. * Removes all the elements in the container from the scene
  49734. * @param container contains the elements to remove
  49735. * @param dispose if the removed element should be disposed (default: false)
  49736. */
  49737. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49738. /**
  49739. * Disposes the component and the associated ressources.
  49740. */
  49741. dispose(): void;
  49742. private _isReadyForMesh;
  49743. private _renderMainTexture;
  49744. private _setStencil;
  49745. private _setStencilBack;
  49746. private _draw;
  49747. private _drawCamera;
  49748. private _drawRenderingGroup;
  49749. }
  49750. }
  49751. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49752. /** @hidden */
  49753. export var glowMapMergePixelShader: {
  49754. name: string;
  49755. shader: string;
  49756. };
  49757. }
  49758. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49759. /** @hidden */
  49760. export var glowMapMergeVertexShader: {
  49761. name: string;
  49762. shader: string;
  49763. };
  49764. }
  49765. declare module "babylonjs/Layers/glowLayer" {
  49766. import { Nullable } from "babylonjs/types";
  49767. import { Camera } from "babylonjs/Cameras/camera";
  49768. import { Scene } from "babylonjs/scene";
  49769. import { Color4 } from "babylonjs/Maths/math";
  49770. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49772. import { Mesh } from "babylonjs/Meshes/mesh";
  49773. import { Texture } from "babylonjs/Materials/Textures/texture";
  49774. import { Effect } from "babylonjs/Materials/effect";
  49775. import { Material } from "babylonjs/Materials/material";
  49776. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49777. import "babylonjs/Shaders/glowMapMerge.fragment";
  49778. import "babylonjs/Shaders/glowMapMerge.vertex";
  49779. import "babylonjs/Layers/effectLayerSceneComponent";
  49780. module "babylonjs/abstractScene" {
  49781. interface AbstractScene {
  49782. /**
  49783. * Return a the first highlight layer of the scene with a given name.
  49784. * @param name The name of the highlight layer to look for.
  49785. * @return The highlight layer if found otherwise null.
  49786. */
  49787. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49788. }
  49789. }
  49790. /**
  49791. * Glow layer options. This helps customizing the behaviour
  49792. * of the glow layer.
  49793. */
  49794. export interface IGlowLayerOptions {
  49795. /**
  49796. * Multiplication factor apply to the canvas size to compute the render target size
  49797. * used to generated the glowing objects (the smaller the faster).
  49798. */
  49799. mainTextureRatio: number;
  49800. /**
  49801. * Enforces a fixed size texture to ensure resize independant blur.
  49802. */
  49803. mainTextureFixedSize?: number;
  49804. /**
  49805. * How big is the kernel of the blur texture.
  49806. */
  49807. blurKernelSize: number;
  49808. /**
  49809. * The camera attached to the layer.
  49810. */
  49811. camera: Nullable<Camera>;
  49812. /**
  49813. * Enable MSAA by chosing the number of samples.
  49814. */
  49815. mainTextureSamples?: number;
  49816. /**
  49817. * The rendering group to draw the layer in.
  49818. */
  49819. renderingGroupId: number;
  49820. }
  49821. /**
  49822. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49823. *
  49824. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49825. * glowy meshes to your scene.
  49826. *
  49827. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49828. */
  49829. export class GlowLayer extends EffectLayer {
  49830. /**
  49831. * Effect Name of the layer.
  49832. */
  49833. static readonly EffectName: string;
  49834. /**
  49835. * The default blur kernel size used for the glow.
  49836. */
  49837. static DefaultBlurKernelSize: number;
  49838. /**
  49839. * The default texture size ratio used for the glow.
  49840. */
  49841. static DefaultTextureRatio: number;
  49842. /**
  49843. * Sets the kernel size of the blur.
  49844. */
  49845. /**
  49846. * Gets the kernel size of the blur.
  49847. */
  49848. blurKernelSize: number;
  49849. /**
  49850. * Sets the glow intensity.
  49851. */
  49852. /**
  49853. * Gets the glow intensity.
  49854. */
  49855. intensity: number;
  49856. private _options;
  49857. private _intensity;
  49858. private _horizontalBlurPostprocess1;
  49859. private _verticalBlurPostprocess1;
  49860. private _horizontalBlurPostprocess2;
  49861. private _verticalBlurPostprocess2;
  49862. private _blurTexture1;
  49863. private _blurTexture2;
  49864. private _postProcesses1;
  49865. private _postProcesses2;
  49866. private _includedOnlyMeshes;
  49867. private _excludedMeshes;
  49868. /**
  49869. * Callback used to let the user override the color selection on a per mesh basis
  49870. */
  49871. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49872. /**
  49873. * Callback used to let the user override the texture selection on a per mesh basis
  49874. */
  49875. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49876. /**
  49877. * Instantiates a new glow Layer and references it to the scene.
  49878. * @param name The name of the layer
  49879. * @param scene The scene to use the layer in
  49880. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49881. */
  49882. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49883. /**
  49884. * Get the effect name of the layer.
  49885. * @return The effect name
  49886. */
  49887. getEffectName(): string;
  49888. /**
  49889. * Create the merge effect. This is the shader use to blit the information back
  49890. * to the main canvas at the end of the scene rendering.
  49891. */
  49892. protected _createMergeEffect(): Effect;
  49893. /**
  49894. * Creates the render target textures and post processes used in the glow layer.
  49895. */
  49896. protected _createTextureAndPostProcesses(): void;
  49897. /**
  49898. * Checks for the readiness of the element composing the layer.
  49899. * @param subMesh the mesh to check for
  49900. * @param useInstances specify wether or not to use instances to render the mesh
  49901. * @param emissiveTexture the associated emissive texture used to generate the glow
  49902. * @return true if ready otherwise, false
  49903. */
  49904. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49905. /**
  49906. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49907. */
  49908. needStencil(): boolean;
  49909. /**
  49910. * Returns true if the mesh can be rendered, otherwise false.
  49911. * @param mesh The mesh to render
  49912. * @param material The material used on the mesh
  49913. * @returns true if it can be rendered otherwise false
  49914. */
  49915. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49916. /**
  49917. * Implementation specific of rendering the generating effect on the main canvas.
  49918. * @param effect The effect used to render through
  49919. */
  49920. protected _internalRender(effect: Effect): void;
  49921. /**
  49922. * Sets the required values for both the emissive texture and and the main color.
  49923. */
  49924. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49925. /**
  49926. * Returns true if the mesh should render, otherwise false.
  49927. * @param mesh The mesh to render
  49928. * @returns true if it should render otherwise false
  49929. */
  49930. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49931. /**
  49932. * Adds specific effects defines.
  49933. * @param defines The defines to add specifics to.
  49934. */
  49935. protected _addCustomEffectDefines(defines: string[]): void;
  49936. /**
  49937. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49938. * @param mesh The mesh to exclude from the glow layer
  49939. */
  49940. addExcludedMesh(mesh: Mesh): void;
  49941. /**
  49942. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49943. * @param mesh The mesh to remove
  49944. */
  49945. removeExcludedMesh(mesh: Mesh): void;
  49946. /**
  49947. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49948. * @param mesh The mesh to include in the glow layer
  49949. */
  49950. addIncludedOnlyMesh(mesh: Mesh): void;
  49951. /**
  49952. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49953. * @param mesh The mesh to remove
  49954. */
  49955. removeIncludedOnlyMesh(mesh: Mesh): void;
  49956. /**
  49957. * Determine if a given mesh will be used in the glow layer
  49958. * @param mesh The mesh to test
  49959. * @returns true if the mesh will be highlighted by the current glow layer
  49960. */
  49961. hasMesh(mesh: AbstractMesh): boolean;
  49962. /**
  49963. * Free any resources and references associated to a mesh.
  49964. * Internal use
  49965. * @param mesh The mesh to free.
  49966. * @hidden
  49967. */
  49968. _disposeMesh(mesh: Mesh): void;
  49969. /**
  49970. * Gets the class name of the effect layer
  49971. * @returns the string with the class name of the effect layer
  49972. */
  49973. getClassName(): string;
  49974. /**
  49975. * Serializes this glow layer
  49976. * @returns a serialized glow layer object
  49977. */
  49978. serialize(): any;
  49979. /**
  49980. * Creates a Glow Layer from parsed glow layer data
  49981. * @param parsedGlowLayer defines glow layer data
  49982. * @param scene defines the current scene
  49983. * @param rootUrl defines the root URL containing the glow layer information
  49984. * @returns a parsed Glow Layer
  49985. */
  49986. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49987. }
  49988. }
  49989. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49990. /** @hidden */
  49991. export var glowBlurPostProcessPixelShader: {
  49992. name: string;
  49993. shader: string;
  49994. };
  49995. }
  49996. declare module "babylonjs/Layers/highlightLayer" {
  49997. import { Observable } from "babylonjs/Misc/observable";
  49998. import { Nullable } from "babylonjs/types";
  49999. import { Camera } from "babylonjs/Cameras/camera";
  50000. import { Scene } from "babylonjs/scene";
  50001. import { Color3, Color4 } from "babylonjs/Maths/math";
  50002. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50004. import { Mesh } from "babylonjs/Meshes/mesh";
  50005. import { Effect } from "babylonjs/Materials/effect";
  50006. import { Material } from "babylonjs/Materials/material";
  50007. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50008. import "babylonjs/Shaders/glowMapMerge.fragment";
  50009. import "babylonjs/Shaders/glowMapMerge.vertex";
  50010. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50011. module "babylonjs/abstractScene" {
  50012. interface AbstractScene {
  50013. /**
  50014. * Return a the first highlight layer of the scene with a given name.
  50015. * @param name The name of the highlight layer to look for.
  50016. * @return The highlight layer if found otherwise null.
  50017. */
  50018. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50019. }
  50020. }
  50021. /**
  50022. * Highlight layer options. This helps customizing the behaviour
  50023. * of the highlight layer.
  50024. */
  50025. export interface IHighlightLayerOptions {
  50026. /**
  50027. * Multiplication factor apply to the canvas size to compute the render target size
  50028. * used to generated the glowing objects (the smaller the faster).
  50029. */
  50030. mainTextureRatio: number;
  50031. /**
  50032. * Enforces a fixed size texture to ensure resize independant blur.
  50033. */
  50034. mainTextureFixedSize?: number;
  50035. /**
  50036. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50037. * of the picture to blur (the smaller the faster).
  50038. */
  50039. blurTextureSizeRatio: number;
  50040. /**
  50041. * How big in texel of the blur texture is the vertical blur.
  50042. */
  50043. blurVerticalSize: number;
  50044. /**
  50045. * How big in texel of the blur texture is the horizontal blur.
  50046. */
  50047. blurHorizontalSize: number;
  50048. /**
  50049. * Alpha blending mode used to apply the blur. Default is combine.
  50050. */
  50051. alphaBlendingMode: number;
  50052. /**
  50053. * The camera attached to the layer.
  50054. */
  50055. camera: Nullable<Camera>;
  50056. /**
  50057. * Should we display highlight as a solid stroke?
  50058. */
  50059. isStroke?: boolean;
  50060. /**
  50061. * The rendering group to draw the layer in.
  50062. */
  50063. renderingGroupId: number;
  50064. }
  50065. /**
  50066. * The highlight layer Helps adding a glow effect around a mesh.
  50067. *
  50068. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50069. * glowy meshes to your scene.
  50070. *
  50071. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50072. */
  50073. export class HighlightLayer extends EffectLayer {
  50074. name: string;
  50075. /**
  50076. * Effect Name of the highlight layer.
  50077. */
  50078. static readonly EffectName: string;
  50079. /**
  50080. * The neutral color used during the preparation of the glow effect.
  50081. * This is black by default as the blend operation is a blend operation.
  50082. */
  50083. static NeutralColor: Color4;
  50084. /**
  50085. * Stencil value used for glowing meshes.
  50086. */
  50087. static GlowingMeshStencilReference: number;
  50088. /**
  50089. * Stencil value used for the other meshes in the scene.
  50090. */
  50091. static NormalMeshStencilReference: number;
  50092. /**
  50093. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50094. */
  50095. innerGlow: boolean;
  50096. /**
  50097. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50098. */
  50099. outerGlow: boolean;
  50100. /**
  50101. * Specifies the horizontal size of the blur.
  50102. */
  50103. /**
  50104. * Gets the horizontal size of the blur.
  50105. */
  50106. blurHorizontalSize: number;
  50107. /**
  50108. * Specifies the vertical size of the blur.
  50109. */
  50110. /**
  50111. * Gets the vertical size of the blur.
  50112. */
  50113. blurVerticalSize: number;
  50114. /**
  50115. * An event triggered when the highlight layer is being blurred.
  50116. */
  50117. onBeforeBlurObservable: Observable<HighlightLayer>;
  50118. /**
  50119. * An event triggered when the highlight layer has been blurred.
  50120. */
  50121. onAfterBlurObservable: Observable<HighlightLayer>;
  50122. private _instanceGlowingMeshStencilReference;
  50123. private _options;
  50124. private _downSamplePostprocess;
  50125. private _horizontalBlurPostprocess;
  50126. private _verticalBlurPostprocess;
  50127. private _blurTexture;
  50128. private _meshes;
  50129. private _excludedMeshes;
  50130. /**
  50131. * Instantiates a new highlight Layer and references it to the scene..
  50132. * @param name The name of the layer
  50133. * @param scene The scene to use the layer in
  50134. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50135. */
  50136. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50137. /**
  50138. * Get the effect name of the layer.
  50139. * @return The effect name
  50140. */
  50141. getEffectName(): string;
  50142. /**
  50143. * Create the merge effect. This is the shader use to blit the information back
  50144. * to the main canvas at the end of the scene rendering.
  50145. */
  50146. protected _createMergeEffect(): Effect;
  50147. /**
  50148. * Creates the render target textures and post processes used in the highlight layer.
  50149. */
  50150. protected _createTextureAndPostProcesses(): void;
  50151. /**
  50152. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50153. */
  50154. needStencil(): boolean;
  50155. /**
  50156. * Checks for the readiness of the element composing the layer.
  50157. * @param subMesh the mesh to check for
  50158. * @param useInstances specify wether or not to use instances to render the mesh
  50159. * @param emissiveTexture the associated emissive texture used to generate the glow
  50160. * @return true if ready otherwise, false
  50161. */
  50162. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50163. /**
  50164. * Implementation specific of rendering the generating effect on the main canvas.
  50165. * @param effect The effect used to render through
  50166. */
  50167. protected _internalRender(effect: Effect): void;
  50168. /**
  50169. * Returns true if the layer contains information to display, otherwise false.
  50170. */
  50171. shouldRender(): boolean;
  50172. /**
  50173. * Returns true if the mesh should render, otherwise false.
  50174. * @param mesh The mesh to render
  50175. * @returns true if it should render otherwise false
  50176. */
  50177. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50178. /**
  50179. * Sets the required values for both the emissive texture and and the main color.
  50180. */
  50181. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50182. /**
  50183. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50184. * @param mesh The mesh to exclude from the highlight layer
  50185. */
  50186. addExcludedMesh(mesh: Mesh): void;
  50187. /**
  50188. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50189. * @param mesh The mesh to highlight
  50190. */
  50191. removeExcludedMesh(mesh: Mesh): void;
  50192. /**
  50193. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50194. * @param mesh mesh to test
  50195. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50196. */
  50197. hasMesh(mesh: AbstractMesh): boolean;
  50198. /**
  50199. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50200. * @param mesh The mesh to highlight
  50201. * @param color The color of the highlight
  50202. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50203. */
  50204. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50205. /**
  50206. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50207. * @param mesh The mesh to highlight
  50208. */
  50209. removeMesh(mesh: Mesh): void;
  50210. /**
  50211. * Force the stencil to the normal expected value for none glowing parts
  50212. */
  50213. private _defaultStencilReference;
  50214. /**
  50215. * Free any resources and references associated to a mesh.
  50216. * Internal use
  50217. * @param mesh The mesh to free.
  50218. * @hidden
  50219. */
  50220. _disposeMesh(mesh: Mesh): void;
  50221. /**
  50222. * Dispose the highlight layer and free resources.
  50223. */
  50224. dispose(): void;
  50225. /**
  50226. * Gets the class name of the effect layer
  50227. * @returns the string with the class name of the effect layer
  50228. */
  50229. getClassName(): string;
  50230. /**
  50231. * Serializes this Highlight layer
  50232. * @returns a serialized Highlight layer object
  50233. */
  50234. serialize(): any;
  50235. /**
  50236. * Creates a Highlight layer from parsed Highlight layer data
  50237. * @param parsedHightlightLayer defines the Highlight layer data
  50238. * @param scene defines the current scene
  50239. * @param rootUrl defines the root URL containing the Highlight layer information
  50240. * @returns a parsed Highlight layer
  50241. */
  50242. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50243. }
  50244. }
  50245. declare module "babylonjs/Layers/layerSceneComponent" {
  50246. import { Scene } from "babylonjs/scene";
  50247. import { ISceneComponent } from "babylonjs/sceneComponent";
  50248. import { Layer } from "babylonjs/Layers/layer";
  50249. import { AbstractScene } from "babylonjs/abstractScene";
  50250. module "babylonjs/abstractScene" {
  50251. interface AbstractScene {
  50252. /**
  50253. * The list of layers (background and foreground) of the scene
  50254. */
  50255. layers: Array<Layer>;
  50256. }
  50257. }
  50258. /**
  50259. * Defines the layer scene component responsible to manage any layers
  50260. * in a given scene.
  50261. */
  50262. export class LayerSceneComponent implements ISceneComponent {
  50263. /**
  50264. * The component name helpfull to identify the component in the list of scene components.
  50265. */
  50266. readonly name: string;
  50267. /**
  50268. * The scene the component belongs to.
  50269. */
  50270. scene: Scene;
  50271. private _engine;
  50272. /**
  50273. * Creates a new instance of the component for the given scene
  50274. * @param scene Defines the scene to register the component in
  50275. */
  50276. constructor(scene: Scene);
  50277. /**
  50278. * Registers the component in a given scene
  50279. */
  50280. register(): void;
  50281. /**
  50282. * Rebuilds the elements related to this component in case of
  50283. * context lost for instance.
  50284. */
  50285. rebuild(): void;
  50286. /**
  50287. * Disposes the component and the associated ressources.
  50288. */
  50289. dispose(): void;
  50290. private _draw;
  50291. private _drawCameraPredicate;
  50292. private _drawCameraBackground;
  50293. private _drawCameraForeground;
  50294. private _drawRenderTargetPredicate;
  50295. private _drawRenderTargetBackground;
  50296. private _drawRenderTargetForeground;
  50297. /**
  50298. * Adds all the elements from the container to the scene
  50299. * @param container the container holding the elements
  50300. */
  50301. addFromContainer(container: AbstractScene): void;
  50302. /**
  50303. * Removes all the elements in the container from the scene
  50304. * @param container contains the elements to remove
  50305. * @param dispose if the removed element should be disposed (default: false)
  50306. */
  50307. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50308. }
  50309. }
  50310. declare module "babylonjs/Shaders/layer.fragment" {
  50311. /** @hidden */
  50312. export var layerPixelShader: {
  50313. name: string;
  50314. shader: string;
  50315. };
  50316. }
  50317. declare module "babylonjs/Shaders/layer.vertex" {
  50318. /** @hidden */
  50319. export var layerVertexShader: {
  50320. name: string;
  50321. shader: string;
  50322. };
  50323. }
  50324. declare module "babylonjs/Layers/layer" {
  50325. import { Observable } from "babylonjs/Misc/observable";
  50326. import { Nullable } from "babylonjs/types";
  50327. import { Scene } from "babylonjs/scene";
  50328. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50329. import { Texture } from "babylonjs/Materials/Textures/texture";
  50330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50331. import "babylonjs/Shaders/layer.fragment";
  50332. import "babylonjs/Shaders/layer.vertex";
  50333. /**
  50334. * This represents a full screen 2d layer.
  50335. * This can be useful to display a picture in the background of your scene for instance.
  50336. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50337. */
  50338. export class Layer {
  50339. /**
  50340. * Define the name of the layer.
  50341. */
  50342. name: string;
  50343. /**
  50344. * Define the texture the layer should display.
  50345. */
  50346. texture: Nullable<Texture>;
  50347. /**
  50348. * Is the layer in background or foreground.
  50349. */
  50350. isBackground: boolean;
  50351. /**
  50352. * Define the color of the layer (instead of texture).
  50353. */
  50354. color: Color4;
  50355. /**
  50356. * Define the scale of the layer in order to zoom in out of the texture.
  50357. */
  50358. scale: Vector2;
  50359. /**
  50360. * Define an offset for the layer in order to shift the texture.
  50361. */
  50362. offset: Vector2;
  50363. /**
  50364. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50365. */
  50366. alphaBlendingMode: number;
  50367. /**
  50368. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50369. * Alpha test will not mix with the background color in case of transparency.
  50370. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50371. */
  50372. alphaTest: boolean;
  50373. /**
  50374. * Define a mask to restrict the layer to only some of the scene cameras.
  50375. */
  50376. layerMask: number;
  50377. /**
  50378. * Define the list of render target the layer is visible into.
  50379. */
  50380. renderTargetTextures: RenderTargetTexture[];
  50381. /**
  50382. * Define if the layer is only used in renderTarget or if it also
  50383. * renders in the main frame buffer of the canvas.
  50384. */
  50385. renderOnlyInRenderTargetTextures: boolean;
  50386. private _scene;
  50387. private _vertexBuffers;
  50388. private _indexBuffer;
  50389. private _effect;
  50390. private _alphaTestEffect;
  50391. /**
  50392. * An event triggered when the layer is disposed.
  50393. */
  50394. onDisposeObservable: Observable<Layer>;
  50395. private _onDisposeObserver;
  50396. /**
  50397. * Back compatibility with callback before the onDisposeObservable existed.
  50398. * The set callback will be triggered when the layer has been disposed.
  50399. */
  50400. onDispose: () => void;
  50401. /**
  50402. * An event triggered before rendering the scene
  50403. */
  50404. onBeforeRenderObservable: Observable<Layer>;
  50405. private _onBeforeRenderObserver;
  50406. /**
  50407. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50408. * The set callback will be triggered just before rendering the layer.
  50409. */
  50410. onBeforeRender: () => void;
  50411. /**
  50412. * An event triggered after rendering the scene
  50413. */
  50414. onAfterRenderObservable: Observable<Layer>;
  50415. private _onAfterRenderObserver;
  50416. /**
  50417. * Back compatibility with callback before the onAfterRenderObservable existed.
  50418. * The set callback will be triggered just after rendering the layer.
  50419. */
  50420. onAfterRender: () => void;
  50421. /**
  50422. * Instantiates a new layer.
  50423. * This represents a full screen 2d layer.
  50424. * This can be useful to display a picture in the background of your scene for instance.
  50425. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50426. * @param name Define the name of the layer in the scene
  50427. * @param imgUrl Define the url of the texture to display in the layer
  50428. * @param scene Define the scene the layer belongs to
  50429. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50430. * @param color Defines a color for the layer
  50431. */
  50432. constructor(
  50433. /**
  50434. * Define the name of the layer.
  50435. */
  50436. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50437. private _createIndexBuffer;
  50438. /** @hidden */
  50439. _rebuild(): void;
  50440. /**
  50441. * Renders the layer in the scene.
  50442. */
  50443. render(): void;
  50444. /**
  50445. * Disposes and releases the associated ressources.
  50446. */
  50447. dispose(): void;
  50448. }
  50449. }
  50450. declare module "babylonjs/Layers/index" {
  50451. export * from "babylonjs/Layers/effectLayer";
  50452. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50453. export * from "babylonjs/Layers/glowLayer";
  50454. export * from "babylonjs/Layers/highlightLayer";
  50455. export * from "babylonjs/Layers/layer";
  50456. export * from "babylonjs/Layers/layerSceneComponent";
  50457. }
  50458. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50459. /** @hidden */
  50460. export var lensFlarePixelShader: {
  50461. name: string;
  50462. shader: string;
  50463. };
  50464. }
  50465. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50466. /** @hidden */
  50467. export var lensFlareVertexShader: {
  50468. name: string;
  50469. shader: string;
  50470. };
  50471. }
  50472. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50473. import { Scene } from "babylonjs/scene";
  50474. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50476. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50477. import "babylonjs/Shaders/lensFlare.fragment";
  50478. import "babylonjs/Shaders/lensFlare.vertex";
  50479. /**
  50480. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50481. * It is usually composed of several `lensFlare`.
  50482. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50483. */
  50484. export class LensFlareSystem {
  50485. /**
  50486. * Define the name of the lens flare system
  50487. */
  50488. name: string;
  50489. /**
  50490. * List of lens flares used in this system.
  50491. */
  50492. lensFlares: LensFlare[];
  50493. /**
  50494. * Define a limit from the border the lens flare can be visible.
  50495. */
  50496. borderLimit: number;
  50497. /**
  50498. * Define a viewport border we do not want to see the lens flare in.
  50499. */
  50500. viewportBorder: number;
  50501. /**
  50502. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50503. */
  50504. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50505. /**
  50506. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50507. */
  50508. layerMask: number;
  50509. /**
  50510. * Define the id of the lens flare system in the scene.
  50511. * (equal to name by default)
  50512. */
  50513. id: string;
  50514. private _scene;
  50515. private _emitter;
  50516. private _vertexBuffers;
  50517. private _indexBuffer;
  50518. private _effect;
  50519. private _positionX;
  50520. private _positionY;
  50521. private _isEnabled;
  50522. /** @hidden */
  50523. static _SceneComponentInitialization: (scene: Scene) => void;
  50524. /**
  50525. * Instantiates a lens flare system.
  50526. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50527. * It is usually composed of several `lensFlare`.
  50528. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50529. * @param name Define the name of the lens flare system in the scene
  50530. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50531. * @param scene Define the scene the lens flare system belongs to
  50532. */
  50533. constructor(
  50534. /**
  50535. * Define the name of the lens flare system
  50536. */
  50537. name: string, emitter: any, scene: Scene);
  50538. /**
  50539. * Define if the lens flare system is enabled.
  50540. */
  50541. isEnabled: boolean;
  50542. /**
  50543. * Get the scene the effects belongs to.
  50544. * @returns the scene holding the lens flare system
  50545. */
  50546. getScene(): Scene;
  50547. /**
  50548. * Get the emitter of the lens flare system.
  50549. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50550. * @returns the emitter of the lens flare system
  50551. */
  50552. getEmitter(): any;
  50553. /**
  50554. * Set the emitter of the lens flare system.
  50555. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50556. * @param newEmitter Define the new emitter of the system
  50557. */
  50558. setEmitter(newEmitter: any): void;
  50559. /**
  50560. * Get the lens flare system emitter position.
  50561. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50562. * @returns the position
  50563. */
  50564. getEmitterPosition(): Vector3;
  50565. /**
  50566. * @hidden
  50567. */
  50568. computeEffectivePosition(globalViewport: Viewport): boolean;
  50569. /** @hidden */
  50570. _isVisible(): boolean;
  50571. /**
  50572. * @hidden
  50573. */
  50574. render(): boolean;
  50575. /**
  50576. * Dispose and release the lens flare with its associated resources.
  50577. */
  50578. dispose(): void;
  50579. /**
  50580. * Parse a lens flare system from a JSON repressentation
  50581. * @param parsedLensFlareSystem Define the JSON to parse
  50582. * @param scene Define the scene the parsed system should be instantiated in
  50583. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50584. * @returns the parsed system
  50585. */
  50586. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50587. /**
  50588. * Serialize the current Lens Flare System into a JSON representation.
  50589. * @returns the serialized JSON
  50590. */
  50591. serialize(): any;
  50592. }
  50593. }
  50594. declare module "babylonjs/LensFlares/lensFlare" {
  50595. import { Nullable } from "babylonjs/types";
  50596. import { Color3 } from "babylonjs/Maths/math";
  50597. import { Texture } from "babylonjs/Materials/Textures/texture";
  50598. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50599. /**
  50600. * This represents one of the lens effect in a `lensFlareSystem`.
  50601. * It controls one of the indiviual texture used in the effect.
  50602. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50603. */
  50604. export class LensFlare {
  50605. /**
  50606. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50607. */
  50608. size: number;
  50609. /**
  50610. * 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.
  50611. */
  50612. position: number;
  50613. /**
  50614. * Define the lens color.
  50615. */
  50616. color: Color3;
  50617. /**
  50618. * Define the lens texture.
  50619. */
  50620. texture: Nullable<Texture>;
  50621. /**
  50622. * Define the alpha mode to render this particular lens.
  50623. */
  50624. alphaMode: number;
  50625. private _system;
  50626. /**
  50627. * Creates a new Lens Flare.
  50628. * This represents one of the lens effect in a `lensFlareSystem`.
  50629. * It controls one of the indiviual texture used in the effect.
  50630. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50631. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50632. * @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.
  50633. * @param color Define the lens color
  50634. * @param imgUrl Define the lens texture url
  50635. * @param system Define the `lensFlareSystem` this flare is part of
  50636. * @returns The newly created Lens Flare
  50637. */
  50638. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50639. /**
  50640. * Instantiates a new Lens Flare.
  50641. * This represents one of the lens effect in a `lensFlareSystem`.
  50642. * It controls one of the indiviual texture used in the effect.
  50643. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50644. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50645. * @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.
  50646. * @param color Define the lens color
  50647. * @param imgUrl Define the lens texture url
  50648. * @param system Define the `lensFlareSystem` this flare is part of
  50649. */
  50650. constructor(
  50651. /**
  50652. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50653. */
  50654. size: number,
  50655. /**
  50656. * 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.
  50657. */
  50658. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50659. /**
  50660. * Dispose and release the lens flare with its associated resources.
  50661. */
  50662. dispose(): void;
  50663. }
  50664. }
  50665. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50666. import { Nullable } from "babylonjs/types";
  50667. import { Scene } from "babylonjs/scene";
  50668. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50669. import { AbstractScene } from "babylonjs/abstractScene";
  50670. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50671. module "babylonjs/abstractScene" {
  50672. interface AbstractScene {
  50673. /**
  50674. * The list of lens flare system added to the scene
  50675. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50676. */
  50677. lensFlareSystems: Array<LensFlareSystem>;
  50678. /**
  50679. * Removes the given lens flare system from this scene.
  50680. * @param toRemove The lens flare system to remove
  50681. * @returns The index of the removed lens flare system
  50682. */
  50683. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50684. /**
  50685. * Adds the given lens flare system to this scene
  50686. * @param newLensFlareSystem The lens flare system to add
  50687. */
  50688. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50689. /**
  50690. * Gets a lens flare system using its name
  50691. * @param name defines the name to look for
  50692. * @returns the lens flare system or null if not found
  50693. */
  50694. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50695. /**
  50696. * Gets a lens flare system using its id
  50697. * @param id defines the id to look for
  50698. * @returns the lens flare system or null if not found
  50699. */
  50700. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50701. }
  50702. }
  50703. /**
  50704. * Defines the lens flare scene component responsible to manage any lens flares
  50705. * in a given scene.
  50706. */
  50707. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50708. /**
  50709. * The component name helpfull to identify the component in the list of scene components.
  50710. */
  50711. readonly name: string;
  50712. /**
  50713. * The scene the component belongs to.
  50714. */
  50715. scene: Scene;
  50716. /**
  50717. * Creates a new instance of the component for the given scene
  50718. * @param scene Defines the scene to register the component in
  50719. */
  50720. constructor(scene: Scene);
  50721. /**
  50722. * Registers the component in a given scene
  50723. */
  50724. register(): void;
  50725. /**
  50726. * Rebuilds the elements related to this component in case of
  50727. * context lost for instance.
  50728. */
  50729. rebuild(): void;
  50730. /**
  50731. * Adds all the elements from the container to the scene
  50732. * @param container the container holding the elements
  50733. */
  50734. addFromContainer(container: AbstractScene): void;
  50735. /**
  50736. * Removes all the elements in the container from the scene
  50737. * @param container contains the elements to remove
  50738. * @param dispose if the removed element should be disposed (default: false)
  50739. */
  50740. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50741. /**
  50742. * Serializes the component data to the specified json object
  50743. * @param serializationObject The object to serialize to
  50744. */
  50745. serialize(serializationObject: any): void;
  50746. /**
  50747. * Disposes the component and the associated ressources.
  50748. */
  50749. dispose(): void;
  50750. private _draw;
  50751. }
  50752. }
  50753. declare module "babylonjs/LensFlares/index" {
  50754. export * from "babylonjs/LensFlares/lensFlare";
  50755. export * from "babylonjs/LensFlares/lensFlareSystem";
  50756. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50757. }
  50758. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50759. import { Scene } from "babylonjs/scene";
  50760. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50761. import { AbstractScene } from "babylonjs/abstractScene";
  50762. /**
  50763. * Defines the shadow generator component responsible to manage any shadow generators
  50764. * in a given scene.
  50765. */
  50766. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50767. /**
  50768. * The component name helpfull to identify the component in the list of scene components.
  50769. */
  50770. readonly name: string;
  50771. /**
  50772. * The scene the component belongs to.
  50773. */
  50774. scene: Scene;
  50775. /**
  50776. * Creates a new instance of the component for the given scene
  50777. * @param scene Defines the scene to register the component in
  50778. */
  50779. constructor(scene: Scene);
  50780. /**
  50781. * Registers the component in a given scene
  50782. */
  50783. register(): void;
  50784. /**
  50785. * Rebuilds the elements related to this component in case of
  50786. * context lost for instance.
  50787. */
  50788. rebuild(): void;
  50789. /**
  50790. * Serializes the component data to the specified json object
  50791. * @param serializationObject The object to serialize to
  50792. */
  50793. serialize(serializationObject: any): void;
  50794. /**
  50795. * Adds all the elements from the container to the scene
  50796. * @param container the container holding the elements
  50797. */
  50798. addFromContainer(container: AbstractScene): void;
  50799. /**
  50800. * Removes all the elements in the container from the scene
  50801. * @param container contains the elements to remove
  50802. * @param dispose if the removed element should be disposed (default: false)
  50803. */
  50804. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50805. /**
  50806. * Rebuilds the elements related to this component in case of
  50807. * context lost for instance.
  50808. */
  50809. dispose(): void;
  50810. private _gatherRenderTargets;
  50811. }
  50812. }
  50813. declare module "babylonjs/Lights/Shadows/index" {
  50814. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50815. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50816. }
  50817. declare module "babylonjs/Lights/pointLight" {
  50818. import { Scene } from "babylonjs/scene";
  50819. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50821. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50822. import { Effect } from "babylonjs/Materials/effect";
  50823. /**
  50824. * A point light is a light defined by an unique point in world space.
  50825. * The light is emitted in every direction from this point.
  50826. * A good example of a point light is a standard light bulb.
  50827. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50828. */
  50829. export class PointLight extends ShadowLight {
  50830. private _shadowAngle;
  50831. /**
  50832. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50833. * This specifies what angle the shadow will use to be created.
  50834. *
  50835. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50836. */
  50837. /**
  50838. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50839. * This specifies what angle the shadow will use to be created.
  50840. *
  50841. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50842. */
  50843. shadowAngle: number;
  50844. /**
  50845. * Gets the direction if it has been set.
  50846. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50847. */
  50848. /**
  50849. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50850. */
  50851. direction: Vector3;
  50852. /**
  50853. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50854. * A PointLight emits the light in every direction.
  50855. * It can cast shadows.
  50856. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50857. * ```javascript
  50858. * var pointLight = new PointLight("pl", camera.position, scene);
  50859. * ```
  50860. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50861. * @param name The light friendly name
  50862. * @param position The position of the point light in the scene
  50863. * @param scene The scene the lights belongs to
  50864. */
  50865. constructor(name: string, position: Vector3, scene: Scene);
  50866. /**
  50867. * Returns the string "PointLight"
  50868. * @returns the class name
  50869. */
  50870. getClassName(): string;
  50871. /**
  50872. * Returns the integer 0.
  50873. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50874. */
  50875. getTypeID(): number;
  50876. /**
  50877. * Specifies wether or not the shadowmap should be a cube texture.
  50878. * @returns true if the shadowmap needs to be a cube texture.
  50879. */
  50880. needCube(): boolean;
  50881. /**
  50882. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50883. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50884. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50885. */
  50886. getShadowDirection(faceIndex?: number): Vector3;
  50887. /**
  50888. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50889. * - fov = PI / 2
  50890. * - aspect ratio : 1.0
  50891. * - z-near and far equal to the active camera minZ and maxZ.
  50892. * Returns the PointLight.
  50893. */
  50894. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50895. protected _buildUniformLayout(): void;
  50896. /**
  50897. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50898. * @param effect The effect to update
  50899. * @param lightIndex The index of the light in the effect to update
  50900. * @returns The point light
  50901. */
  50902. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50903. /**
  50904. * Prepares the list of defines specific to the light type.
  50905. * @param defines the list of defines
  50906. * @param lightIndex defines the index of the light for the effect
  50907. */
  50908. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50909. }
  50910. }
  50911. declare module "babylonjs/Lights/index" {
  50912. export * from "babylonjs/Lights/light";
  50913. export * from "babylonjs/Lights/shadowLight";
  50914. export * from "babylonjs/Lights/Shadows/index";
  50915. export * from "babylonjs/Lights/directionalLight";
  50916. export * from "babylonjs/Lights/hemisphericLight";
  50917. export * from "babylonjs/Lights/pointLight";
  50918. export * from "babylonjs/Lights/spotLight";
  50919. }
  50920. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50921. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50922. /**
  50923. * Header information of HDR texture files.
  50924. */
  50925. export interface HDRInfo {
  50926. /**
  50927. * The height of the texture in pixels.
  50928. */
  50929. height: number;
  50930. /**
  50931. * The width of the texture in pixels.
  50932. */
  50933. width: number;
  50934. /**
  50935. * The index of the beginning of the data in the binary file.
  50936. */
  50937. dataPosition: number;
  50938. }
  50939. /**
  50940. * This groups tools to convert HDR texture to native colors array.
  50941. */
  50942. export class HDRTools {
  50943. private static Ldexp;
  50944. private static Rgbe2float;
  50945. private static readStringLine;
  50946. /**
  50947. * Reads header information from an RGBE texture stored in a native array.
  50948. * More information on this format are available here:
  50949. * https://en.wikipedia.org/wiki/RGBE_image_format
  50950. *
  50951. * @param uint8array The binary file stored in native array.
  50952. * @return The header information.
  50953. */
  50954. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50955. /**
  50956. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50957. * This RGBE texture needs to store the information as a panorama.
  50958. *
  50959. * More information on this format are available here:
  50960. * https://en.wikipedia.org/wiki/RGBE_image_format
  50961. *
  50962. * @param buffer The binary file stored in an array buffer.
  50963. * @param size The expected size of the extracted cubemap.
  50964. * @return The Cube Map information.
  50965. */
  50966. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50967. /**
  50968. * Returns the pixels data extracted from an RGBE texture.
  50969. * This pixels will be stored left to right up to down in the R G B order in one array.
  50970. *
  50971. * More information on this format are available here:
  50972. * https://en.wikipedia.org/wiki/RGBE_image_format
  50973. *
  50974. * @param uint8array The binary file stored in an array buffer.
  50975. * @param hdrInfo The header information of the file.
  50976. * @return The pixels data in RGB right to left up to down order.
  50977. */
  50978. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50979. private static RGBE_ReadPixels_RLE;
  50980. }
  50981. }
  50982. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50983. import { Nullable } from "babylonjs/types";
  50984. import { Scene } from "babylonjs/scene";
  50985. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50987. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50988. /**
  50989. * This represents a texture coming from an HDR input.
  50990. *
  50991. * The only supported format is currently panorama picture stored in RGBE format.
  50992. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50993. */
  50994. export class HDRCubeTexture extends BaseTexture {
  50995. private static _facesMapping;
  50996. private _generateHarmonics;
  50997. private _noMipmap;
  50998. private _textureMatrix;
  50999. private _size;
  51000. private _onLoad;
  51001. private _onError;
  51002. /**
  51003. * The texture URL.
  51004. */
  51005. url: string;
  51006. /**
  51007. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51008. */
  51009. coordinatesMode: number;
  51010. protected _isBlocking: boolean;
  51011. /**
  51012. * Sets wether or not the texture is blocking during loading.
  51013. */
  51014. /**
  51015. * Gets wether or not the texture is blocking during loading.
  51016. */
  51017. isBlocking: boolean;
  51018. protected _rotationY: number;
  51019. /**
  51020. * Sets texture matrix rotation angle around Y axis in radians.
  51021. */
  51022. /**
  51023. * Gets texture matrix rotation angle around Y axis radians.
  51024. */
  51025. rotationY: number;
  51026. /**
  51027. * Gets or sets the center of the bounding box associated with the cube texture
  51028. * It must define where the camera used to render the texture was set
  51029. */
  51030. boundingBoxPosition: Vector3;
  51031. private _boundingBoxSize;
  51032. /**
  51033. * Gets or sets the size of the bounding box associated with the cube texture
  51034. * When defined, the cubemap will switch to local mode
  51035. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51036. * @example https://www.babylonjs-playground.com/#RNASML
  51037. */
  51038. boundingBoxSize: Vector3;
  51039. /**
  51040. * Instantiates an HDRTexture from the following parameters.
  51041. *
  51042. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51043. * @param scene The scene the texture will be used in
  51044. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51045. * @param noMipmap Forces to not generate the mipmap if true
  51046. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51047. * @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)
  51048. * @param reserved Reserved flag for internal use.
  51049. */
  51050. 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>);
  51051. /**
  51052. * Get the current class name of the texture useful for serialization or dynamic coding.
  51053. * @returns "HDRCubeTexture"
  51054. */
  51055. getClassName(): string;
  51056. /**
  51057. * Occurs when the file is raw .hdr file.
  51058. */
  51059. private loadTexture;
  51060. clone(): HDRCubeTexture;
  51061. delayLoad(): void;
  51062. /**
  51063. * Get the texture reflection matrix used to rotate/transform the reflection.
  51064. * @returns the reflection matrix
  51065. */
  51066. getReflectionTextureMatrix(): Matrix;
  51067. /**
  51068. * Set the texture reflection matrix used to rotate/transform the reflection.
  51069. * @param value Define the reflection matrix to set
  51070. */
  51071. setReflectionTextureMatrix(value: Matrix): void;
  51072. /**
  51073. * Parses a JSON representation of an HDR Texture in order to create the texture
  51074. * @param parsedTexture Define the JSON representation
  51075. * @param scene Define the scene the texture should be created in
  51076. * @param rootUrl Define the root url in case we need to load relative dependencies
  51077. * @returns the newly created texture after parsing
  51078. */
  51079. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51080. serialize(): any;
  51081. }
  51082. }
  51083. declare module "babylonjs/Physics/physicsEngine" {
  51084. import { Nullable } from "babylonjs/types";
  51085. import { Vector3 } from "babylonjs/Maths/math";
  51086. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51087. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51088. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51089. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51090. /**
  51091. * Class used to control physics engine
  51092. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51093. */
  51094. export class PhysicsEngine implements IPhysicsEngine {
  51095. private _physicsPlugin;
  51096. /**
  51097. * Global value used to control the smallest number supported by the simulation
  51098. */
  51099. static Epsilon: number;
  51100. private _impostors;
  51101. private _joints;
  51102. /**
  51103. * Gets the gravity vector used by the simulation
  51104. */
  51105. gravity: Vector3;
  51106. /**
  51107. * Factory used to create the default physics plugin.
  51108. * @returns The default physics plugin
  51109. */
  51110. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51111. /**
  51112. * Creates a new Physics Engine
  51113. * @param gravity defines the gravity vector used by the simulation
  51114. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51115. */
  51116. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51117. /**
  51118. * Sets the gravity vector used by the simulation
  51119. * @param gravity defines the gravity vector to use
  51120. */
  51121. setGravity(gravity: Vector3): void;
  51122. /**
  51123. * Set the time step of the physics engine.
  51124. * Default is 1/60.
  51125. * To slow it down, enter 1/600 for example.
  51126. * To speed it up, 1/30
  51127. * @param newTimeStep defines the new timestep to apply to this world.
  51128. */
  51129. setTimeStep(newTimeStep?: number): void;
  51130. /**
  51131. * Get the time step of the physics engine.
  51132. * @returns the current time step
  51133. */
  51134. getTimeStep(): number;
  51135. /**
  51136. * Release all resources
  51137. */
  51138. dispose(): void;
  51139. /**
  51140. * Gets the name of the current physics plugin
  51141. * @returns the name of the plugin
  51142. */
  51143. getPhysicsPluginName(): string;
  51144. /**
  51145. * Adding a new impostor for the impostor tracking.
  51146. * This will be done by the impostor itself.
  51147. * @param impostor the impostor to add
  51148. */
  51149. addImpostor(impostor: PhysicsImpostor): void;
  51150. /**
  51151. * Remove an impostor from the engine.
  51152. * This impostor and its mesh will not longer be updated by the physics engine.
  51153. * @param impostor the impostor to remove
  51154. */
  51155. removeImpostor(impostor: PhysicsImpostor): void;
  51156. /**
  51157. * Add a joint to the physics engine
  51158. * @param mainImpostor defines the main impostor to which the joint is added.
  51159. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51160. * @param joint defines the joint that will connect both impostors.
  51161. */
  51162. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51163. /**
  51164. * Removes a joint from the simulation
  51165. * @param mainImpostor defines the impostor used with the joint
  51166. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51167. * @param joint defines the joint to remove
  51168. */
  51169. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51170. /**
  51171. * Called by the scene. No need to call it.
  51172. * @param delta defines the timespam between frames
  51173. */
  51174. _step(delta: number): void;
  51175. /**
  51176. * Gets the current plugin used to run the simulation
  51177. * @returns current plugin
  51178. */
  51179. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51180. /**
  51181. * Gets the list of physic impostors
  51182. * @returns an array of PhysicsImpostor
  51183. */
  51184. getImpostors(): Array<PhysicsImpostor>;
  51185. /**
  51186. * Gets the impostor for a physics enabled object
  51187. * @param object defines the object impersonated by the impostor
  51188. * @returns the PhysicsImpostor or null if not found
  51189. */
  51190. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51191. /**
  51192. * Gets the impostor for a physics body object
  51193. * @param body defines physics body used by the impostor
  51194. * @returns the PhysicsImpostor or null if not found
  51195. */
  51196. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51197. /**
  51198. * Does a raycast in the physics world
  51199. * @param from when should the ray start?
  51200. * @param to when should the ray end?
  51201. * @returns PhysicsRaycastResult
  51202. */
  51203. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51204. }
  51205. }
  51206. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51207. import { Nullable } from "babylonjs/types";
  51208. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51210. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51211. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51212. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51213. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51214. /** @hidden */
  51215. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51216. private _useDeltaForWorldStep;
  51217. world: any;
  51218. name: string;
  51219. private _physicsMaterials;
  51220. private _fixedTimeStep;
  51221. private _cannonRaycastResult;
  51222. private _raycastResult;
  51223. private _removeAfterStep;
  51224. BJSCANNON: any;
  51225. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51226. setGravity(gravity: Vector3): void;
  51227. setTimeStep(timeStep: number): void;
  51228. getTimeStep(): number;
  51229. executeStep(delta: number): void;
  51230. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51231. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51232. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51233. private _processChildMeshes;
  51234. removePhysicsBody(impostor: PhysicsImpostor): void;
  51235. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51236. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51237. private _addMaterial;
  51238. private _checkWithEpsilon;
  51239. private _createShape;
  51240. private _createHeightmap;
  51241. private _minus90X;
  51242. private _plus90X;
  51243. private _tmpPosition;
  51244. private _tmpDeltaPosition;
  51245. private _tmpUnityRotation;
  51246. private _updatePhysicsBodyTransformation;
  51247. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51248. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51249. isSupported(): boolean;
  51250. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51251. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51252. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51253. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51254. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51255. getBodyMass(impostor: PhysicsImpostor): number;
  51256. getBodyFriction(impostor: PhysicsImpostor): number;
  51257. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51258. getBodyRestitution(impostor: PhysicsImpostor): number;
  51259. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51260. sleepBody(impostor: PhysicsImpostor): void;
  51261. wakeUpBody(impostor: PhysicsImpostor): void;
  51262. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51263. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51264. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51265. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51266. getRadius(impostor: PhysicsImpostor): number;
  51267. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51268. dispose(): void;
  51269. private _extendNamespace;
  51270. /**
  51271. * Does a raycast in the physics world
  51272. * @param from when should the ray start?
  51273. * @param to when should the ray end?
  51274. * @returns PhysicsRaycastResult
  51275. */
  51276. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51277. }
  51278. }
  51279. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51280. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51281. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51282. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51284. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51285. import { Nullable } from "babylonjs/types";
  51286. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51287. /** @hidden */
  51288. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51289. world: any;
  51290. name: string;
  51291. BJSOIMO: any;
  51292. private _raycastResult;
  51293. constructor(iterations?: number, oimoInjection?: any);
  51294. setGravity(gravity: Vector3): void;
  51295. setTimeStep(timeStep: number): void;
  51296. getTimeStep(): number;
  51297. private _tmpImpostorsArray;
  51298. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51299. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51300. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51301. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51302. private _tmpPositionVector;
  51303. removePhysicsBody(impostor: PhysicsImpostor): void;
  51304. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51305. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51306. isSupported(): boolean;
  51307. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51308. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51309. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51310. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51311. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51312. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51313. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51314. getBodyMass(impostor: PhysicsImpostor): number;
  51315. getBodyFriction(impostor: PhysicsImpostor): number;
  51316. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51317. getBodyRestitution(impostor: PhysicsImpostor): number;
  51318. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51319. sleepBody(impostor: PhysicsImpostor): void;
  51320. wakeUpBody(impostor: PhysicsImpostor): void;
  51321. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51322. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51323. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51324. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51325. getRadius(impostor: PhysicsImpostor): number;
  51326. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51327. dispose(): void;
  51328. /**
  51329. * Does a raycast in the physics world
  51330. * @param from when should the ray start?
  51331. * @param to when should the ray end?
  51332. * @returns PhysicsRaycastResult
  51333. */
  51334. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51335. }
  51336. }
  51337. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51338. import { Nullable } from "babylonjs/types";
  51339. import { Scene } from "babylonjs/scene";
  51340. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51341. import { Mesh } from "babylonjs/Meshes/mesh";
  51342. /**
  51343. * Class containing static functions to help procedurally build meshes
  51344. */
  51345. export class RibbonBuilder {
  51346. /**
  51347. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51348. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51349. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51350. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51351. * * 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
  51352. * * 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
  51353. * * 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
  51354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51357. * * 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
  51358. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51359. * * 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
  51360. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51362. * @param name defines the name of the mesh
  51363. * @param options defines the options used to create the mesh
  51364. * @param scene defines the hosting scene
  51365. * @returns the ribbon mesh
  51366. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51368. */
  51369. static CreateRibbon(name: string, options: {
  51370. pathArray: Vector3[][];
  51371. closeArray?: boolean;
  51372. closePath?: boolean;
  51373. offset?: number;
  51374. updatable?: boolean;
  51375. sideOrientation?: number;
  51376. frontUVs?: Vector4;
  51377. backUVs?: Vector4;
  51378. instance?: Mesh;
  51379. invertUV?: boolean;
  51380. uvs?: Vector2[];
  51381. colors?: Color4[];
  51382. }, scene?: Nullable<Scene>): Mesh;
  51383. }
  51384. }
  51385. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51386. import { Nullable } from "babylonjs/types";
  51387. import { Scene } from "babylonjs/scene";
  51388. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51389. import { Mesh } from "babylonjs/Meshes/mesh";
  51390. /**
  51391. * Class containing static functions to help procedurally build meshes
  51392. */
  51393. export class ShapeBuilder {
  51394. /**
  51395. * 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.
  51396. * * 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.
  51397. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51398. * * 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.
  51399. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51400. * * 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
  51401. * * 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
  51402. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51407. * @param name defines the name of the mesh
  51408. * @param options defines the options used to create the mesh
  51409. * @param scene defines the hosting scene
  51410. * @returns the extruded shape mesh
  51411. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51413. */
  51414. static ExtrudeShape(name: string, options: {
  51415. shape: Vector3[];
  51416. path: Vector3[];
  51417. scale?: number;
  51418. rotation?: number;
  51419. cap?: number;
  51420. updatable?: boolean;
  51421. sideOrientation?: number;
  51422. frontUVs?: Vector4;
  51423. backUVs?: Vector4;
  51424. instance?: Mesh;
  51425. invertUV?: boolean;
  51426. }, scene?: Nullable<Scene>): Mesh;
  51427. /**
  51428. * Creates an custom extruded shape mesh.
  51429. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51430. * * 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.
  51431. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51432. * * 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
  51433. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51434. * * 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
  51435. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51436. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51437. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51438. * * 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
  51439. * * 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
  51440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51445. * @param name defines the name of the mesh
  51446. * @param options defines the options used to create the mesh
  51447. * @param scene defines the hosting scene
  51448. * @returns the custom extruded shape mesh
  51449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51452. */
  51453. static ExtrudeShapeCustom(name: string, options: {
  51454. shape: Vector3[];
  51455. path: Vector3[];
  51456. scaleFunction?: any;
  51457. rotationFunction?: any;
  51458. ribbonCloseArray?: boolean;
  51459. ribbonClosePath?: boolean;
  51460. cap?: number;
  51461. updatable?: boolean;
  51462. sideOrientation?: number;
  51463. frontUVs?: Vector4;
  51464. backUVs?: Vector4;
  51465. instance?: Mesh;
  51466. invertUV?: boolean;
  51467. }, scene?: Nullable<Scene>): Mesh;
  51468. private static _ExtrudeShapeGeneric;
  51469. }
  51470. }
  51471. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51472. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51473. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51474. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51475. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51476. import { Nullable } from "babylonjs/types";
  51477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51478. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51479. /**
  51480. * AmmoJS Physics plugin
  51481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51482. * @see https://github.com/kripken/ammo.js/
  51483. */
  51484. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51485. private _useDeltaForWorldStep;
  51486. /**
  51487. * Reference to the Ammo library
  51488. */
  51489. bjsAMMO: any;
  51490. /**
  51491. * Created ammoJS world which physics bodies are added to
  51492. */
  51493. world: any;
  51494. /**
  51495. * Name of the plugin
  51496. */
  51497. name: string;
  51498. private _timeStep;
  51499. private _fixedTimeStep;
  51500. private _maxSteps;
  51501. private _tmpQuaternion;
  51502. private _tmpAmmoTransform;
  51503. private _tmpAmmoQuaternion;
  51504. private _tmpAmmoConcreteContactResultCallback;
  51505. private _collisionConfiguration;
  51506. private _dispatcher;
  51507. private _overlappingPairCache;
  51508. private _solver;
  51509. private _softBodySolver;
  51510. private _tmpAmmoVectorA;
  51511. private _tmpAmmoVectorB;
  51512. private _tmpAmmoVectorC;
  51513. private _tmpAmmoVectorD;
  51514. private _tmpContactCallbackResult;
  51515. private _tmpAmmoVectorRCA;
  51516. private _tmpAmmoVectorRCB;
  51517. private _raycastResult;
  51518. private static readonly DISABLE_COLLISION_FLAG;
  51519. private static readonly KINEMATIC_FLAG;
  51520. private static readonly DISABLE_DEACTIVATION_FLAG;
  51521. /**
  51522. * Initializes the ammoJS plugin
  51523. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51524. * @param ammoInjection can be used to inject your own ammo reference
  51525. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51526. */
  51527. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51528. /**
  51529. * Sets the gravity of the physics world (m/(s^2))
  51530. * @param gravity Gravity to set
  51531. */
  51532. setGravity(gravity: Vector3): void;
  51533. /**
  51534. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51535. * @param timeStep timestep to use in seconds
  51536. */
  51537. setTimeStep(timeStep: number): void;
  51538. /**
  51539. * 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)
  51540. * @param fixedTimeStep fixedTimeStep to use in seconds
  51541. */
  51542. setFixedTimeStep(fixedTimeStep: number): void;
  51543. /**
  51544. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51545. * @param maxSteps the maximum number of steps by the physics engine per frame
  51546. */
  51547. setMaxSteps(maxSteps: number): void;
  51548. /**
  51549. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51550. * @returns the current timestep in seconds
  51551. */
  51552. getTimeStep(): number;
  51553. private _isImpostorInContact;
  51554. private _isImpostorPairInContact;
  51555. private _stepSimulation;
  51556. /**
  51557. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51558. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51559. * After the step the babylon meshes are set to the position of the physics imposters
  51560. * @param delta amount of time to step forward
  51561. * @param impostors array of imposters to update before/after the step
  51562. */
  51563. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51564. /**
  51565. * Update babylon mesh to match physics world object
  51566. * @param impostor imposter to match
  51567. */
  51568. private _afterSoftStep;
  51569. /**
  51570. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51571. * @param impostor imposter to match
  51572. */
  51573. private _ropeStep;
  51574. /**
  51575. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51576. * @param impostor imposter to match
  51577. */
  51578. private _softbodyOrClothStep;
  51579. private _tmpVector;
  51580. private _tmpMatrix;
  51581. /**
  51582. * Applies an impulse on the imposter
  51583. * @param impostor imposter to apply impulse to
  51584. * @param force amount of force to be applied to the imposter
  51585. * @param contactPoint the location to apply the impulse on the imposter
  51586. */
  51587. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51588. /**
  51589. * Applies a force on the imposter
  51590. * @param impostor imposter to apply force
  51591. * @param force amount of force to be applied to the imposter
  51592. * @param contactPoint the location to apply the force on the imposter
  51593. */
  51594. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51595. /**
  51596. * Creates a physics body using the plugin
  51597. * @param impostor the imposter to create the physics body on
  51598. */
  51599. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51600. /**
  51601. * Removes the physics body from the imposter and disposes of the body's memory
  51602. * @param impostor imposter to remove the physics body from
  51603. */
  51604. removePhysicsBody(impostor: PhysicsImpostor): void;
  51605. /**
  51606. * Generates a joint
  51607. * @param impostorJoint the imposter joint to create the joint with
  51608. */
  51609. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51610. /**
  51611. * Removes a joint
  51612. * @param impostorJoint the imposter joint to remove the joint from
  51613. */
  51614. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51615. private _addMeshVerts;
  51616. /**
  51617. * Initialise the soft body vertices to match its object's (mesh) vertices
  51618. * Softbody vertices (nodes) are in world space and to match this
  51619. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51620. * @param impostor to create the softbody for
  51621. */
  51622. private _softVertexData;
  51623. /**
  51624. * Create an impostor's soft body
  51625. * @param impostor to create the softbody for
  51626. */
  51627. private _createSoftbody;
  51628. /**
  51629. * Create cloth for an impostor
  51630. * @param impostor to create the softbody for
  51631. */
  51632. private _createCloth;
  51633. /**
  51634. * Create rope for an impostor
  51635. * @param impostor to create the softbody for
  51636. */
  51637. private _createRope;
  51638. private _addHullVerts;
  51639. private _createShape;
  51640. /**
  51641. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51642. * @param impostor imposter containing the physics body and babylon object
  51643. */
  51644. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51645. /**
  51646. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51647. * @param impostor imposter containing the physics body and babylon object
  51648. * @param newPosition new position
  51649. * @param newRotation new rotation
  51650. */
  51651. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51652. /**
  51653. * If this plugin is supported
  51654. * @returns true if its supported
  51655. */
  51656. isSupported(): boolean;
  51657. /**
  51658. * Sets the linear velocity of the physics body
  51659. * @param impostor imposter to set the velocity on
  51660. * @param velocity velocity to set
  51661. */
  51662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51663. /**
  51664. * Sets the angular velocity of the physics body
  51665. * @param impostor imposter to set the velocity on
  51666. * @param velocity velocity to set
  51667. */
  51668. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51669. /**
  51670. * gets the linear velocity
  51671. * @param impostor imposter to get linear velocity from
  51672. * @returns linear velocity
  51673. */
  51674. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51675. /**
  51676. * gets the angular velocity
  51677. * @param impostor imposter to get angular velocity from
  51678. * @returns angular velocity
  51679. */
  51680. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51681. /**
  51682. * Sets the mass of physics body
  51683. * @param impostor imposter to set the mass on
  51684. * @param mass mass to set
  51685. */
  51686. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51687. /**
  51688. * Gets the mass of the physics body
  51689. * @param impostor imposter to get the mass from
  51690. * @returns mass
  51691. */
  51692. getBodyMass(impostor: PhysicsImpostor): number;
  51693. /**
  51694. * Gets friction of the impostor
  51695. * @param impostor impostor to get friction from
  51696. * @returns friction value
  51697. */
  51698. getBodyFriction(impostor: PhysicsImpostor): number;
  51699. /**
  51700. * Sets friction of the impostor
  51701. * @param impostor impostor to set friction on
  51702. * @param friction friction value
  51703. */
  51704. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51705. /**
  51706. * Gets restitution of the impostor
  51707. * @param impostor impostor to get restitution from
  51708. * @returns restitution value
  51709. */
  51710. getBodyRestitution(impostor: PhysicsImpostor): number;
  51711. /**
  51712. * Sets resitution of the impostor
  51713. * @param impostor impostor to set resitution on
  51714. * @param restitution resitution value
  51715. */
  51716. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51717. /**
  51718. * Gets pressure inside the impostor
  51719. * @param impostor impostor to get pressure from
  51720. * @returns pressure value
  51721. */
  51722. getBodyPressure(impostor: PhysicsImpostor): number;
  51723. /**
  51724. * Sets pressure inside a soft body impostor
  51725. * Cloth and rope must remain 0 pressure
  51726. * @param impostor impostor to set pressure on
  51727. * @param pressure pressure value
  51728. */
  51729. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51730. /**
  51731. * Gets stiffness of the impostor
  51732. * @param impostor impostor to get stiffness from
  51733. * @returns pressure value
  51734. */
  51735. getBodyStiffness(impostor: PhysicsImpostor): number;
  51736. /**
  51737. * Sets stiffness of the impostor
  51738. * @param impostor impostor to set stiffness on
  51739. * @param stiffness stiffness value from 0 to 1
  51740. */
  51741. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51742. /**
  51743. * Gets velocityIterations of the impostor
  51744. * @param impostor impostor to get velocity iterations from
  51745. * @returns velocityIterations value
  51746. */
  51747. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51748. /**
  51749. * Sets velocityIterations of the impostor
  51750. * @param impostor impostor to set velocity iterations on
  51751. * @param velocityIterations velocityIterations value
  51752. */
  51753. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51754. /**
  51755. * Gets positionIterations of the impostor
  51756. * @param impostor impostor to get position iterations from
  51757. * @returns positionIterations value
  51758. */
  51759. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51760. /**
  51761. * Sets positionIterations of the impostor
  51762. * @param impostor impostor to set position on
  51763. * @param positionIterations positionIterations value
  51764. */
  51765. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51766. /**
  51767. * Append an anchor to a cloth object
  51768. * @param impostor is the cloth impostor to add anchor to
  51769. * @param otherImpostor is the rigid impostor to anchor to
  51770. * @param width ratio across width from 0 to 1
  51771. * @param height ratio up height from 0 to 1
  51772. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51773. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51774. */
  51775. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51776. /**
  51777. * Append an hook to a rope object
  51778. * @param impostor is the rope impostor to add hook to
  51779. * @param otherImpostor is the rigid impostor to hook to
  51780. * @param length ratio along the rope from 0 to 1
  51781. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51782. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51783. */
  51784. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51785. /**
  51786. * Sleeps the physics body and stops it from being active
  51787. * @param impostor impostor to sleep
  51788. */
  51789. sleepBody(impostor: PhysicsImpostor): void;
  51790. /**
  51791. * Activates the physics body
  51792. * @param impostor impostor to activate
  51793. */
  51794. wakeUpBody(impostor: PhysicsImpostor): void;
  51795. /**
  51796. * Updates the distance parameters of the joint
  51797. * @param joint joint to update
  51798. * @param maxDistance maximum distance of the joint
  51799. * @param minDistance minimum distance of the joint
  51800. */
  51801. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51802. /**
  51803. * Sets a motor on the joint
  51804. * @param joint joint to set motor on
  51805. * @param speed speed of the motor
  51806. * @param maxForce maximum force of the motor
  51807. * @param motorIndex index of the motor
  51808. */
  51809. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51810. /**
  51811. * Sets the motors limit
  51812. * @param joint joint to set limit on
  51813. * @param upperLimit upper limit
  51814. * @param lowerLimit lower limit
  51815. */
  51816. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51817. /**
  51818. * Syncs the position and rotation of a mesh with the impostor
  51819. * @param mesh mesh to sync
  51820. * @param impostor impostor to update the mesh with
  51821. */
  51822. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51823. /**
  51824. * Gets the radius of the impostor
  51825. * @param impostor impostor to get radius from
  51826. * @returns the radius
  51827. */
  51828. getRadius(impostor: PhysicsImpostor): number;
  51829. /**
  51830. * Gets the box size of the impostor
  51831. * @param impostor impostor to get box size from
  51832. * @param result the resulting box size
  51833. */
  51834. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51835. /**
  51836. * Disposes of the impostor
  51837. */
  51838. dispose(): void;
  51839. /**
  51840. * Does a raycast in the physics world
  51841. * @param from when should the ray start?
  51842. * @param to when should the ray end?
  51843. * @returns PhysicsRaycastResult
  51844. */
  51845. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51846. }
  51847. }
  51848. declare module "babylonjs/Probes/reflectionProbe" {
  51849. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51850. import { Vector3 } from "babylonjs/Maths/math";
  51851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51852. import { Nullable } from "babylonjs/types";
  51853. import { Scene } from "babylonjs/scene";
  51854. module "babylonjs/abstractScene" {
  51855. interface AbstractScene {
  51856. /**
  51857. * The list of reflection probes added to the scene
  51858. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51859. */
  51860. reflectionProbes: Array<ReflectionProbe>;
  51861. /**
  51862. * Removes the given reflection probe from this scene.
  51863. * @param toRemove The reflection probe to remove
  51864. * @returns The index of the removed reflection probe
  51865. */
  51866. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51867. /**
  51868. * Adds the given reflection probe to this scene.
  51869. * @param newReflectionProbe The reflection probe to add
  51870. */
  51871. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51872. }
  51873. }
  51874. /**
  51875. * Class used to generate realtime reflection / refraction cube textures
  51876. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51877. */
  51878. export class ReflectionProbe {
  51879. /** defines the name of the probe */
  51880. name: string;
  51881. private _scene;
  51882. private _renderTargetTexture;
  51883. private _projectionMatrix;
  51884. private _viewMatrix;
  51885. private _target;
  51886. private _add;
  51887. private _attachedMesh;
  51888. private _invertYAxis;
  51889. /** Gets or sets probe position (center of the cube map) */
  51890. position: Vector3;
  51891. /**
  51892. * Creates a new reflection probe
  51893. * @param name defines the name of the probe
  51894. * @param size defines the texture resolution (for each face)
  51895. * @param scene defines the hosting scene
  51896. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51897. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51898. */
  51899. constructor(
  51900. /** defines the name of the probe */
  51901. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51902. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51903. samples: number;
  51904. /** Gets or sets the refresh rate to use (on every frame by default) */
  51905. refreshRate: number;
  51906. /**
  51907. * Gets the hosting scene
  51908. * @returns a Scene
  51909. */
  51910. getScene(): Scene;
  51911. /** Gets the internal CubeTexture used to render to */
  51912. readonly cubeTexture: RenderTargetTexture;
  51913. /** Gets the list of meshes to render */
  51914. readonly renderList: Nullable<AbstractMesh[]>;
  51915. /**
  51916. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51917. * @param mesh defines the mesh to attach to
  51918. */
  51919. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51920. /**
  51921. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51922. * @param renderingGroupId The rendering group id corresponding to its index
  51923. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51924. */
  51925. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51926. /**
  51927. * Clean all associated resources
  51928. */
  51929. dispose(): void;
  51930. /**
  51931. * Converts the reflection probe information to a readable string for debug purpose.
  51932. * @param fullDetails Supports for multiple levels of logging within scene loading
  51933. * @returns the human readable reflection probe info
  51934. */
  51935. toString(fullDetails?: boolean): string;
  51936. /**
  51937. * Get the class name of the relfection probe.
  51938. * @returns "ReflectionProbe"
  51939. */
  51940. getClassName(): string;
  51941. /**
  51942. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51943. * @returns The JSON representation of the texture
  51944. */
  51945. serialize(): any;
  51946. /**
  51947. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51948. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51949. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51950. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51951. * @returns The parsed reflection probe if successful
  51952. */
  51953. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51954. }
  51955. }
  51956. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51957. /** @hidden */
  51958. export var _BabylonLoaderRegistered: boolean;
  51959. }
  51960. declare module "babylonjs/Loading/Plugins/index" {
  51961. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51962. }
  51963. declare module "babylonjs/Loading/index" {
  51964. export * from "babylonjs/Loading/loadingScreen";
  51965. export * from "babylonjs/Loading/Plugins/index";
  51966. export * from "babylonjs/Loading/sceneLoader";
  51967. export * from "babylonjs/Loading/sceneLoaderFlags";
  51968. }
  51969. declare module "babylonjs/Materials/Background/index" {
  51970. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51971. }
  51972. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51973. import { Scene } from "babylonjs/scene";
  51974. import { Color3 } from "babylonjs/Maths/math";
  51975. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51977. /**
  51978. * The Physically based simple base material of BJS.
  51979. *
  51980. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51981. * It is used as the base class for both the specGloss and metalRough conventions.
  51982. */
  51983. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51984. /**
  51985. * Number of Simultaneous lights allowed on the material.
  51986. */
  51987. maxSimultaneousLights: number;
  51988. /**
  51989. * If sets to true, disables all the lights affecting the material.
  51990. */
  51991. disableLighting: boolean;
  51992. /**
  51993. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51994. */
  51995. environmentTexture: BaseTexture;
  51996. /**
  51997. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51998. */
  51999. invertNormalMapX: boolean;
  52000. /**
  52001. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52002. */
  52003. invertNormalMapY: boolean;
  52004. /**
  52005. * Normal map used in the model.
  52006. */
  52007. normalTexture: BaseTexture;
  52008. /**
  52009. * Emissivie color used to self-illuminate the model.
  52010. */
  52011. emissiveColor: Color3;
  52012. /**
  52013. * Emissivie texture used to self-illuminate the model.
  52014. */
  52015. emissiveTexture: BaseTexture;
  52016. /**
  52017. * Occlusion Channel Strenght.
  52018. */
  52019. occlusionStrength: number;
  52020. /**
  52021. * Occlusion Texture of the material (adding extra occlusion effects).
  52022. */
  52023. occlusionTexture: BaseTexture;
  52024. /**
  52025. * Defines the alpha limits in alpha test mode.
  52026. */
  52027. alphaCutOff: number;
  52028. /**
  52029. * Gets the current double sided mode.
  52030. */
  52031. /**
  52032. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52033. */
  52034. doubleSided: boolean;
  52035. /**
  52036. * Stores the pre-calculated light information of a mesh in a texture.
  52037. */
  52038. lightmapTexture: BaseTexture;
  52039. /**
  52040. * If true, the light map contains occlusion information instead of lighting info.
  52041. */
  52042. useLightmapAsShadowmap: boolean;
  52043. /**
  52044. * Instantiates a new PBRMaterial instance.
  52045. *
  52046. * @param name The material name
  52047. * @param scene The scene the material will be use in.
  52048. */
  52049. constructor(name: string, scene: Scene);
  52050. getClassName(): string;
  52051. }
  52052. }
  52053. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52054. import { Scene } from "babylonjs/scene";
  52055. import { Color3 } from "babylonjs/Maths/math";
  52056. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52057. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52058. /**
  52059. * The PBR material of BJS following the metal roughness convention.
  52060. *
  52061. * This fits to the PBR convention in the GLTF definition:
  52062. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52063. */
  52064. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52065. /**
  52066. * The base color has two different interpretations depending on the value of metalness.
  52067. * When the material is a metal, the base color is the specific measured reflectance value
  52068. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52069. * of the material.
  52070. */
  52071. baseColor: Color3;
  52072. /**
  52073. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52074. * well as opacity information in the alpha channel.
  52075. */
  52076. baseTexture: BaseTexture;
  52077. /**
  52078. * Specifies the metallic scalar value of the material.
  52079. * Can also be used to scale the metalness values of the metallic texture.
  52080. */
  52081. metallic: number;
  52082. /**
  52083. * Specifies the roughness scalar value of the material.
  52084. * Can also be used to scale the roughness values of the metallic texture.
  52085. */
  52086. roughness: number;
  52087. /**
  52088. * Texture containing both the metallic value in the B channel and the
  52089. * roughness value in the G channel to keep better precision.
  52090. */
  52091. metallicRoughnessTexture: BaseTexture;
  52092. /**
  52093. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52094. *
  52095. * @param name The material name
  52096. * @param scene The scene the material will be use in.
  52097. */
  52098. constructor(name: string, scene: Scene);
  52099. /**
  52100. * Return the currrent class name of the material.
  52101. */
  52102. getClassName(): string;
  52103. /**
  52104. * Makes a duplicate of the current material.
  52105. * @param name - name to use for the new material.
  52106. */
  52107. clone(name: string): PBRMetallicRoughnessMaterial;
  52108. /**
  52109. * Serialize the material to a parsable JSON object.
  52110. */
  52111. serialize(): any;
  52112. /**
  52113. * Parses a JSON object correponding to the serialize function.
  52114. */
  52115. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52116. }
  52117. }
  52118. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52119. import { Scene } from "babylonjs/scene";
  52120. import { Color3 } from "babylonjs/Maths/math";
  52121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52122. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52123. /**
  52124. * The PBR material of BJS following the specular glossiness convention.
  52125. *
  52126. * This fits to the PBR convention in the GLTF definition:
  52127. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52128. */
  52129. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52130. /**
  52131. * Specifies the diffuse color of the material.
  52132. */
  52133. diffuseColor: Color3;
  52134. /**
  52135. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52136. * channel.
  52137. */
  52138. diffuseTexture: BaseTexture;
  52139. /**
  52140. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52141. */
  52142. specularColor: Color3;
  52143. /**
  52144. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52145. */
  52146. glossiness: number;
  52147. /**
  52148. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52149. */
  52150. specularGlossinessTexture: BaseTexture;
  52151. /**
  52152. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52153. *
  52154. * @param name The material name
  52155. * @param scene The scene the material will be use in.
  52156. */
  52157. constructor(name: string, scene: Scene);
  52158. /**
  52159. * Return the currrent class name of the material.
  52160. */
  52161. getClassName(): string;
  52162. /**
  52163. * Makes a duplicate of the current material.
  52164. * @param name - name to use for the new material.
  52165. */
  52166. clone(name: string): PBRSpecularGlossinessMaterial;
  52167. /**
  52168. * Serialize the material to a parsable JSON object.
  52169. */
  52170. serialize(): any;
  52171. /**
  52172. * Parses a JSON object correponding to the serialize function.
  52173. */
  52174. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52175. }
  52176. }
  52177. declare module "babylonjs/Materials/PBR/index" {
  52178. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52179. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52180. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52181. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52182. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52183. }
  52184. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52185. import { Nullable } from "babylonjs/types";
  52186. import { Scene } from "babylonjs/scene";
  52187. import { Matrix } from "babylonjs/Maths/math";
  52188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52189. /**
  52190. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52191. * It can help converting any input color in a desired output one. This can then be used to create effects
  52192. * from sepia, black and white to sixties or futuristic rendering...
  52193. *
  52194. * The only supported format is currently 3dl.
  52195. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52196. */
  52197. export class ColorGradingTexture extends BaseTexture {
  52198. /**
  52199. * The current texture matrix. (will always be identity in color grading texture)
  52200. */
  52201. private _textureMatrix;
  52202. /**
  52203. * The texture URL.
  52204. */
  52205. url: string;
  52206. /**
  52207. * Empty line regex stored for GC.
  52208. */
  52209. private static _noneEmptyLineRegex;
  52210. private _engine;
  52211. /**
  52212. * Instantiates a ColorGradingTexture from the following parameters.
  52213. *
  52214. * @param url The location of the color gradind data (currently only supporting 3dl)
  52215. * @param scene The scene the texture will be used in
  52216. */
  52217. constructor(url: string, scene: Scene);
  52218. /**
  52219. * Returns the texture matrix used in most of the material.
  52220. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52221. */
  52222. getTextureMatrix(): Matrix;
  52223. /**
  52224. * Occurs when the file being loaded is a .3dl LUT file.
  52225. */
  52226. private load3dlTexture;
  52227. /**
  52228. * Starts the loading process of the texture.
  52229. */
  52230. private loadTexture;
  52231. /**
  52232. * Clones the color gradind texture.
  52233. */
  52234. clone(): ColorGradingTexture;
  52235. /**
  52236. * Called during delayed load for textures.
  52237. */
  52238. delayLoad(): void;
  52239. /**
  52240. * Parses a color grading texture serialized by Babylon.
  52241. * @param parsedTexture The texture information being parsedTexture
  52242. * @param scene The scene to load the texture in
  52243. * @param rootUrl The root url of the data assets to load
  52244. * @return A color gradind texture
  52245. */
  52246. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52247. /**
  52248. * Serializes the LUT texture to json format.
  52249. */
  52250. serialize(): any;
  52251. }
  52252. }
  52253. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52255. import { Scene } from "babylonjs/scene";
  52256. import { Nullable } from "babylonjs/types";
  52257. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52258. /**
  52259. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52260. */
  52261. export class EquiRectangularCubeTexture extends BaseTexture {
  52262. /** The six faces of the cube. */
  52263. private static _FacesMapping;
  52264. private _noMipmap;
  52265. private _onLoad;
  52266. private _onError;
  52267. /** The size of the cubemap. */
  52268. private _size;
  52269. /** The buffer of the image. */
  52270. private _buffer;
  52271. /** The width of the input image. */
  52272. private _width;
  52273. /** The height of the input image. */
  52274. private _height;
  52275. /** The URL to the image. */
  52276. url: string;
  52277. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52278. coordinatesMode: number;
  52279. /**
  52280. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52281. * @param url The location of the image
  52282. * @param scene The scene the texture will be used in
  52283. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52284. * @param noMipmap Forces to not generate the mipmap if true
  52285. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52286. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52287. * @param onLoad — defines a callback called when texture is loaded
  52288. * @param onError — defines a callback called if there is an error
  52289. */
  52290. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52291. /**
  52292. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52293. */
  52294. private loadImage;
  52295. /**
  52296. * Convert the image buffer into a cubemap and create a CubeTexture.
  52297. */
  52298. private loadTexture;
  52299. /**
  52300. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52301. * @param buffer The ArrayBuffer that should be converted.
  52302. * @returns The buffer as Float32Array.
  52303. */
  52304. private getFloat32ArrayFromArrayBuffer;
  52305. /**
  52306. * Get the current class name of the texture useful for serialization or dynamic coding.
  52307. * @returns "EquiRectangularCubeTexture"
  52308. */
  52309. getClassName(): string;
  52310. /**
  52311. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52312. * @returns A clone of the current EquiRectangularCubeTexture.
  52313. */
  52314. clone(): EquiRectangularCubeTexture;
  52315. }
  52316. }
  52317. declare module "babylonjs/Misc/tga" {
  52318. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52319. /**
  52320. * Based on jsTGALoader - Javascript loader for TGA file
  52321. * By Vincent Thibault
  52322. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52323. */
  52324. export class TGATools {
  52325. private static _TYPE_INDEXED;
  52326. private static _TYPE_RGB;
  52327. private static _TYPE_GREY;
  52328. private static _TYPE_RLE_INDEXED;
  52329. private static _TYPE_RLE_RGB;
  52330. private static _TYPE_RLE_GREY;
  52331. private static _ORIGIN_MASK;
  52332. private static _ORIGIN_SHIFT;
  52333. private static _ORIGIN_BL;
  52334. private static _ORIGIN_BR;
  52335. private static _ORIGIN_UL;
  52336. private static _ORIGIN_UR;
  52337. /**
  52338. * Gets the header of a TGA file
  52339. * @param data defines the TGA data
  52340. * @returns the header
  52341. */
  52342. static GetTGAHeader(data: Uint8Array): any;
  52343. /**
  52344. * Uploads TGA content to a Babylon Texture
  52345. * @hidden
  52346. */
  52347. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52348. /** @hidden */
  52349. 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;
  52350. /** @hidden */
  52351. 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;
  52352. /** @hidden */
  52353. 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;
  52354. /** @hidden */
  52355. 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;
  52356. /** @hidden */
  52357. 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;
  52358. /** @hidden */
  52359. 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;
  52360. }
  52361. }
  52362. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52363. import { Nullable } from "babylonjs/types";
  52364. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52365. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52366. /**
  52367. * Implementation of the TGA Texture Loader.
  52368. * @hidden
  52369. */
  52370. export class _TGATextureLoader implements IInternalTextureLoader {
  52371. /**
  52372. * Defines wether the loader supports cascade loading the different faces.
  52373. */
  52374. readonly supportCascades: boolean;
  52375. /**
  52376. * This returns if the loader support the current file information.
  52377. * @param extension defines the file extension of the file being loaded
  52378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52379. * @param fallback defines the fallback internal texture if any
  52380. * @param isBase64 defines whether the texture is encoded as a base64
  52381. * @param isBuffer defines whether the texture data are stored as a buffer
  52382. * @returns true if the loader can load the specified file
  52383. */
  52384. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52385. /**
  52386. * Transform the url before loading if required.
  52387. * @param rootUrl the url of the texture
  52388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52389. * @returns the transformed texture
  52390. */
  52391. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52392. /**
  52393. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52394. * @param rootUrl the url of the texture
  52395. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52396. * @returns the fallback texture
  52397. */
  52398. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52399. /**
  52400. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52401. * @param data contains the texture data
  52402. * @param texture defines the BabylonJS internal texture
  52403. * @param createPolynomials will be true if polynomials have been requested
  52404. * @param onLoad defines the callback to trigger once the texture is ready
  52405. * @param onError defines the callback to trigger in case of error
  52406. */
  52407. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52408. /**
  52409. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52410. * @param data contains the texture data
  52411. * @param texture defines the BabylonJS internal texture
  52412. * @param callback defines the method to call once ready to upload
  52413. */
  52414. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52415. }
  52416. }
  52417. declare module "babylonjs/Misc/basis" {
  52418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52419. /**
  52420. * Info about the .basis files
  52421. */
  52422. class BasisFileInfo {
  52423. /**
  52424. * If the file has alpha
  52425. */
  52426. hasAlpha: boolean;
  52427. /**
  52428. * Info about each image of the basis file
  52429. */
  52430. images: Array<{
  52431. levels: Array<{
  52432. width: number;
  52433. height: number;
  52434. transcodedPixels: ArrayBufferView;
  52435. }>;
  52436. }>;
  52437. }
  52438. /**
  52439. * Result of transcoding a basis file
  52440. */
  52441. class TranscodeResult {
  52442. /**
  52443. * Info about the .basis file
  52444. */
  52445. fileInfo: BasisFileInfo;
  52446. /**
  52447. * Format to use when loading the file
  52448. */
  52449. format: number;
  52450. }
  52451. /**
  52452. * Configuration options for the Basis transcoder
  52453. */
  52454. export class BasisTranscodeConfiguration {
  52455. /**
  52456. * Supported compression formats used to determine the supported output format of the transcoder
  52457. */
  52458. supportedCompressionFormats?: {
  52459. /**
  52460. * etc1 compression format
  52461. */
  52462. etc1?: boolean;
  52463. /**
  52464. * s3tc compression format
  52465. */
  52466. s3tc?: boolean;
  52467. /**
  52468. * pvrtc compression format
  52469. */
  52470. pvrtc?: boolean;
  52471. /**
  52472. * etc2 compression format
  52473. */
  52474. etc2?: boolean;
  52475. };
  52476. /**
  52477. * If mipmap levels should be loaded for transcoded images (Default: true)
  52478. */
  52479. loadMipmapLevels?: boolean;
  52480. /**
  52481. * Index of a single image to load (Default: all images)
  52482. */
  52483. loadSingleImage?: number;
  52484. }
  52485. /**
  52486. * Used to load .Basis files
  52487. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52488. */
  52489. export class BasisTools {
  52490. private static _IgnoreSupportedFormats;
  52491. /**
  52492. * URL to use when loading the basis transcoder
  52493. */
  52494. static JSModuleURL: string;
  52495. /**
  52496. * URL to use when loading the wasm module for the transcoder
  52497. */
  52498. static WasmModuleURL: string;
  52499. /**
  52500. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52501. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52502. * @returns internal format corresponding to the Basis format
  52503. */
  52504. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52505. private static _WorkerPromise;
  52506. private static _Worker;
  52507. private static _actionId;
  52508. private static _CreateWorkerAsync;
  52509. /**
  52510. * Transcodes a loaded image file to compressed pixel data
  52511. * @param imageData image data to transcode
  52512. * @param config configuration options for the transcoding
  52513. * @returns a promise resulting in the transcoded image
  52514. */
  52515. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52516. /**
  52517. * Loads a texture from the transcode result
  52518. * @param texture texture load to
  52519. * @param transcodeResult the result of transcoding the basis file to load from
  52520. */
  52521. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52522. }
  52523. }
  52524. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52525. import { Nullable } from "babylonjs/types";
  52526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52527. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52528. /**
  52529. * Loader for .basis file format
  52530. */
  52531. export class _BasisTextureLoader implements IInternalTextureLoader {
  52532. /**
  52533. * Defines whether the loader supports cascade loading the different faces.
  52534. */
  52535. readonly supportCascades: boolean;
  52536. /**
  52537. * This returns if the loader support the current file information.
  52538. * @param extension defines the file extension of the file being loaded
  52539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52540. * @param fallback defines the fallback internal texture if any
  52541. * @param isBase64 defines whether the texture is encoded as a base64
  52542. * @param isBuffer defines whether the texture data are stored as a buffer
  52543. * @returns true if the loader can load the specified file
  52544. */
  52545. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52546. /**
  52547. * Transform the url before loading if required.
  52548. * @param rootUrl the url of the texture
  52549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52550. * @returns the transformed texture
  52551. */
  52552. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52553. /**
  52554. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52555. * @param rootUrl the url of the texture
  52556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52557. * @returns the fallback texture
  52558. */
  52559. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52560. /**
  52561. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52562. * @param data contains the texture data
  52563. * @param texture defines the BabylonJS internal texture
  52564. * @param createPolynomials will be true if polynomials have been requested
  52565. * @param onLoad defines the callback to trigger once the texture is ready
  52566. * @param onError defines the callback to trigger in case of error
  52567. */
  52568. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52569. /**
  52570. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52571. * @param data contains the texture data
  52572. * @param texture defines the BabylonJS internal texture
  52573. * @param callback defines the method to call once ready to upload
  52574. */
  52575. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52576. }
  52577. }
  52578. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52579. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52580. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52581. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52582. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52583. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52584. }
  52585. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52586. import { Scene } from "babylonjs/scene";
  52587. import { Texture } from "babylonjs/Materials/Textures/texture";
  52588. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52589. /**
  52590. * 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.
  52591. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52592. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52593. */
  52594. export class CustomProceduralTexture extends ProceduralTexture {
  52595. private _animate;
  52596. private _time;
  52597. private _config;
  52598. private _texturePath;
  52599. /**
  52600. * Instantiates a new Custom Procedural Texture.
  52601. * 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.
  52602. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52603. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52604. * @param name Define the name of the texture
  52605. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52606. * @param size Define the size of the texture to create
  52607. * @param scene Define the scene the texture belongs to
  52608. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52609. * @param generateMipMaps Define if the texture should creates mip maps or not
  52610. */
  52611. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52612. private _loadJson;
  52613. /**
  52614. * Is the texture ready to be used ? (rendered at least once)
  52615. * @returns true if ready, otherwise, false.
  52616. */
  52617. isReady(): boolean;
  52618. /**
  52619. * Render the texture to its associated render target.
  52620. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52621. */
  52622. render(useCameraPostProcess?: boolean): void;
  52623. /**
  52624. * Update the list of dependant textures samplers in the shader.
  52625. */
  52626. updateTextures(): void;
  52627. /**
  52628. * Update the uniform values of the procedural texture in the shader.
  52629. */
  52630. updateShaderUniforms(): void;
  52631. /**
  52632. * Define if the texture animates or not.
  52633. */
  52634. animate: boolean;
  52635. }
  52636. }
  52637. declare module "babylonjs/Shaders/noise.fragment" {
  52638. /** @hidden */
  52639. export var noisePixelShader: {
  52640. name: string;
  52641. shader: string;
  52642. };
  52643. }
  52644. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52645. import { Nullable } from "babylonjs/types";
  52646. import { Scene } from "babylonjs/scene";
  52647. import { Texture } from "babylonjs/Materials/Textures/texture";
  52648. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52649. import "babylonjs/Shaders/noise.fragment";
  52650. /**
  52651. * Class used to generate noise procedural textures
  52652. */
  52653. export class NoiseProceduralTexture extends ProceduralTexture {
  52654. private _time;
  52655. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52656. brightness: number;
  52657. /** Defines the number of octaves to process */
  52658. octaves: number;
  52659. /** Defines the level of persistence (0.8 by default) */
  52660. persistence: number;
  52661. /** Gets or sets animation speed factor (default is 1) */
  52662. animationSpeedFactor: number;
  52663. /**
  52664. * Creates a new NoiseProceduralTexture
  52665. * @param name defines the name fo the texture
  52666. * @param size defines the size of the texture (default is 256)
  52667. * @param scene defines the hosting scene
  52668. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52669. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52670. */
  52671. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52672. private _updateShaderUniforms;
  52673. protected _getDefines(): string;
  52674. /** Generate the current state of the procedural texture */
  52675. render(useCameraPostProcess?: boolean): void;
  52676. /**
  52677. * Serializes this noise procedural texture
  52678. * @returns a serialized noise procedural texture object
  52679. */
  52680. serialize(): any;
  52681. /**
  52682. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52683. * @param parsedTexture defines parsed texture data
  52684. * @param scene defines the current scene
  52685. * @param rootUrl defines the root URL containing noise procedural texture information
  52686. * @returns a parsed NoiseProceduralTexture
  52687. */
  52688. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52689. }
  52690. }
  52691. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52692. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52693. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52694. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52695. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52696. }
  52697. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52698. import { Nullable } from "babylonjs/types";
  52699. import { Scene } from "babylonjs/scene";
  52700. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52701. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52702. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52703. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52704. /**
  52705. * Raw cube texture where the raw buffers are passed in
  52706. */
  52707. export class RawCubeTexture extends CubeTexture {
  52708. /**
  52709. * Creates a cube texture where the raw buffers are passed in.
  52710. * @param scene defines the scene the texture is attached to
  52711. * @param data defines the array of data to use to create each face
  52712. * @param size defines the size of the textures
  52713. * @param format defines the format of the data
  52714. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52715. * @param generateMipMaps defines if the engine should generate the mip levels
  52716. * @param invertY defines if data must be stored with Y axis inverted
  52717. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52718. * @param compression defines the compression used (null by default)
  52719. */
  52720. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52721. /**
  52722. * Updates the raw cube texture.
  52723. * @param data defines the data to store
  52724. * @param format defines the data format
  52725. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52726. * @param invertY defines if data must be stored with Y axis inverted
  52727. * @param compression defines the compression used (null by default)
  52728. * @param level defines which level of the texture to update
  52729. */
  52730. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52731. /**
  52732. * Updates a raw cube texture with RGBD encoded data.
  52733. * @param data defines the array of data [mipmap][face] to use to create each face
  52734. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52735. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52736. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52737. * @returns a promsie that resolves when the operation is complete
  52738. */
  52739. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52740. /**
  52741. * Clones the raw cube texture.
  52742. * @return a new cube texture
  52743. */
  52744. clone(): CubeTexture;
  52745. /** @hidden */
  52746. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52747. }
  52748. }
  52749. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52750. import { Scene } from "babylonjs/scene";
  52751. import { Texture } from "babylonjs/Materials/Textures/texture";
  52752. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52753. /**
  52754. * Class used to store 3D textures containing user data
  52755. */
  52756. export class RawTexture3D extends Texture {
  52757. /** Gets or sets the texture format to use */
  52758. format: number;
  52759. private _engine;
  52760. /**
  52761. * Create a new RawTexture3D
  52762. * @param data defines the data of the texture
  52763. * @param width defines the width of the texture
  52764. * @param height defines the height of the texture
  52765. * @param depth defines the depth of the texture
  52766. * @param format defines the texture format to use
  52767. * @param scene defines the hosting scene
  52768. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52769. * @param invertY defines if texture must be stored with Y axis inverted
  52770. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52771. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52772. */
  52773. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52774. /** Gets or sets the texture format to use */
  52775. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52776. /**
  52777. * Update the texture with new data
  52778. * @param data defines the data to store in the texture
  52779. */
  52780. update(data: ArrayBufferView): void;
  52781. }
  52782. }
  52783. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52784. import { Scene } from "babylonjs/scene";
  52785. import { Plane } from "babylonjs/Maths/math";
  52786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52787. /**
  52788. * Creates a refraction texture used by refraction channel of the standard material.
  52789. * It is like a mirror but to see through a material.
  52790. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52791. */
  52792. export class RefractionTexture extends RenderTargetTexture {
  52793. /**
  52794. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52795. * 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.
  52796. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52797. */
  52798. refractionPlane: Plane;
  52799. /**
  52800. * Define how deep under the surface we should see.
  52801. */
  52802. depth: number;
  52803. /**
  52804. * Creates a refraction texture used by refraction channel of the standard material.
  52805. * It is like a mirror but to see through a material.
  52806. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52807. * @param name Define the texture name
  52808. * @param size Define the size of the underlying texture
  52809. * @param scene Define the scene the refraction belongs to
  52810. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52811. */
  52812. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52813. /**
  52814. * Clone the refraction texture.
  52815. * @returns the cloned texture
  52816. */
  52817. clone(): RefractionTexture;
  52818. /**
  52819. * Serialize the texture to a JSON representation you could use in Parse later on
  52820. * @returns the serialized JSON representation
  52821. */
  52822. serialize(): any;
  52823. }
  52824. }
  52825. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52826. import { Nullable } from "babylonjs/types";
  52827. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52828. import { Matrix } from "babylonjs/Maths/math";
  52829. import { Engine } from "babylonjs/Engines/engine";
  52830. import { Scene } from "babylonjs/scene";
  52831. /**
  52832. * Defines the options related to the creation of an HtmlElementTexture
  52833. */
  52834. export interface IHtmlElementTextureOptions {
  52835. /**
  52836. * Defines wether mip maps should be created or not.
  52837. */
  52838. generateMipMaps?: boolean;
  52839. /**
  52840. * Defines the sampling mode of the texture.
  52841. */
  52842. samplingMode?: number;
  52843. /**
  52844. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52845. */
  52846. engine: Nullable<Engine>;
  52847. /**
  52848. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52849. */
  52850. scene: Nullable<Scene>;
  52851. }
  52852. /**
  52853. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52854. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52855. * is automatically managed.
  52856. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52857. * in your application.
  52858. *
  52859. * As the update is not automatic, you need to call them manually.
  52860. */
  52861. export class HtmlElementTexture extends BaseTexture {
  52862. /**
  52863. * The texture URL.
  52864. */
  52865. element: HTMLVideoElement | HTMLCanvasElement;
  52866. private static readonly DefaultOptions;
  52867. private _textureMatrix;
  52868. private _engine;
  52869. private _isVideo;
  52870. private _generateMipMaps;
  52871. private _samplingMode;
  52872. /**
  52873. * Instantiates a HtmlElementTexture from the following parameters.
  52874. *
  52875. * @param name Defines the name of the texture
  52876. * @param element Defines the video or canvas the texture is filled with
  52877. * @param options Defines the other none mandatory texture creation options
  52878. */
  52879. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52880. private _createInternalTexture;
  52881. /**
  52882. * Returns the texture matrix used in most of the material.
  52883. */
  52884. getTextureMatrix(): Matrix;
  52885. /**
  52886. * Updates the content of the texture.
  52887. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52888. */
  52889. update(invertY?: Nullable<boolean>): void;
  52890. }
  52891. }
  52892. declare module "babylonjs/Materials/Textures/index" {
  52893. export * from "babylonjs/Materials/Textures/baseTexture";
  52894. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52895. export * from "babylonjs/Materials/Textures/cubeTexture";
  52896. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52897. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52898. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52899. export * from "babylonjs/Materials/Textures/internalTexture";
  52900. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52901. export * from "babylonjs/Materials/Textures/Loaders/index";
  52902. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52903. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52904. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52905. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52906. export * from "babylonjs/Materials/Textures/rawTexture";
  52907. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52908. export * from "babylonjs/Materials/Textures/refractionTexture";
  52909. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52910. export * from "babylonjs/Materials/Textures/texture";
  52911. export * from "babylonjs/Materials/Textures/videoTexture";
  52912. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52913. }
  52914. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52915. /**
  52916. * Enum used to define the target of a block
  52917. */
  52918. export enum NodeMaterialBlockTargets {
  52919. /** Vertex shader */
  52920. Vertex = 1,
  52921. /** Fragment shader */
  52922. Fragment = 2,
  52923. /** Vertex and Fragment */
  52924. VertexAndFragment = 3
  52925. }
  52926. }
  52927. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52928. /**
  52929. * Defines the kind of connection point for node based material
  52930. */
  52931. export enum NodeMaterialBlockConnectionPointTypes {
  52932. /** Float */
  52933. Float = 1,
  52934. /** Int */
  52935. Int = 2,
  52936. /** Vector2 */
  52937. Vector2 = 4,
  52938. /** Vector3 */
  52939. Vector3 = 8,
  52940. /** Vector4 */
  52941. Vector4 = 16,
  52942. /** Color3 */
  52943. Color3 = 32,
  52944. /** Color4 */
  52945. Color4 = 64,
  52946. /** Matrix */
  52947. Matrix = 128,
  52948. /** Texture */
  52949. Texture = 256,
  52950. /** Texture3D */
  52951. Texture3D = 512,
  52952. /** Vector3 or Color3 */
  52953. Vector3OrColor3 = 40,
  52954. /** Vector3 or Vector4 */
  52955. Vector3OrVector4 = 24,
  52956. /** Vector4 or Color4 */
  52957. Vector4OrColor4 = 80,
  52958. /** Color3 or Color4 */
  52959. Color3OrColor4 = 96,
  52960. /** Vector3 or Color3 */
  52961. Vector3OrColor3OrVector4OrColor4 = 120,
  52962. /** Detect type based on connection */
  52963. AutoDetect = 1024,
  52964. /** Output type that will be defined by input type */
  52965. BasedOnInput = 2048,
  52966. /** Light */
  52967. Light = 4096
  52968. }
  52969. }
  52970. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52971. /**
  52972. * Enum used to define well known values e.g. values automatically provided by the system
  52973. */
  52974. export enum NodeMaterialWellKnownValues {
  52975. /** World */
  52976. World = 1,
  52977. /** View */
  52978. View = 2,
  52979. /** Projection */
  52980. Projection = 3,
  52981. /** ViewProjection */
  52982. ViewProjection = 4,
  52983. /** WorldView */
  52984. WorldView = 5,
  52985. /** WorldViewProjection */
  52986. WorldViewProjection = 6,
  52987. /** CameraPosition */
  52988. CameraPosition = 7,
  52989. /** Will be filled by the block itself */
  52990. Automatic = 8
  52991. }
  52992. }
  52993. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52994. /**
  52995. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52996. */
  52997. export enum NodeMaterialBlockConnectionPointMode {
  52998. /** Value is an uniform */
  52999. Uniform = 0,
  53000. /** Value is a mesh attribute */
  53001. Attribute = 1,
  53002. /** Value is a varying between vertex and fragment shaders */
  53003. Varying = 2,
  53004. /** Mode is undefined */
  53005. Undefined = 3
  53006. }
  53007. }
  53008. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53011. /**
  53012. * Class used to store shared data between 2 NodeMaterialBuildState
  53013. */
  53014. export class NodeMaterialBuildStateSharedData {
  53015. /**
  53016. * Gets the list of emitted varyings
  53017. */
  53018. varyings: string[];
  53019. /**
  53020. * Gets the varying declaration string
  53021. */
  53022. varyingDeclaration: string;
  53023. /**
  53024. * Uniform connection points
  53025. */
  53026. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  53027. /**
  53028. * Bindable blocks (Blocks that need to set data to the effect)
  53029. */
  53030. bindableBlocks: NodeMaterialBlock[];
  53031. /**
  53032. * List of blocks that can provide a compilation fallback
  53033. */
  53034. blocksWithFallbacks: NodeMaterialBlock[];
  53035. /**
  53036. * List of blocks that can provide a define update
  53037. */
  53038. blocksWithDefines: NodeMaterialBlock[];
  53039. /**
  53040. * List of blocks that can provide a repeatable content
  53041. */
  53042. repeatableContentBlocks: NodeMaterialBlock[];
  53043. /**
  53044. * List of blocks that can block the isReady function for the material
  53045. */
  53046. blockingBlocks: NodeMaterialBlock[];
  53047. /**
  53048. * Build Id used to avoid multiple recompilations
  53049. */
  53050. buildId: number;
  53051. /** List of emitted variables */
  53052. variableNames: {
  53053. [key: string]: number;
  53054. };
  53055. /** List of emitted defines */
  53056. defineNames: {
  53057. [key: string]: number;
  53058. };
  53059. /** Should emit comments? */
  53060. emitComments: boolean;
  53061. /** Emit build activity */
  53062. verbose: boolean;
  53063. /**
  53064. * Gets the compilation hints emitted at compilation time
  53065. */
  53066. hints: {
  53067. needWorldViewMatrix: boolean;
  53068. needWorldViewProjectionMatrix: boolean;
  53069. needAlphaBlending: boolean;
  53070. needAlphaTesting: boolean;
  53071. };
  53072. /**
  53073. * List of compilation checks
  53074. */
  53075. checks: {
  53076. emitVertex: boolean;
  53077. emitFragment: boolean;
  53078. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53079. };
  53080. /** Creates a new shared data */
  53081. constructor();
  53082. /**
  53083. * Emits console errors and exceptions if there is a failing check
  53084. */
  53085. emitErrors(): void;
  53086. }
  53087. }
  53088. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53090. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53091. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53092. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53093. import { Nullable } from "babylonjs/types";
  53094. /**
  53095. * Class used to store node based material build state
  53096. */
  53097. export class NodeMaterialBuildState {
  53098. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53099. supportUniformBuffers: boolean;
  53100. /**
  53101. * Gets the list of emitted attributes
  53102. */
  53103. attributes: string[];
  53104. /**
  53105. * Gets the list of emitted uniforms
  53106. */
  53107. uniforms: string[];
  53108. /**
  53109. * Gets the list of emitted uniform buffers
  53110. */
  53111. uniformBuffers: string[];
  53112. /**
  53113. * Gets the list of emitted samplers
  53114. */
  53115. samplers: string[];
  53116. /**
  53117. * Gets the list of emitted functions
  53118. */
  53119. functions: {
  53120. [key: string]: string;
  53121. };
  53122. /**
  53123. * Gets the target of the compilation state
  53124. */
  53125. target: NodeMaterialBlockTargets;
  53126. /**
  53127. * Gets the list of emitted counters
  53128. */
  53129. counters: {
  53130. [key: string]: number;
  53131. };
  53132. /**
  53133. * Shared data between multiple NodeMaterialBuildState instances
  53134. */
  53135. sharedData: NodeMaterialBuildStateSharedData;
  53136. /** @hidden */
  53137. _vertexState: NodeMaterialBuildState;
  53138. private _attributeDeclaration;
  53139. private _uniformDeclaration;
  53140. private _samplerDeclaration;
  53141. private _varyingTransfer;
  53142. private _repeatableContentAnchorIndex;
  53143. /** @hidden */
  53144. _builtCompilationString: string;
  53145. /**
  53146. * Gets the emitted compilation strings
  53147. */
  53148. compilationString: string;
  53149. /**
  53150. * Finalize the compilation strings
  53151. * @param state defines the current compilation state
  53152. */
  53153. finalize(state: NodeMaterialBuildState): void;
  53154. /** @hidden */
  53155. readonly _repeatableContentAnchor: string;
  53156. /** @hidden */
  53157. _getFreeVariableName(prefix: string): string;
  53158. /** @hidden */
  53159. _getFreeDefineName(prefix: string): string;
  53160. /** @hidden */
  53161. _excludeVariableName(name: string): void;
  53162. /** @hidden */
  53163. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53164. /** @hidden */
  53165. _emitFunction(name: string, code: string, comments: string): void;
  53166. /** @hidden */
  53167. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53168. replaceStrings?: {
  53169. search: RegExp;
  53170. replace: string;
  53171. }[];
  53172. }): string;
  53173. /** @hidden */
  53174. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53175. repeatKey?: string;
  53176. removeAttributes?: boolean;
  53177. removeUniforms?: boolean;
  53178. removeVaryings?: boolean;
  53179. removeIfDef?: boolean;
  53180. replaceStrings?: {
  53181. search: RegExp;
  53182. replace: string;
  53183. }[];
  53184. }, storeKey?: string): void;
  53185. /** @hidden */
  53186. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  53187. private _emitDefine;
  53188. /** @hidden */
  53189. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  53190. }
  53191. }
  53192. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53194. /**
  53195. * Root class for all node material optimizers
  53196. */
  53197. export class NodeMaterialOptimizer {
  53198. /**
  53199. * Function used to optimize a NodeMaterial graph
  53200. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53201. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53202. */
  53203. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53204. }
  53205. }
  53206. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53210. /**
  53211. * Block used to transform a vector4 with a matrix
  53212. */
  53213. export class Vector4TransformBlock extends NodeMaterialBlock {
  53214. /**
  53215. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53216. */
  53217. complementW: number;
  53218. /**
  53219. * Creates a new Vector4TransformBlock
  53220. * @param name defines the block name
  53221. */
  53222. constructor(name: string);
  53223. /**
  53224. * Gets the current class name
  53225. * @returns the class name
  53226. */
  53227. getClassName(): string;
  53228. /**
  53229. * Gets the vector input
  53230. */
  53231. readonly vector: NodeMaterialConnectionPoint;
  53232. /**
  53233. * Gets the output component
  53234. */
  53235. readonly output: NodeMaterialConnectionPoint;
  53236. /**
  53237. * Gets the matrix transform input
  53238. */
  53239. readonly transform: NodeMaterialConnectionPoint;
  53240. protected _buildBlock(state: NodeMaterialBuildState): this;
  53241. }
  53242. }
  53243. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53247. /**
  53248. * Block used to output the vertex position
  53249. */
  53250. export class VertexOutputBlock extends NodeMaterialBlock {
  53251. /**
  53252. * Creates a new VertexOutputBlock
  53253. * @param name defines the block name
  53254. */
  53255. constructor(name: string);
  53256. /**
  53257. * Gets the current class name
  53258. * @returns the class name
  53259. */
  53260. getClassName(): string;
  53261. /**
  53262. * Gets the vector input component
  53263. */
  53264. readonly vector: NodeMaterialConnectionPoint;
  53265. protected _buildBlock(state: NodeMaterialBuildState): this;
  53266. }
  53267. }
  53268. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53272. /**
  53273. * Block used to output the final color
  53274. */
  53275. export class FragmentOutputBlock extends NodeMaterialBlock {
  53276. /**
  53277. * Gets or sets a boolean indicating if this block will output an alpha value
  53278. */
  53279. alphaBlendingEnabled: boolean;
  53280. /**
  53281. * Create a new FragmentOutputBlock
  53282. * @param name defines the block name
  53283. */
  53284. constructor(name: string);
  53285. /**
  53286. * Gets the current class name
  53287. * @returns the class name
  53288. */
  53289. getClassName(): string;
  53290. /**
  53291. * Gets the color input component
  53292. */
  53293. readonly color: NodeMaterialConnectionPoint;
  53294. protected _buildBlock(state: NodeMaterialBuildState): this;
  53295. }
  53296. }
  53297. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53299. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53300. import { Scene } from "babylonjs/scene";
  53301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53302. import { Matrix } from "babylonjs/Maths/math";
  53303. import { Mesh } from "babylonjs/Meshes/mesh";
  53304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53305. import { Observable } from "babylonjs/Misc/observable";
  53306. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53307. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53308. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53309. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53310. import { Nullable } from "babylonjs/types";
  53311. /**
  53312. * Interface used to configure the node material editor
  53313. */
  53314. export interface INodeMaterialEditorOptions {
  53315. /** Define the URl to load node editor script */
  53316. editorURL?: string;
  53317. }
  53318. /** @hidden */
  53319. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53320. /** BONES */
  53321. NUM_BONE_INFLUENCERS: number;
  53322. BonesPerMesh: number;
  53323. BONETEXTURE: boolean;
  53324. /** MORPH TARGETS */
  53325. MORPHTARGETS: boolean;
  53326. MORPHTARGETS_NORMAL: boolean;
  53327. MORPHTARGETS_TANGENT: boolean;
  53328. MORPHTARGETS_UV: boolean;
  53329. NUM_MORPH_INFLUENCERS: number;
  53330. /** IMAGE PROCESSING */
  53331. IMAGEPROCESSING: boolean;
  53332. VIGNETTE: boolean;
  53333. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53334. VIGNETTEBLENDMODEOPAQUE: boolean;
  53335. TONEMAPPING: boolean;
  53336. TONEMAPPING_ACES: boolean;
  53337. CONTRAST: boolean;
  53338. EXPOSURE: boolean;
  53339. COLORCURVES: boolean;
  53340. COLORGRADING: boolean;
  53341. COLORGRADING3D: boolean;
  53342. SAMPLER3DGREENDEPTH: boolean;
  53343. SAMPLER3DBGRMAP: boolean;
  53344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53345. constructor();
  53346. setValue(name: string, value: boolean): void;
  53347. }
  53348. /**
  53349. * Class used to configure NodeMaterial
  53350. */
  53351. export interface INodeMaterialOptions {
  53352. /**
  53353. * Defines if blocks should emit comments
  53354. */
  53355. emitComments: boolean;
  53356. }
  53357. /**
  53358. * Class used to create a node based material built by assembling shader blocks
  53359. */
  53360. export class NodeMaterial extends PushMaterial {
  53361. private _options;
  53362. private _vertexCompilationState;
  53363. private _fragmentCompilationState;
  53364. private _sharedData;
  53365. private _buildId;
  53366. private _buildWasSuccessful;
  53367. private _cachedWorldViewMatrix;
  53368. private _cachedWorldViewProjectionMatrix;
  53369. private _textureConnectionPoints;
  53370. private _optimizers;
  53371. /** Define the URl to load node editor script */
  53372. static EditorURL: string;
  53373. private BJSNODEMATERIALEDITOR;
  53374. /** Get the inspector from bundle or global */
  53375. private _getGlobalNodeMaterialEditor;
  53376. /**
  53377. * Defines the maximum number of lights that can be used in the material
  53378. */
  53379. maxSimultaneousLights: number;
  53380. /**
  53381. * Observable raised when the material is built
  53382. */
  53383. onBuildObservable: Observable<NodeMaterial>;
  53384. /**
  53385. * Gets or sets the root nodes of the material vertex shader
  53386. */
  53387. _vertexOutputNodes: NodeMaterialBlock[];
  53388. /**
  53389. * Gets or sets the root nodes of the material fragment (pixel) shader
  53390. */
  53391. _fragmentOutputNodes: NodeMaterialBlock[];
  53392. /** Gets or sets options to control the node material overall behavior */
  53393. options: INodeMaterialOptions;
  53394. /**
  53395. * Default configuration related to image processing available in the standard Material.
  53396. */
  53397. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53398. /**
  53399. * Gets the image processing configuration used either in this material.
  53400. */
  53401. /**
  53402. * Sets the Default image processing configuration used either in the this material.
  53403. *
  53404. * If sets to null, the scene one is in use.
  53405. */
  53406. imageProcessingConfiguration: ImageProcessingConfiguration;
  53407. /**
  53408. * Create a new node based material
  53409. * @param name defines the material name
  53410. * @param scene defines the hosting scene
  53411. * @param options defines creation option
  53412. */
  53413. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53414. /**
  53415. * Gets the current class name of the material e.g. "NodeMaterial"
  53416. * @returns the class name
  53417. */
  53418. getClassName(): string;
  53419. /**
  53420. * Keep track of the image processing observer to allow dispose and replace.
  53421. */
  53422. private _imageProcessingObserver;
  53423. /**
  53424. * Attaches a new image processing configuration to the Standard Material.
  53425. * @param configuration
  53426. */
  53427. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53428. /**
  53429. * Adds a new optimizer to the list of optimizers
  53430. * @param optimizer defines the optimizers to add
  53431. * @returns the current material
  53432. */
  53433. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53434. /**
  53435. * Remove an optimizer from the list of optimizers
  53436. * @param optimizer defines the optimizers to remove
  53437. * @returns the current material
  53438. */
  53439. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53440. /**
  53441. * Add a new block to the list of output nodes
  53442. * @param node defines the node to add
  53443. * @returns the current material
  53444. */
  53445. addOutputNode(node: NodeMaterialBlock): this;
  53446. /**
  53447. * Remove a block from the list of root nodes
  53448. * @param node defines the node to remove
  53449. * @returns the current material
  53450. */
  53451. removeOutputNode(node: NodeMaterialBlock): this;
  53452. private _addVertexOutputNode;
  53453. private _removeVertexOutputNode;
  53454. private _addFragmentOutputNode;
  53455. private _removeFragmentOutputNode;
  53456. /**
  53457. * Specifies if the material will require alpha blending
  53458. * @returns a boolean specifying if alpha blending is needed
  53459. */
  53460. needAlphaBlending(): boolean;
  53461. /**
  53462. * Specifies if this material should be rendered in alpha test mode
  53463. * @returns a boolean specifying if an alpha test is needed.
  53464. */
  53465. needAlphaTesting(): boolean;
  53466. private _initializeBlock;
  53467. private _resetDualBlocks;
  53468. /**
  53469. * Build the material and generates the inner effect
  53470. * @param verbose defines if the build should log activity
  53471. */
  53472. build(verbose?: boolean): void;
  53473. /**
  53474. * Runs an otpimization phase to try to improve the shader code
  53475. */
  53476. optimize(): void;
  53477. private _prepareDefinesForAttributes;
  53478. /**
  53479. * Get if the submesh is ready to be used and all its information available.
  53480. * Child classes can use it to update shaders
  53481. * @param mesh defines the mesh to check
  53482. * @param subMesh defines which submesh to check
  53483. * @param useInstances specifies that instances should be used
  53484. * @returns a boolean indicating that the submesh is ready or not
  53485. */
  53486. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53487. /**
  53488. * Binds the world matrix to the material
  53489. * @param world defines the world transformation matrix
  53490. */
  53491. bindOnlyWorldMatrix(world: Matrix): void;
  53492. /**
  53493. * Binds the submesh to this material by preparing the effect and shader to draw
  53494. * @param world defines the world transformation matrix
  53495. * @param mesh defines the mesh containing the submesh
  53496. * @param subMesh defines the submesh to bind the material to
  53497. */
  53498. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53499. /**
  53500. * Gets the active textures from the material
  53501. * @returns an array of textures
  53502. */
  53503. getActiveTextures(): BaseTexture[];
  53504. /**
  53505. * Specifies if the material uses a texture
  53506. * @param texture defines the texture to check against the material
  53507. * @returns a boolean specifying if the material uses the texture
  53508. */
  53509. hasTexture(texture: BaseTexture): boolean;
  53510. /**
  53511. * Disposes the material
  53512. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53513. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53514. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53515. */
  53516. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53517. /** Creates the node editor window. */
  53518. private _createNodeEditor;
  53519. /**
  53520. * Launch the node material editor
  53521. * @param config Define the configuration of the editor
  53522. * @return a promise fulfilled when the node editor is visible
  53523. */
  53524. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53525. /**
  53526. * Clear the current material
  53527. */
  53528. clear(): void;
  53529. /**
  53530. * Clear the current material and set it to a default state
  53531. */
  53532. setToDefault(): void;
  53533. }
  53534. }
  53535. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53536. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53538. import { Nullable } from "babylonjs/types";
  53539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53540. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53541. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53543. import { Mesh } from "babylonjs/Meshes/mesh";
  53544. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53545. /**
  53546. * Defines a block that can be used inside a node based material
  53547. */
  53548. export class NodeMaterialBlock {
  53549. private _buildId;
  53550. private _target;
  53551. private _isFinalMerger;
  53552. /** @hidden */
  53553. _inputs: NodeMaterialConnectionPoint[];
  53554. /** @hidden */
  53555. _outputs: NodeMaterialConnectionPoint[];
  53556. /**
  53557. * Gets or sets the name of the block
  53558. */
  53559. name: string;
  53560. /**
  53561. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53562. */
  53563. readonly isFinalMerger: boolean;
  53564. /**
  53565. * Gets or sets the build Id
  53566. */
  53567. buildId: number;
  53568. /**
  53569. * Gets or sets the target of the block
  53570. */
  53571. target: NodeMaterialBlockTargets;
  53572. /**
  53573. * Gets the list of input points
  53574. */
  53575. readonly inputs: NodeMaterialConnectionPoint[];
  53576. /** Gets the list of output points */
  53577. readonly outputs: NodeMaterialConnectionPoint[];
  53578. /**
  53579. * Find an input by its name
  53580. * @param name defines the name of the input to look for
  53581. * @returns the input or null if not found
  53582. */
  53583. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53584. /**
  53585. * Find an output by its name
  53586. * @param name defines the name of the outputto look for
  53587. * @returns the output or null if not found
  53588. */
  53589. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53590. /**
  53591. * Creates a new NodeMaterialBlock
  53592. * @param name defines the block name
  53593. * @param target defines the target of that block (Vertex by default)
  53594. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53595. */
  53596. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53597. /**
  53598. * Initialize the block and prepare the context for build
  53599. * @param state defines the state that will be used for the build
  53600. */
  53601. initialize(state: NodeMaterialBuildState): void;
  53602. /**
  53603. * Bind data to effect. Will only be called for blocks with isBindable === true
  53604. * @param effect defines the effect to bind data to
  53605. * @param nodeMaterial defines the hosting NodeMaterial
  53606. * @param mesh defines the mesh that will be rendered
  53607. */
  53608. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53609. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53610. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53611. protected _writeFloat(value: number): string;
  53612. /**
  53613. * Gets the current class name e.g. "NodeMaterialBlock"
  53614. * @returns the class name
  53615. */
  53616. getClassName(): string;
  53617. /**
  53618. * Register a new input. Must be called inside a block constructor
  53619. * @param name defines the connection point name
  53620. * @param type defines the connection point type
  53621. * @param isOptional defines a boolean indicating that this input can be omitted
  53622. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53623. * @returns the current block
  53624. */
  53625. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53626. /**
  53627. * Register a new output. Must be called inside a block constructor
  53628. * @param name defines the connection point name
  53629. * @param type defines the connection point type
  53630. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53631. * @returns the current block
  53632. */
  53633. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53634. /**
  53635. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53636. * @param forOutput defines an optional connection point to check compatibility with
  53637. * @returns the first available input or null
  53638. */
  53639. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53640. /**
  53641. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53642. * @param forBlock defines an optional block to check compatibility with
  53643. * @returns the first available input or null
  53644. */
  53645. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53646. /**
  53647. * Connect current block with another block
  53648. * @param other defines the block to connect with
  53649. * @param options define the various options to help pick the right connections
  53650. * @returns the current block
  53651. */
  53652. connectTo(other: NodeMaterialBlock, options?: {
  53653. input?: string;
  53654. output?: string;
  53655. outputSwizzle?: string;
  53656. }): this | undefined;
  53657. protected _buildBlock(state: NodeMaterialBuildState): void;
  53658. /**
  53659. * Add potential fallbacks if shader compilation fails
  53660. * @param mesh defines the mesh to be rendered
  53661. * @param fallbacks defines the current prioritized list of fallbacks
  53662. */
  53663. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53664. /**
  53665. * Update defines for shader compilation
  53666. * @param mesh defines the mesh to be rendered
  53667. * @param nodeMaterial defines the node material requesting the update
  53668. * @param defines defines the material defines to update
  53669. * @param useInstances specifies that instances should be used
  53670. */
  53671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53672. /**
  53673. * Lets the block try to connect some inputs automatically
  53674. */
  53675. autoConfigure(): void;
  53676. /**
  53677. * Function called when a block is declared as repeatable content generator
  53678. * @param vertexShaderState defines the current compilation state for the vertex shader
  53679. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53680. * @param mesh defines the mesh to be rendered
  53681. * @param defines defines the material defines to update
  53682. */
  53683. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53684. /**
  53685. * Checks if the block is ready
  53686. * @param mesh defines the mesh to be rendered
  53687. * @param nodeMaterial defines the node material requesting the update
  53688. * @param defines defines the material defines to update
  53689. * @param useInstances specifies that instances should be used
  53690. * @returns true if the block is ready
  53691. */
  53692. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53693. /**
  53694. * Compile the current node and generate the shader code
  53695. * @param state defines the current compilation state (uniforms, samplers, current string)
  53696. * @returns the current block
  53697. */
  53698. build(state: NodeMaterialBuildState): this | undefined;
  53699. }
  53700. }
  53701. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53702. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53703. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53704. import { Nullable } from "babylonjs/types";
  53705. import { Effect } from "babylonjs/Materials/effect";
  53706. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53707. import { Scene } from "babylonjs/scene";
  53708. import { Matrix } from "babylonjs/Maths/math";
  53709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53710. /**
  53711. * Defines a connection point for a block
  53712. */
  53713. export class NodeMaterialConnectionPoint {
  53714. /** @hidden */
  53715. _ownerBlock: NodeMaterialBlock;
  53716. /** @hidden */
  53717. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53718. private _associatedVariableName;
  53719. private _endpoints;
  53720. private _storedValue;
  53721. private _valueCallback;
  53722. private _mode;
  53723. /** @hidden */
  53724. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53725. /** @hidden */
  53726. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53727. /** @hidden */
  53728. _needToEmitVarying: boolean;
  53729. /** @hidden */
  53730. _forceUniformInVertexShaderOnly: boolean;
  53731. private _type;
  53732. /**
  53733. * Gets or sets the connection point type (default is float)
  53734. */
  53735. type: NodeMaterialBlockConnectionPointTypes;
  53736. /**
  53737. * Gets or sets the connection point name
  53738. */
  53739. name: string;
  53740. /**
  53741. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53742. */
  53743. swizzle: string;
  53744. /**
  53745. * Gets or sets a boolean indicating that this connection point can be omitted
  53746. */
  53747. isOptional: boolean;
  53748. /**
  53749. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53750. */
  53751. define: string;
  53752. /** Gets or sets the target of that connection point */
  53753. target: NodeMaterialBlockTargets;
  53754. /**
  53755. * Gets or sets the value of that point.
  53756. * Please note that this value will be ignored if valueCallback is defined
  53757. */
  53758. value: any;
  53759. /**
  53760. * Gets or sets a callback used to get the value of that point.
  53761. * Please note that setting this value will force the connection point to ignore the value property
  53762. */
  53763. valueCallback: () => any;
  53764. /**
  53765. * Gets or sets the associated variable name in the shader
  53766. */
  53767. associatedVariableName: string;
  53768. /**
  53769. * Gets a boolean indicating that this connection point not defined yet
  53770. */
  53771. readonly isUndefined: boolean;
  53772. /**
  53773. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53774. * In this case the connection point name must be the name of the uniform to use.
  53775. * Can only be set on inputs
  53776. */
  53777. isUniform: boolean;
  53778. /**
  53779. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53780. * In this case the connection point name must be the name of the attribute to use
  53781. * Can only be set on inputs
  53782. */
  53783. isAttribute: boolean;
  53784. /**
  53785. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53786. * Can only be set on exit points
  53787. */
  53788. isVarying: boolean;
  53789. /** Get the other side of the connection (if any) */
  53790. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53791. /** Get the block that owns this connection point */
  53792. readonly ownerBlock: NodeMaterialBlock;
  53793. /** Get the block connected on the other side of this connection (if any) */
  53794. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53795. /** Get the block connected on the endpoints of this connection (if any) */
  53796. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53797. /**
  53798. * Creates a new connection point
  53799. * @param name defines the connection point name
  53800. * @param ownerBlock defines the block hosting this connection point
  53801. */
  53802. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53803. /**
  53804. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53805. * @returns the class name
  53806. */
  53807. getClassName(): string;
  53808. /**
  53809. * Set the source of this connection point to a vertex attribute
  53810. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53811. * @returns the current connection point
  53812. */
  53813. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53814. /**
  53815. * Set the source of this connection point to a well known value
  53816. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53817. * @returns the current connection point
  53818. */
  53819. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53820. /**
  53821. * Gets a boolean indicating that the current connection point is a well known value
  53822. */
  53823. readonly isWellKnownValue: boolean;
  53824. /**
  53825. * Gets or sets the current well known value or null if not defined as well know value
  53826. */
  53827. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53828. private _getTypeLength;
  53829. /**
  53830. * Connect this point to another connection point
  53831. * @param connectionPoint defines the other connection point
  53832. * @returns the current connection point
  53833. */
  53834. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53835. /**
  53836. * Disconnect this point from one of his endpoint
  53837. * @param endpoint defines the other connection point
  53838. * @returns the current connection point
  53839. */
  53840. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53841. /**
  53842. * When connection point is an uniform, this function will send its value to the effect
  53843. * @param effect defines the effect to transmit value to
  53844. * @param world defines the world matrix
  53845. * @param worldView defines the worldxview matrix
  53846. * @param worldViewProjection defines the worldxviewxprojection matrix
  53847. */
  53848. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53849. /**
  53850. * When connection point is an uniform, this function will send its value to the effect
  53851. * @param effect defines the effect to transmit value to
  53852. * @param scene defines the hosting scene
  53853. */
  53854. transmit(effect: Effect, scene: Scene): void;
  53855. }
  53856. }
  53857. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53861. import { Mesh } from "babylonjs/Meshes/mesh";
  53862. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53864. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53865. /**
  53866. * Block used to add support for vertex skinning (bones)
  53867. */
  53868. export class BonesBlock extends NodeMaterialBlock {
  53869. /**
  53870. * Creates a new BonesBlock
  53871. * @param name defines the block name
  53872. */
  53873. constructor(name: string);
  53874. /**
  53875. * Initialize the block and prepare the context for build
  53876. * @param state defines the state that will be used for the build
  53877. */
  53878. initialize(state: NodeMaterialBuildState): void;
  53879. /**
  53880. * Gets the current class name
  53881. * @returns the class name
  53882. */
  53883. getClassName(): string;
  53884. /**
  53885. * Gets the matrix indices input component
  53886. */
  53887. readonly matricesIndices: NodeMaterialConnectionPoint;
  53888. /**
  53889. * Gets the matrix weights input component
  53890. */
  53891. readonly matricesWeights: NodeMaterialConnectionPoint;
  53892. /**
  53893. * Gets the extra matrix indices input component
  53894. */
  53895. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53896. /**
  53897. * Gets the extra matrix weights input component
  53898. */
  53899. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53900. /**
  53901. * Gets the world input component
  53902. */
  53903. readonly world: NodeMaterialConnectionPoint;
  53904. /**
  53905. * Gets the output component
  53906. */
  53907. readonly output: NodeMaterialConnectionPoint;
  53908. autoConfigure(): void;
  53909. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53910. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53912. protected _buildBlock(state: NodeMaterialBuildState): this;
  53913. }
  53914. }
  53915. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53920. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53921. /**
  53922. * Block used to add support for instances
  53923. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53924. */
  53925. export class InstancesBlock extends NodeMaterialBlock {
  53926. /**
  53927. * Creates a new InstancesBlock
  53928. * @param name defines the block name
  53929. */
  53930. constructor(name: string);
  53931. /**
  53932. * Gets the current class name
  53933. * @returns the class name
  53934. */
  53935. getClassName(): string;
  53936. /**
  53937. * Gets the first world row input component
  53938. */
  53939. readonly world0: NodeMaterialConnectionPoint;
  53940. /**
  53941. * Gets the second world row input component
  53942. */
  53943. readonly world1: NodeMaterialConnectionPoint;
  53944. /**
  53945. * Gets the third world row input component
  53946. */
  53947. readonly world2: NodeMaterialConnectionPoint;
  53948. /**
  53949. * Gets the forth world row input component
  53950. */
  53951. readonly world3: NodeMaterialConnectionPoint;
  53952. /**
  53953. * Gets the world input component
  53954. */
  53955. readonly world: NodeMaterialConnectionPoint;
  53956. /**
  53957. * Gets the output component
  53958. */
  53959. readonly output: NodeMaterialConnectionPoint;
  53960. autoConfigure(): void;
  53961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53962. protected _buildBlock(state: NodeMaterialBuildState): this;
  53963. }
  53964. }
  53965. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53970. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53971. import { Effect } from "babylonjs/Materials/effect";
  53972. import { Mesh } from "babylonjs/Meshes/mesh";
  53973. /**
  53974. * Block used to add morph targets support to vertex shader
  53975. */
  53976. export class MorphTargetsBlock extends NodeMaterialBlock {
  53977. private _repeatableContentAnchor;
  53978. private _repeatebleContentGenerated;
  53979. /**
  53980. * Create a new MorphTargetsBlock
  53981. * @param name defines the block name
  53982. */
  53983. constructor(name: string);
  53984. /**
  53985. * Gets the current class name
  53986. * @returns the class name
  53987. */
  53988. getClassName(): string;
  53989. /**
  53990. * Gets the position input component
  53991. */
  53992. readonly position: NodeMaterialConnectionPoint;
  53993. /**
  53994. * Gets the normal input component
  53995. */
  53996. readonly normal: NodeMaterialConnectionPoint;
  53997. /**
  53998. * Gets the tangent input component
  53999. */
  54000. readonly tangent: NodeMaterialConnectionPoint;
  54001. /**
  54002. * Gets the tangent input component
  54003. */
  54004. readonly uv: NodeMaterialConnectionPoint;
  54005. /**
  54006. * Gets the position output component
  54007. */
  54008. readonly positionOutput: NodeMaterialConnectionPoint;
  54009. /**
  54010. * Gets the normal output component
  54011. */
  54012. readonly normalOutput: NodeMaterialConnectionPoint;
  54013. /**
  54014. * Gets the tangent output component
  54015. */
  54016. readonly tangentOutput: NodeMaterialConnectionPoint;
  54017. /**
  54018. * Gets the tangent output component
  54019. */
  54020. readonly uvOutput: NodeMaterialConnectionPoint;
  54021. initialize(state: NodeMaterialBuildState): void;
  54022. autoConfigure(): void;
  54023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54025. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54026. protected _buildBlock(state: NodeMaterialBuildState): this;
  54027. }
  54028. }
  54029. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54030. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54031. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54032. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54033. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54034. }
  54035. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54039. /**
  54040. * Block used to add an alpha test in the fragment shader
  54041. */
  54042. export class AlphaTestBlock extends NodeMaterialBlock {
  54043. /**
  54044. * Gets or sets the alpha value where alpha testing happens
  54045. */
  54046. alphaCutOff: number;
  54047. /**
  54048. * Create a new AlphaTestBlock
  54049. * @param name defines the block name
  54050. */
  54051. constructor(name: string);
  54052. /**
  54053. * Gets the current class name
  54054. * @returns the class name
  54055. */
  54056. getClassName(): string;
  54057. /**
  54058. * Gets the color input component
  54059. */
  54060. readonly color: NodeMaterialConnectionPoint;
  54061. protected _buildBlock(state: NodeMaterialBuildState): this;
  54062. }
  54063. }
  54064. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54068. /**
  54069. * Block used to create a Color4 out of 4 inputs (one for each component)
  54070. */
  54071. export class RGBAMergerBlock extends NodeMaterialBlock {
  54072. /**
  54073. * Create a new RGBAMergerBlock
  54074. * @param name defines the block name
  54075. */
  54076. constructor(name: string);
  54077. /**
  54078. * Gets the current class name
  54079. * @returns the class name
  54080. */
  54081. getClassName(): string;
  54082. /**
  54083. * Gets the R input component
  54084. */
  54085. readonly r: NodeMaterialConnectionPoint;
  54086. /**
  54087. * Gets the G input component
  54088. */
  54089. readonly g: NodeMaterialConnectionPoint;
  54090. /**
  54091. * Gets the B input component
  54092. */
  54093. readonly b: NodeMaterialConnectionPoint;
  54094. /**
  54095. * Gets the RGB input component
  54096. */
  54097. readonly rgb: NodeMaterialConnectionPoint;
  54098. /**
  54099. * Gets the R input component
  54100. */
  54101. readonly a: NodeMaterialConnectionPoint;
  54102. /**
  54103. * Gets the output component
  54104. */
  54105. readonly output: NodeMaterialConnectionPoint;
  54106. protected _buildBlock(state: NodeMaterialBuildState): this;
  54107. }
  54108. }
  54109. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54110. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54111. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54112. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54113. /**
  54114. * Block used to create a Color3 out of 3 inputs (one for each component)
  54115. */
  54116. export class RGBMergerBlock extends NodeMaterialBlock {
  54117. /**
  54118. * Create a new RGBMergerBlock
  54119. * @param name defines the block name
  54120. */
  54121. constructor(name: string);
  54122. /**
  54123. * Gets the current class name
  54124. * @returns the class name
  54125. */
  54126. getClassName(): string;
  54127. /**
  54128. * Gets the R component input
  54129. */
  54130. readonly r: NodeMaterialConnectionPoint;
  54131. /**
  54132. * Gets the G component input
  54133. */
  54134. readonly g: NodeMaterialConnectionPoint;
  54135. /**
  54136. * Gets the B component input
  54137. */
  54138. readonly b: NodeMaterialConnectionPoint;
  54139. /**
  54140. * Gets the output component
  54141. */
  54142. readonly output: NodeMaterialConnectionPoint;
  54143. protected _buildBlock(state: NodeMaterialBuildState): this;
  54144. }
  54145. }
  54146. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54147. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54148. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54149. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54150. /**
  54151. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54152. */
  54153. export class RGBASplitterBlock extends NodeMaterialBlock {
  54154. /**
  54155. * Create a new RGBASplitterBlock
  54156. * @param name defines the block name
  54157. */
  54158. constructor(name: string);
  54159. /**
  54160. * Gets the current class name
  54161. * @returns the class name
  54162. */
  54163. getClassName(): string;
  54164. /**
  54165. * Gets the input component
  54166. */
  54167. readonly input: NodeMaterialConnectionPoint;
  54168. protected _buildBlock(state: NodeMaterialBuildState): this;
  54169. }
  54170. }
  54171. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54172. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54175. /**
  54176. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54177. */
  54178. export class RGBSplitterBlock extends NodeMaterialBlock {
  54179. /**
  54180. * Create a new RGBSplitterBlock
  54181. * @param name defines the block name
  54182. */
  54183. constructor(name: string);
  54184. /**
  54185. * Gets the current class name
  54186. * @returns the class name
  54187. */
  54188. getClassName(): string;
  54189. /**
  54190. * Gets the input component
  54191. */
  54192. readonly input: NodeMaterialConnectionPoint;
  54193. protected _buildBlock(state: NodeMaterialBuildState): this;
  54194. }
  54195. }
  54196. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  54197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54201. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54202. /**
  54203. * Block used to read a texture from a sampler
  54204. */
  54205. export class TextureBlock extends NodeMaterialBlock {
  54206. private _defineName;
  54207. /**
  54208. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  54209. */
  54210. autoConnectTextureMatrix: boolean;
  54211. /**
  54212. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  54213. */
  54214. autoSelectUV: boolean;
  54215. /**
  54216. * Create a new TextureBlock
  54217. * @param name defines the block name
  54218. */
  54219. constructor(name: string);
  54220. /**
  54221. * Gets the current class name
  54222. * @returns the class name
  54223. */
  54224. getClassName(): string;
  54225. /**
  54226. * Gets the uv input component
  54227. */
  54228. readonly uv: NodeMaterialConnectionPoint;
  54229. /**
  54230. * Gets the texture information input component
  54231. */
  54232. readonly textureInfo: NodeMaterialConnectionPoint;
  54233. /**
  54234. * Gets the transformed uv input component
  54235. */
  54236. readonly transformedUV: NodeMaterialConnectionPoint;
  54237. /**
  54238. * Gets the texture input component
  54239. */
  54240. readonly texture: NodeMaterialConnectionPoint;
  54241. /**
  54242. * Gets the texture transform input component
  54243. */
  54244. readonly textureTransform: NodeMaterialConnectionPoint;
  54245. /**
  54246. * Gets the output component
  54247. */
  54248. readonly output: NodeMaterialConnectionPoint;
  54249. autoConfigure(): void;
  54250. initialize(state: NodeMaterialBuildState): void;
  54251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54252. isReady(): boolean;
  54253. private _injectVertexCode;
  54254. protected _buildBlock(state: NodeMaterialBuildState): this;
  54255. }
  54256. }
  54257. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54262. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54263. import { Effect } from "babylonjs/Materials/effect";
  54264. import { Mesh } from "babylonjs/Meshes/mesh";
  54265. /**
  54266. * Block used to add image processing support to fragment shader
  54267. */
  54268. export class ImageProcessingBlock extends NodeMaterialBlock {
  54269. /**
  54270. * Create a new ImageProcessingBlock
  54271. * @param name defines the block name
  54272. */
  54273. constructor(name: string);
  54274. /**
  54275. * Gets the current class name
  54276. * @returns the class name
  54277. */
  54278. getClassName(): string;
  54279. /**
  54280. * Gets the color input component
  54281. */
  54282. readonly color: NodeMaterialConnectionPoint;
  54283. /**
  54284. * Gets the output component
  54285. */
  54286. readonly output: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Initialize the block and prepare the context for build
  54289. * @param state defines the state that will be used for the build
  54290. */
  54291. initialize(state: NodeMaterialBuildState): void;
  54292. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54295. protected _buildBlock(state: NodeMaterialBuildState): this;
  54296. }
  54297. }
  54298. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54299. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54300. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54301. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54302. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54303. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54304. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54305. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54306. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54307. }
  54308. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54310. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54311. import { Mesh } from "babylonjs/Meshes/mesh";
  54312. import { Effect } from "babylonjs/Materials/effect";
  54313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54315. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54316. /**
  54317. * Block used to add support for scene fog
  54318. */
  54319. export class FogBlock extends NodeMaterialBlock {
  54320. /**
  54321. * Create a new FogBlock
  54322. * @param name defines the block name
  54323. */
  54324. constructor(name: string);
  54325. /**
  54326. * Gets the current class name
  54327. * @returns the class name
  54328. */
  54329. getClassName(): string;
  54330. /**
  54331. * Gets the world position input component
  54332. */
  54333. readonly worldPosition: NodeMaterialConnectionPoint;
  54334. /**
  54335. * Gets the view input component
  54336. */
  54337. readonly view: NodeMaterialConnectionPoint;
  54338. /**
  54339. * Gets the color input component
  54340. */
  54341. readonly color: NodeMaterialConnectionPoint;
  54342. /**
  54343. * Gets the fog color input component
  54344. */
  54345. readonly fogColor: NodeMaterialConnectionPoint;
  54346. /**
  54347. * Gets the for parameter input component
  54348. */
  54349. readonly fogParameters: NodeMaterialConnectionPoint;
  54350. /**
  54351. * Gets the output component
  54352. */
  54353. readonly output: NodeMaterialConnectionPoint;
  54354. autoConfigure(): void;
  54355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54356. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54357. protected _buildBlock(state: NodeMaterialBuildState): this;
  54358. }
  54359. }
  54360. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54365. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54366. import { Effect } from "babylonjs/Materials/effect";
  54367. import { Mesh } from "babylonjs/Meshes/mesh";
  54368. /**
  54369. * Block used to add light in the fragment shader
  54370. */
  54371. export class LightBlock extends NodeMaterialBlock {
  54372. private _lightId;
  54373. /**
  54374. * Create a new LightBlock
  54375. * @param name defines the block name
  54376. */
  54377. constructor(name: string);
  54378. /**
  54379. * Gets the current class name
  54380. * @returns the class name
  54381. */
  54382. getClassName(): string;
  54383. /**
  54384. * Gets the world position input component
  54385. */
  54386. readonly worldPosition: NodeMaterialConnectionPoint;
  54387. /**
  54388. * Gets the world normal input component
  54389. */
  54390. readonly worldNormal: NodeMaterialConnectionPoint;
  54391. /**
  54392. * Gets the light input component
  54393. */
  54394. readonly light: NodeMaterialConnectionPoint;
  54395. /**
  54396. * Gets the camera (or eye) position component
  54397. */
  54398. readonly cameraPosition: NodeMaterialConnectionPoint;
  54399. /**
  54400. * Gets the diffuse output component
  54401. */
  54402. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54403. /**
  54404. * Gets the specular output component
  54405. */
  54406. readonly specularOutput: NodeMaterialConnectionPoint;
  54407. autoConfigure(): void;
  54408. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54409. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54410. private _injectVertexCode;
  54411. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54412. }
  54413. }
  54414. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54415. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54416. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54417. }
  54418. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54422. /**
  54423. * Block used to multiply 2 vector4
  54424. */
  54425. export class MultiplyBlock extends NodeMaterialBlock {
  54426. /**
  54427. * Creates a new MultiplyBlock
  54428. * @param name defines the block name
  54429. */
  54430. constructor(name: string);
  54431. /**
  54432. * Gets the current class name
  54433. * @returns the class name
  54434. */
  54435. getClassName(): string;
  54436. /**
  54437. * Gets the left operand input component
  54438. */
  54439. readonly left: NodeMaterialConnectionPoint;
  54440. /**
  54441. * Gets the right operand input component
  54442. */
  54443. readonly right: NodeMaterialConnectionPoint;
  54444. /**
  54445. * Gets the output component
  54446. */
  54447. readonly output: NodeMaterialConnectionPoint;
  54448. protected _buildBlock(state: NodeMaterialBuildState): this;
  54449. }
  54450. }
  54451. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54452. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54453. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54454. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54455. /**
  54456. * Block used to add 2 vector4
  54457. */
  54458. export class AddBlock extends NodeMaterialBlock {
  54459. /**
  54460. * Creates a new AddBlock
  54461. * @param name defines the block name
  54462. */
  54463. constructor(name: string);
  54464. /**
  54465. * Gets the current class name
  54466. * @returns the class name
  54467. */
  54468. getClassName(): string;
  54469. /**
  54470. * Gets the left operand input component
  54471. */
  54472. readonly left: NodeMaterialConnectionPoint;
  54473. /**
  54474. * Gets the right operand input component
  54475. */
  54476. readonly right: NodeMaterialConnectionPoint;
  54477. /**
  54478. * Gets the output component
  54479. */
  54480. readonly output: NodeMaterialConnectionPoint;
  54481. protected _buildBlock(state: NodeMaterialBuildState): this;
  54482. }
  54483. }
  54484. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54488. /**
  54489. * Block used to clamp a float
  54490. */
  54491. export class ClampBlock extends NodeMaterialBlock {
  54492. /** Gets or sets the minimum range */
  54493. minimum: number;
  54494. /** Gets or sets the maximum range */
  54495. maximum: number;
  54496. /**
  54497. * Creates a new ClampBlock
  54498. * @param name defines the block name
  54499. */
  54500. constructor(name: string);
  54501. /**
  54502. * Gets the current class name
  54503. * @returns the class name
  54504. */
  54505. getClassName(): string;
  54506. /**
  54507. * Gets the value input component
  54508. */
  54509. readonly value: NodeMaterialConnectionPoint;
  54510. /**
  54511. * Gets the output component
  54512. */
  54513. readonly output: NodeMaterialConnectionPoint;
  54514. protected _buildBlock(state: NodeMaterialBuildState): this;
  54515. }
  54516. }
  54517. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  54518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54521. /**
  54522. * Block used to scale a value
  54523. */
  54524. export class ScaleBlock extends NodeMaterialBlock {
  54525. /**
  54526. * Creates a new ScaleBlock
  54527. * @param name defines the block name
  54528. */
  54529. constructor(name: string);
  54530. /**
  54531. * Gets the current class name
  54532. * @returns the class name
  54533. */
  54534. getClassName(): string;
  54535. /**
  54536. * Gets the value operand input component
  54537. */
  54538. readonly value: NodeMaterialConnectionPoint;
  54539. /**
  54540. * Gets the scale operand input component
  54541. */
  54542. readonly scale: NodeMaterialConnectionPoint;
  54543. /**
  54544. * Gets the output component
  54545. */
  54546. readonly output: NodeMaterialConnectionPoint;
  54547. protected _buildBlock(state: NodeMaterialBuildState): this;
  54548. }
  54549. }
  54550. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54554. /**
  54555. * Block used to transform a vector2 with a matrix
  54556. */
  54557. export class Vector2TransformBlock extends NodeMaterialBlock {
  54558. /**
  54559. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54560. */
  54561. complementZ: number;
  54562. /**
  54563. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54564. */
  54565. complementW: number;
  54566. /**
  54567. * Creates a new Vector2TransformBlock
  54568. * @param name defines the block name
  54569. */
  54570. constructor(name: string);
  54571. /**
  54572. * Gets the vector input
  54573. */
  54574. readonly vector: NodeMaterialConnectionPoint;
  54575. /**
  54576. * Gets the matrix transform input
  54577. */
  54578. readonly transform: NodeMaterialConnectionPoint;
  54579. /**
  54580. * Gets the output component
  54581. */
  54582. readonly output: NodeMaterialConnectionPoint;
  54583. /**
  54584. * Gets the current class name
  54585. * @returns the class name
  54586. */
  54587. getClassName(): string;
  54588. protected _buildBlock(state: NodeMaterialBuildState): this;
  54589. }
  54590. }
  54591. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54595. /**
  54596. * Block used to transform a vector3 with a matrix
  54597. */
  54598. export class Vector3TransformBlock extends NodeMaterialBlock {
  54599. /**
  54600. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54601. */
  54602. complement: number;
  54603. /**
  54604. * Creates a new Vector3TransformBlock
  54605. * @param name defines the block name
  54606. */
  54607. constructor(name: string);
  54608. /**
  54609. * Gets the vector input
  54610. */
  54611. readonly vector: NodeMaterialConnectionPoint;
  54612. /**
  54613. * Gets the matrix transform input
  54614. */
  54615. readonly transform: NodeMaterialConnectionPoint;
  54616. /**
  54617. * Gets the output component
  54618. */
  54619. readonly output: NodeMaterialConnectionPoint;
  54620. /**
  54621. * Gets the current class name
  54622. * @returns the class name
  54623. */
  54624. getClassName(): string;
  54625. protected _buildBlock(state: NodeMaterialBuildState): this;
  54626. }
  54627. }
  54628. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54632. /**
  54633. * Block used to multiply two matrices
  54634. */
  54635. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54636. /**
  54637. * Creates a new MatrixMultiplicationBlock
  54638. * @param name defines the block name
  54639. */
  54640. constructor(name: string);
  54641. /**
  54642. * Gets the left operand
  54643. */
  54644. readonly left: NodeMaterialConnectionPoint;
  54645. /**
  54646. * Gets the right operand
  54647. */
  54648. readonly right: NodeMaterialConnectionPoint;
  54649. /**
  54650. * Gets the output component
  54651. */
  54652. readonly output: NodeMaterialConnectionPoint;
  54653. /**
  54654. * Gets the current class name
  54655. * @returns the class name
  54656. */
  54657. getClassName(): string;
  54658. protected _buildBlock(state: NodeMaterialBuildState): this;
  54659. }
  54660. }
  54661. declare module "babylonjs/Materials/Node/Blocks/index" {
  54662. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54663. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54664. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54665. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54666. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54667. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54668. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  54669. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54670. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54671. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54672. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54673. }
  54674. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54675. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54676. }
  54677. declare module "babylonjs/Materials/Node/index" {
  54678. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54679. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54680. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54681. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54682. export * from "babylonjs/Materials/Node/nodeMaterial";
  54683. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54684. export * from "babylonjs/Materials/Node/Blocks/index";
  54685. export * from "babylonjs/Materials/Node/Optimizers/index";
  54686. }
  54687. declare module "babylonjs/Materials/index" {
  54688. export * from "babylonjs/Materials/Background/index";
  54689. export * from "babylonjs/Materials/colorCurves";
  54690. export * from "babylonjs/Materials/effect";
  54691. export * from "babylonjs/Materials/fresnelParameters";
  54692. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54693. export * from "babylonjs/Materials/material";
  54694. export * from "babylonjs/Materials/materialDefines";
  54695. export * from "babylonjs/Materials/materialHelper";
  54696. export * from "babylonjs/Materials/multiMaterial";
  54697. export * from "babylonjs/Materials/PBR/index";
  54698. export * from "babylonjs/Materials/pushMaterial";
  54699. export * from "babylonjs/Materials/shaderMaterial";
  54700. export * from "babylonjs/Materials/standardMaterial";
  54701. export * from "babylonjs/Materials/Textures/index";
  54702. export * from "babylonjs/Materials/uniformBuffer";
  54703. export * from "babylonjs/Materials/materialFlags";
  54704. export * from "babylonjs/Materials/Node/index";
  54705. }
  54706. declare module "babylonjs/Maths/index" {
  54707. export * from "babylonjs/Maths/math.scalar";
  54708. export * from "babylonjs/Maths/math";
  54709. export * from "babylonjs/Maths/sphericalPolynomial";
  54710. }
  54711. declare module "babylonjs/Misc/workerPool" {
  54712. import { IDisposable } from "babylonjs/scene";
  54713. /**
  54714. * Helper class to push actions to a pool of workers.
  54715. */
  54716. export class WorkerPool implements IDisposable {
  54717. private _workerInfos;
  54718. private _pendingActions;
  54719. /**
  54720. * Constructor
  54721. * @param workers Array of workers to use for actions
  54722. */
  54723. constructor(workers: Array<Worker>);
  54724. /**
  54725. * Terminates all workers and clears any pending actions.
  54726. */
  54727. dispose(): void;
  54728. /**
  54729. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54730. * pended until a worker has completed its action.
  54731. * @param action The action to perform. Call onComplete when the action is complete.
  54732. */
  54733. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54734. private _execute;
  54735. }
  54736. }
  54737. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54738. import { IDisposable } from "babylonjs/scene";
  54739. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54740. /**
  54741. * Configuration for Draco compression
  54742. */
  54743. export interface IDracoCompressionConfiguration {
  54744. /**
  54745. * Configuration for the decoder.
  54746. */
  54747. decoder: {
  54748. /**
  54749. * The url to the WebAssembly module.
  54750. */
  54751. wasmUrl?: string;
  54752. /**
  54753. * The url to the WebAssembly binary.
  54754. */
  54755. wasmBinaryUrl?: string;
  54756. /**
  54757. * The url to the fallback JavaScript module.
  54758. */
  54759. fallbackUrl?: string;
  54760. };
  54761. }
  54762. /**
  54763. * Draco compression (https://google.github.io/draco/)
  54764. *
  54765. * This class wraps the Draco module.
  54766. *
  54767. * **Encoder**
  54768. *
  54769. * The encoder is not currently implemented.
  54770. *
  54771. * **Decoder**
  54772. *
  54773. * 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.
  54774. *
  54775. * To update the configuration, use the following code:
  54776. * ```javascript
  54777. * DracoCompression.Configuration = {
  54778. * decoder: {
  54779. * wasmUrl: "<url to the WebAssembly library>",
  54780. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54781. * fallbackUrl: "<url to the fallback JavaScript library>",
  54782. * }
  54783. * };
  54784. * ```
  54785. *
  54786. * 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.
  54787. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54788. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54789. *
  54790. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54791. * ```javascript
  54792. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54793. * ```
  54794. *
  54795. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54796. */
  54797. export class DracoCompression implements IDisposable {
  54798. private _workerPoolPromise?;
  54799. private _decoderModulePromise?;
  54800. /**
  54801. * The configuration. Defaults to the following urls:
  54802. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54803. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54804. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54805. */
  54806. static Configuration: IDracoCompressionConfiguration;
  54807. /**
  54808. * Returns true if the decoder configuration is available.
  54809. */
  54810. static readonly DecoderAvailable: boolean;
  54811. /**
  54812. * Default number of workers to create when creating the draco compression object.
  54813. */
  54814. static DefaultNumWorkers: number;
  54815. private static GetDefaultNumWorkers;
  54816. private static _Default;
  54817. /**
  54818. * Default instance for the draco compression object.
  54819. */
  54820. static readonly Default: DracoCompression;
  54821. /**
  54822. * Constructor
  54823. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54824. */
  54825. constructor(numWorkers?: number);
  54826. /**
  54827. * Stop all async operations and release resources.
  54828. */
  54829. dispose(): void;
  54830. /**
  54831. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54832. * @returns a promise that resolves when ready
  54833. */
  54834. whenReadyAsync(): Promise<void>;
  54835. /**
  54836. * Decode Draco compressed mesh data to vertex data.
  54837. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54838. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54839. * @returns A promise that resolves with the decoded vertex data
  54840. */
  54841. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54842. [kind: string]: number;
  54843. }): Promise<VertexData>;
  54844. }
  54845. }
  54846. declare module "babylonjs/Meshes/Compression/index" {
  54847. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54848. }
  54849. declare module "babylonjs/Meshes/csg" {
  54850. import { Nullable } from "babylonjs/types";
  54851. import { Scene } from "babylonjs/scene";
  54852. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54853. import { Mesh } from "babylonjs/Meshes/mesh";
  54854. import { Material } from "babylonjs/Materials/material";
  54855. /**
  54856. * Class for building Constructive Solid Geometry
  54857. */
  54858. export class CSG {
  54859. private polygons;
  54860. /**
  54861. * The world matrix
  54862. */
  54863. matrix: Matrix;
  54864. /**
  54865. * Stores the position
  54866. */
  54867. position: Vector3;
  54868. /**
  54869. * Stores the rotation
  54870. */
  54871. rotation: Vector3;
  54872. /**
  54873. * Stores the rotation quaternion
  54874. */
  54875. rotationQuaternion: Nullable<Quaternion>;
  54876. /**
  54877. * Stores the scaling vector
  54878. */
  54879. scaling: Vector3;
  54880. /**
  54881. * Convert the Mesh to CSG
  54882. * @param mesh The Mesh to convert to CSG
  54883. * @returns A new CSG from the Mesh
  54884. */
  54885. static FromMesh(mesh: Mesh): CSG;
  54886. /**
  54887. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54888. * @param polygons Polygons used to construct a CSG solid
  54889. */
  54890. private static FromPolygons;
  54891. /**
  54892. * Clones, or makes a deep copy, of the CSG
  54893. * @returns A new CSG
  54894. */
  54895. clone(): CSG;
  54896. /**
  54897. * Unions this CSG with another CSG
  54898. * @param csg The CSG to union against this CSG
  54899. * @returns The unioned CSG
  54900. */
  54901. union(csg: CSG): CSG;
  54902. /**
  54903. * Unions this CSG with another CSG in place
  54904. * @param csg The CSG to union against this CSG
  54905. */
  54906. unionInPlace(csg: CSG): void;
  54907. /**
  54908. * Subtracts this CSG with another CSG
  54909. * @param csg The CSG to subtract against this CSG
  54910. * @returns A new CSG
  54911. */
  54912. subtract(csg: CSG): CSG;
  54913. /**
  54914. * Subtracts this CSG with another CSG in place
  54915. * @param csg The CSG to subtact against this CSG
  54916. */
  54917. subtractInPlace(csg: CSG): void;
  54918. /**
  54919. * Intersect this CSG with another CSG
  54920. * @param csg The CSG to intersect against this CSG
  54921. * @returns A new CSG
  54922. */
  54923. intersect(csg: CSG): CSG;
  54924. /**
  54925. * Intersects this CSG with another CSG in place
  54926. * @param csg The CSG to intersect against this CSG
  54927. */
  54928. intersectInPlace(csg: CSG): void;
  54929. /**
  54930. * Return a new CSG solid with solid and empty space switched. This solid is
  54931. * not modified.
  54932. * @returns A new CSG solid with solid and empty space switched
  54933. */
  54934. inverse(): CSG;
  54935. /**
  54936. * Inverses the CSG in place
  54937. */
  54938. inverseInPlace(): void;
  54939. /**
  54940. * This is used to keep meshes transformations so they can be restored
  54941. * when we build back a Babylon Mesh
  54942. * NB : All CSG operations are performed in world coordinates
  54943. * @param csg The CSG to copy the transform attributes from
  54944. * @returns This CSG
  54945. */
  54946. copyTransformAttributes(csg: CSG): CSG;
  54947. /**
  54948. * Build Raw mesh from CSG
  54949. * Coordinates here are in world space
  54950. * @param name The name of the mesh geometry
  54951. * @param scene The Scene
  54952. * @param keepSubMeshes Specifies if the submeshes should be kept
  54953. * @returns A new Mesh
  54954. */
  54955. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54956. /**
  54957. * Build Mesh from CSG taking material and transforms into account
  54958. * @param name The name of the Mesh
  54959. * @param material The material of the Mesh
  54960. * @param scene The Scene
  54961. * @param keepSubMeshes Specifies if submeshes should be kept
  54962. * @returns The new Mesh
  54963. */
  54964. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54965. }
  54966. }
  54967. declare module "babylonjs/Meshes/trailMesh" {
  54968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54969. import { Mesh } from "babylonjs/Meshes/mesh";
  54970. import { Scene } from "babylonjs/scene";
  54971. /**
  54972. * Class used to create a trail following a mesh
  54973. */
  54974. export class TrailMesh extends Mesh {
  54975. private _generator;
  54976. private _autoStart;
  54977. private _running;
  54978. private _diameter;
  54979. private _length;
  54980. private _sectionPolygonPointsCount;
  54981. private _sectionVectors;
  54982. private _sectionNormalVectors;
  54983. private _beforeRenderObserver;
  54984. /**
  54985. * @constructor
  54986. * @param name The value used by scene.getMeshByName() to do a lookup.
  54987. * @param generator The mesh to generate a trail.
  54988. * @param scene The scene to add this mesh to.
  54989. * @param diameter Diameter of trailing mesh. Default is 1.
  54990. * @param length Length of trailing mesh. Default is 60.
  54991. * @param autoStart Automatically start trailing mesh. Default true.
  54992. */
  54993. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54994. /**
  54995. * "TrailMesh"
  54996. * @returns "TrailMesh"
  54997. */
  54998. getClassName(): string;
  54999. private _createMesh;
  55000. /**
  55001. * Start trailing mesh.
  55002. */
  55003. start(): void;
  55004. /**
  55005. * Stop trailing mesh.
  55006. */
  55007. stop(): void;
  55008. /**
  55009. * Update trailing mesh geometry.
  55010. */
  55011. update(): void;
  55012. /**
  55013. * Returns a new TrailMesh object.
  55014. * @param name is a string, the name given to the new mesh
  55015. * @param newGenerator use new generator object for cloned trail mesh
  55016. * @returns a new mesh
  55017. */
  55018. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55019. /**
  55020. * Serializes this trail mesh
  55021. * @param serializationObject object to write serialization to
  55022. */
  55023. serialize(serializationObject: any): void;
  55024. /**
  55025. * Parses a serialized trail mesh
  55026. * @param parsedMesh the serialized mesh
  55027. * @param scene the scene to create the trail mesh in
  55028. * @returns the created trail mesh
  55029. */
  55030. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55031. }
  55032. }
  55033. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55034. import { Nullable } from "babylonjs/types";
  55035. import { Scene } from "babylonjs/scene";
  55036. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55037. import { Mesh } from "babylonjs/Meshes/mesh";
  55038. /**
  55039. * Class containing static functions to help procedurally build meshes
  55040. */
  55041. export class TiledBoxBuilder {
  55042. /**
  55043. * Creates a box mesh
  55044. * 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)
  55045. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55049. * @param name defines the name of the mesh
  55050. * @param options defines the options used to create the mesh
  55051. * @param scene defines the hosting scene
  55052. * @returns the box mesh
  55053. */
  55054. static CreateTiledBox(name: string, options: {
  55055. pattern?: number;
  55056. width?: number;
  55057. height?: number;
  55058. depth?: number;
  55059. tileSize?: number;
  55060. tileWidth?: number;
  55061. tileHeight?: number;
  55062. alignHorizontal?: number;
  55063. alignVertical?: number;
  55064. faceUV?: Vector4[];
  55065. faceColors?: Color4[];
  55066. sideOrientation?: number;
  55067. updatable?: boolean;
  55068. }, scene?: Nullable<Scene>): Mesh;
  55069. }
  55070. }
  55071. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55072. import { Vector4 } from "babylonjs/Maths/math";
  55073. import { Mesh } from "babylonjs/Meshes/mesh";
  55074. /**
  55075. * Class containing static functions to help procedurally build meshes
  55076. */
  55077. export class TorusKnotBuilder {
  55078. /**
  55079. * Creates a torus knot mesh
  55080. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55081. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55082. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55083. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55087. * @param name defines the name of the mesh
  55088. * @param options defines the options used to create the mesh
  55089. * @param scene defines the hosting scene
  55090. * @returns the torus knot mesh
  55091. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55092. */
  55093. static CreateTorusKnot(name: string, options: {
  55094. radius?: number;
  55095. tube?: number;
  55096. radialSegments?: number;
  55097. tubularSegments?: number;
  55098. p?: number;
  55099. q?: number;
  55100. updatable?: boolean;
  55101. sideOrientation?: number;
  55102. frontUVs?: Vector4;
  55103. backUVs?: Vector4;
  55104. }, scene: any): Mesh;
  55105. }
  55106. }
  55107. declare module "babylonjs/Meshes/polygonMesh" {
  55108. import { Scene } from "babylonjs/scene";
  55109. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55110. import { Mesh } from "babylonjs/Meshes/mesh";
  55111. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55112. /**
  55113. * Polygon
  55114. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55115. */
  55116. export class Polygon {
  55117. /**
  55118. * Creates a rectangle
  55119. * @param xmin bottom X coord
  55120. * @param ymin bottom Y coord
  55121. * @param xmax top X coord
  55122. * @param ymax top Y coord
  55123. * @returns points that make the resulting rectation
  55124. */
  55125. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55126. /**
  55127. * Creates a circle
  55128. * @param radius radius of circle
  55129. * @param cx scale in x
  55130. * @param cy scale in y
  55131. * @param numberOfSides number of sides that make up the circle
  55132. * @returns points that make the resulting circle
  55133. */
  55134. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55135. /**
  55136. * Creates a polygon from input string
  55137. * @param input Input polygon data
  55138. * @returns the parsed points
  55139. */
  55140. static Parse(input: string): Vector2[];
  55141. /**
  55142. * Starts building a polygon from x and y coordinates
  55143. * @param x x coordinate
  55144. * @param y y coordinate
  55145. * @returns the started path2
  55146. */
  55147. static StartingAt(x: number, y: number): Path2;
  55148. }
  55149. /**
  55150. * Builds a polygon
  55151. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55152. */
  55153. export class PolygonMeshBuilder {
  55154. private _points;
  55155. private _outlinepoints;
  55156. private _holes;
  55157. private _name;
  55158. private _scene;
  55159. private _epoints;
  55160. private _eholes;
  55161. private _addToepoint;
  55162. /**
  55163. * Babylon reference to the earcut plugin.
  55164. */
  55165. bjsEarcut: any;
  55166. /**
  55167. * Creates a PolygonMeshBuilder
  55168. * @param name name of the builder
  55169. * @param contours Path of the polygon
  55170. * @param scene scene to add to when creating the mesh
  55171. * @param earcutInjection can be used to inject your own earcut reference
  55172. */
  55173. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55174. /**
  55175. * Adds a whole within the polygon
  55176. * @param hole Array of points defining the hole
  55177. * @returns this
  55178. */
  55179. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55180. /**
  55181. * Creates the polygon
  55182. * @param updatable If the mesh should be updatable
  55183. * @param depth The depth of the mesh created
  55184. * @returns the created mesh
  55185. */
  55186. build(updatable?: boolean, depth?: number): Mesh;
  55187. /**
  55188. * Creates the polygon
  55189. * @param depth The depth of the mesh created
  55190. * @returns the created VertexData
  55191. */
  55192. buildVertexData(depth?: number): VertexData;
  55193. /**
  55194. * Adds a side to the polygon
  55195. * @param positions points that make the polygon
  55196. * @param normals normals of the polygon
  55197. * @param uvs uvs of the polygon
  55198. * @param indices indices of the polygon
  55199. * @param bounds bounds of the polygon
  55200. * @param points points of the polygon
  55201. * @param depth depth of the polygon
  55202. * @param flip flip of the polygon
  55203. */
  55204. private addSide;
  55205. }
  55206. }
  55207. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55208. import { Scene } from "babylonjs/scene";
  55209. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55210. import { Mesh } from "babylonjs/Meshes/mesh";
  55211. import { Nullable } from "babylonjs/types";
  55212. /**
  55213. * Class containing static functions to help procedurally build meshes
  55214. */
  55215. export class PolygonBuilder {
  55216. /**
  55217. * Creates a polygon mesh
  55218. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55219. * * 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
  55220. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55223. * * Remember you can only change the shape positions, not their number when updating a polygon
  55224. * @param name defines the name of the mesh
  55225. * @param options defines the options used to create the mesh
  55226. * @param scene defines the hosting scene
  55227. * @param earcutInjection can be used to inject your own earcut reference
  55228. * @returns the polygon mesh
  55229. */
  55230. static CreatePolygon(name: string, options: {
  55231. shape: Vector3[];
  55232. holes?: Vector3[][];
  55233. depth?: number;
  55234. faceUV?: Vector4[];
  55235. faceColors?: Color4[];
  55236. updatable?: boolean;
  55237. sideOrientation?: number;
  55238. frontUVs?: Vector4;
  55239. backUVs?: Vector4;
  55240. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55241. /**
  55242. * Creates an extruded polygon mesh, with depth in the Y direction.
  55243. * * 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)
  55244. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55245. * @param name defines the name of the mesh
  55246. * @param options defines the options used to create the mesh
  55247. * @param scene defines the hosting scene
  55248. * @param earcutInjection can be used to inject your own earcut reference
  55249. * @returns the polygon mesh
  55250. */
  55251. static ExtrudePolygon(name: string, options: {
  55252. shape: Vector3[];
  55253. holes?: Vector3[][];
  55254. depth?: number;
  55255. faceUV?: Vector4[];
  55256. faceColors?: Color4[];
  55257. updatable?: boolean;
  55258. sideOrientation?: number;
  55259. frontUVs?: Vector4;
  55260. backUVs?: Vector4;
  55261. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55262. }
  55263. }
  55264. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55265. import { Scene } from "babylonjs/scene";
  55266. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55267. import { Mesh } from "babylonjs/Meshes/mesh";
  55268. import { Nullable } from "babylonjs/types";
  55269. /**
  55270. * Class containing static functions to help procedurally build meshes
  55271. */
  55272. export class LatheBuilder {
  55273. /**
  55274. * Creates lathe mesh.
  55275. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55276. * * 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
  55277. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55278. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55279. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55280. * * 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
  55281. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55282. * * 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
  55283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55287. * @param name defines the name of the mesh
  55288. * @param options defines the options used to create the mesh
  55289. * @param scene defines the hosting scene
  55290. * @returns the lathe mesh
  55291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55292. */
  55293. static CreateLathe(name: string, options: {
  55294. shape: Vector3[];
  55295. radius?: number;
  55296. tessellation?: number;
  55297. clip?: number;
  55298. arc?: number;
  55299. closed?: boolean;
  55300. updatable?: boolean;
  55301. sideOrientation?: number;
  55302. frontUVs?: Vector4;
  55303. backUVs?: Vector4;
  55304. cap?: number;
  55305. invertUV?: boolean;
  55306. }, scene?: Nullable<Scene>): Mesh;
  55307. }
  55308. }
  55309. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55310. import { Nullable } from "babylonjs/types";
  55311. import { Scene } from "babylonjs/scene";
  55312. import { Vector4 } from "babylonjs/Maths/math";
  55313. import { Mesh } from "babylonjs/Meshes/mesh";
  55314. /**
  55315. * Class containing static functions to help procedurally build meshes
  55316. */
  55317. export class TiledPlaneBuilder {
  55318. /**
  55319. * Creates a tiled plane mesh
  55320. * * The parameter `pattern` will, depending on value, do nothing or
  55321. * * * flip (reflect about central vertical) alternate tiles across and up
  55322. * * * flip every tile on alternate rows
  55323. * * * rotate (180 degs) alternate tiles across and up
  55324. * * * rotate every tile on alternate rows
  55325. * * * flip and rotate alternate tiles across and up
  55326. * * * flip and rotate every tile on alternate rows
  55327. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55328. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55331. * * 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)
  55332. * * 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)
  55333. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55334. * @param name defines the name of the mesh
  55335. * @param options defines the options used to create the mesh
  55336. * @param scene defines the hosting scene
  55337. * @returns the box mesh
  55338. */
  55339. static CreateTiledPlane(name: string, options: {
  55340. pattern?: number;
  55341. tileSize?: number;
  55342. tileWidth?: number;
  55343. tileHeight?: number;
  55344. size?: number;
  55345. width?: number;
  55346. height?: number;
  55347. alignHorizontal?: number;
  55348. alignVertical?: number;
  55349. sideOrientation?: number;
  55350. frontUVs?: Vector4;
  55351. backUVs?: Vector4;
  55352. updatable?: boolean;
  55353. }, scene?: Nullable<Scene>): Mesh;
  55354. }
  55355. }
  55356. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55357. import { Nullable } from "babylonjs/types";
  55358. import { Scene } from "babylonjs/scene";
  55359. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55360. import { Mesh } from "babylonjs/Meshes/mesh";
  55361. /**
  55362. * Class containing static functions to help procedurally build meshes
  55363. */
  55364. export class TubeBuilder {
  55365. /**
  55366. * Creates a tube mesh.
  55367. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55368. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55369. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55370. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55371. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55372. * * 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)
  55373. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55374. * * 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
  55375. * * 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
  55376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55378. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55380. * @param name defines the name of the mesh
  55381. * @param options defines the options used to create the mesh
  55382. * @param scene defines the hosting scene
  55383. * @returns the tube mesh
  55384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55385. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55386. */
  55387. static CreateTube(name: string, options: {
  55388. path: Vector3[];
  55389. radius?: number;
  55390. tessellation?: number;
  55391. radiusFunction?: {
  55392. (i: number, distance: number): number;
  55393. };
  55394. cap?: number;
  55395. arc?: number;
  55396. updatable?: boolean;
  55397. sideOrientation?: number;
  55398. frontUVs?: Vector4;
  55399. backUVs?: Vector4;
  55400. instance?: Mesh;
  55401. invertUV?: boolean;
  55402. }, scene?: Nullable<Scene>): Mesh;
  55403. }
  55404. }
  55405. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55406. import { Scene } from "babylonjs/scene";
  55407. import { Vector4 } from "babylonjs/Maths/math";
  55408. import { Mesh } from "babylonjs/Meshes/mesh";
  55409. import { Nullable } from "babylonjs/types";
  55410. /**
  55411. * Class containing static functions to help procedurally build meshes
  55412. */
  55413. export class IcoSphereBuilder {
  55414. /**
  55415. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55416. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55417. * * 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`)
  55418. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55419. * * 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
  55420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55423. * @param name defines the name of the mesh
  55424. * @param options defines the options used to create the mesh
  55425. * @param scene defines the hosting scene
  55426. * @returns the icosahedron mesh
  55427. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55428. */
  55429. static CreateIcoSphere(name: string, options: {
  55430. radius?: number;
  55431. radiusX?: number;
  55432. radiusY?: number;
  55433. radiusZ?: number;
  55434. flat?: boolean;
  55435. subdivisions?: number;
  55436. sideOrientation?: number;
  55437. frontUVs?: Vector4;
  55438. backUVs?: Vector4;
  55439. updatable?: boolean;
  55440. }, scene?: Nullable<Scene>): Mesh;
  55441. }
  55442. }
  55443. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55444. import { Vector3 } from "babylonjs/Maths/math";
  55445. import { Mesh } from "babylonjs/Meshes/mesh";
  55446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55447. /**
  55448. * Class containing static functions to help procedurally build meshes
  55449. */
  55450. export class DecalBuilder {
  55451. /**
  55452. * Creates a decal mesh.
  55453. * 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
  55454. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55455. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55456. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55457. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55458. * @param name defines the name of the mesh
  55459. * @param sourceMesh defines the mesh where the decal must be applied
  55460. * @param options defines the options used to create the mesh
  55461. * @param scene defines the hosting scene
  55462. * @returns the decal mesh
  55463. * @see https://doc.babylonjs.com/how_to/decals
  55464. */
  55465. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55466. position?: Vector3;
  55467. normal?: Vector3;
  55468. size?: Vector3;
  55469. angle?: number;
  55470. }): Mesh;
  55471. }
  55472. }
  55473. declare module "babylonjs/Meshes/meshBuilder" {
  55474. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55475. import { Nullable } from "babylonjs/types";
  55476. import { Scene } from "babylonjs/scene";
  55477. import { Mesh } from "babylonjs/Meshes/mesh";
  55478. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55479. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55481. /**
  55482. * Class containing static functions to help procedurally build meshes
  55483. */
  55484. export class MeshBuilder {
  55485. /**
  55486. * Creates a box mesh
  55487. * * The parameter `size` sets the size (float) of each box side (default 1)
  55488. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55489. * * 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)
  55490. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55494. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55495. * @param name defines the name of the mesh
  55496. * @param options defines the options used to create the mesh
  55497. * @param scene defines the hosting scene
  55498. * @returns the box mesh
  55499. */
  55500. static CreateBox(name: string, options: {
  55501. size?: number;
  55502. width?: number;
  55503. height?: number;
  55504. depth?: number;
  55505. faceUV?: Vector4[];
  55506. faceColors?: Color4[];
  55507. sideOrientation?: number;
  55508. frontUVs?: Vector4;
  55509. backUVs?: Vector4;
  55510. updatable?: boolean;
  55511. }, scene?: Nullable<Scene>): Mesh;
  55512. /**
  55513. * Creates a tiled box mesh
  55514. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55516. * @param name defines the name of the mesh
  55517. * @param options defines the options used to create the mesh
  55518. * @param scene defines the hosting scene
  55519. * @returns the tiled box mesh
  55520. */
  55521. static CreateTiledBox(name: string, options: {
  55522. pattern?: number;
  55523. size?: number;
  55524. width?: number;
  55525. height?: number;
  55526. depth: number;
  55527. tileSize?: number;
  55528. tileWidth?: number;
  55529. tileHeight?: number;
  55530. faceUV?: Vector4[];
  55531. faceColors?: Color4[];
  55532. alignHorizontal?: number;
  55533. alignVertical?: number;
  55534. sideOrientation?: number;
  55535. updatable?: boolean;
  55536. }, scene?: Nullable<Scene>): Mesh;
  55537. /**
  55538. * Creates a sphere mesh
  55539. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55540. * * 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`)
  55541. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55542. * * 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
  55543. * * 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)
  55544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55547. * @param name defines the name of the mesh
  55548. * @param options defines the options used to create the mesh
  55549. * @param scene defines the hosting scene
  55550. * @returns the sphere mesh
  55551. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55552. */
  55553. static CreateSphere(name: string, options: {
  55554. segments?: number;
  55555. diameter?: number;
  55556. diameterX?: number;
  55557. diameterY?: number;
  55558. diameterZ?: number;
  55559. arc?: number;
  55560. slice?: number;
  55561. sideOrientation?: number;
  55562. frontUVs?: Vector4;
  55563. backUVs?: Vector4;
  55564. updatable?: boolean;
  55565. }, scene?: Nullable<Scene>): Mesh;
  55566. /**
  55567. * Creates a plane polygonal mesh. By default, this is a disc
  55568. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55569. * * 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
  55570. * * 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
  55571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55574. * @param name defines the name of the mesh
  55575. * @param options defines the options used to create the mesh
  55576. * @param scene defines the hosting scene
  55577. * @returns the plane polygonal mesh
  55578. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55579. */
  55580. static CreateDisc(name: string, options: {
  55581. radius?: number;
  55582. tessellation?: number;
  55583. arc?: number;
  55584. updatable?: boolean;
  55585. sideOrientation?: number;
  55586. frontUVs?: Vector4;
  55587. backUVs?: Vector4;
  55588. }, scene?: Nullable<Scene>): Mesh;
  55589. /**
  55590. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55591. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55592. * * 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`)
  55593. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55594. * * 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
  55595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55598. * @param name defines the name of the mesh
  55599. * @param options defines the options used to create the mesh
  55600. * @param scene defines the hosting scene
  55601. * @returns the icosahedron mesh
  55602. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55603. */
  55604. static CreateIcoSphere(name: string, options: {
  55605. radius?: number;
  55606. radiusX?: number;
  55607. radiusY?: number;
  55608. radiusZ?: number;
  55609. flat?: boolean;
  55610. subdivisions?: number;
  55611. sideOrientation?: number;
  55612. frontUVs?: Vector4;
  55613. backUVs?: Vector4;
  55614. updatable?: boolean;
  55615. }, scene?: Nullable<Scene>): Mesh;
  55616. /**
  55617. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55618. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55619. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55620. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55621. * * 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
  55622. * * 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
  55623. * * 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
  55624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55626. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55627. * * 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
  55628. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55629. * * 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
  55630. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55632. * @param name defines the name of the mesh
  55633. * @param options defines the options used to create the mesh
  55634. * @param scene defines the hosting scene
  55635. * @returns the ribbon mesh
  55636. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55637. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55638. */
  55639. static CreateRibbon(name: string, options: {
  55640. pathArray: Vector3[][];
  55641. closeArray?: boolean;
  55642. closePath?: boolean;
  55643. offset?: number;
  55644. updatable?: boolean;
  55645. sideOrientation?: number;
  55646. frontUVs?: Vector4;
  55647. backUVs?: Vector4;
  55648. instance?: Mesh;
  55649. invertUV?: boolean;
  55650. uvs?: Vector2[];
  55651. colors?: Color4[];
  55652. }, scene?: Nullable<Scene>): Mesh;
  55653. /**
  55654. * Creates a cylinder or a cone mesh
  55655. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55656. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55657. * * 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.
  55658. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55659. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55660. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55661. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55662. * * 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).
  55663. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55664. * * 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).
  55665. * * 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
  55666. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55667. * * 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
  55668. * * 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.
  55669. * * If `enclose` is false, a ring surface is one element.
  55670. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55671. * * 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
  55672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55675. * @param name defines the name of the mesh
  55676. * @param options defines the options used to create the mesh
  55677. * @param scene defines the hosting scene
  55678. * @returns the cylinder mesh
  55679. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55680. */
  55681. static CreateCylinder(name: string, options: {
  55682. height?: number;
  55683. diameterTop?: number;
  55684. diameterBottom?: number;
  55685. diameter?: number;
  55686. tessellation?: number;
  55687. subdivisions?: number;
  55688. arc?: number;
  55689. faceColors?: Color4[];
  55690. faceUV?: Vector4[];
  55691. updatable?: boolean;
  55692. hasRings?: boolean;
  55693. enclose?: boolean;
  55694. cap?: number;
  55695. sideOrientation?: number;
  55696. frontUVs?: Vector4;
  55697. backUVs?: Vector4;
  55698. }, scene?: Nullable<Scene>): Mesh;
  55699. /**
  55700. * Creates a torus mesh
  55701. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55702. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55703. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55707. * @param name defines the name of the mesh
  55708. * @param options defines the options used to create the mesh
  55709. * @param scene defines the hosting scene
  55710. * @returns the torus mesh
  55711. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55712. */
  55713. static CreateTorus(name: string, options: {
  55714. diameter?: number;
  55715. thickness?: number;
  55716. tessellation?: number;
  55717. updatable?: boolean;
  55718. sideOrientation?: number;
  55719. frontUVs?: Vector4;
  55720. backUVs?: Vector4;
  55721. }, scene?: Nullable<Scene>): Mesh;
  55722. /**
  55723. * Creates a torus knot mesh
  55724. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55725. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55726. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55727. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55731. * @param name defines the name of the mesh
  55732. * @param options defines the options used to create the mesh
  55733. * @param scene defines the hosting scene
  55734. * @returns the torus knot mesh
  55735. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55736. */
  55737. static CreateTorusKnot(name: string, options: {
  55738. radius?: number;
  55739. tube?: number;
  55740. radialSegments?: number;
  55741. tubularSegments?: number;
  55742. p?: number;
  55743. q?: number;
  55744. updatable?: boolean;
  55745. sideOrientation?: number;
  55746. frontUVs?: Vector4;
  55747. backUVs?: Vector4;
  55748. }, scene?: Nullable<Scene>): Mesh;
  55749. /**
  55750. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55751. * * 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
  55752. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55753. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55754. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55755. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55756. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55757. * * 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
  55758. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55761. * @param name defines the name of the new line system
  55762. * @param options defines the options used to create the line system
  55763. * @param scene defines the hosting scene
  55764. * @returns a new line system mesh
  55765. */
  55766. static CreateLineSystem(name: string, options: {
  55767. lines: Vector3[][];
  55768. updatable?: boolean;
  55769. instance?: Nullable<LinesMesh>;
  55770. colors?: Nullable<Color4[][]>;
  55771. useVertexAlpha?: boolean;
  55772. }, scene: Nullable<Scene>): LinesMesh;
  55773. /**
  55774. * Creates a line mesh
  55775. * 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
  55776. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55777. * * The parameter `points` is an array successive Vector3
  55778. * * 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
  55779. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55780. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55781. * * When updating an instance, remember that only point positions can change, not the number of points
  55782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55783. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55784. * @param name defines the name of the new line system
  55785. * @param options defines the options used to create the line system
  55786. * @param scene defines the hosting scene
  55787. * @returns a new line mesh
  55788. */
  55789. static CreateLines(name: string, options: {
  55790. points: Vector3[];
  55791. updatable?: boolean;
  55792. instance?: Nullable<LinesMesh>;
  55793. colors?: Color4[];
  55794. useVertexAlpha?: boolean;
  55795. }, scene?: Nullable<Scene>): LinesMesh;
  55796. /**
  55797. * Creates a dashed line mesh
  55798. * * 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
  55799. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55800. * * The parameter `points` is an array successive Vector3
  55801. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55802. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55803. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55804. * * 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
  55805. * * When updating an instance, remember that only point positions can change, not the number of points
  55806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55807. * @param name defines the name of the mesh
  55808. * @param options defines the options used to create the mesh
  55809. * @param scene defines the hosting scene
  55810. * @returns the dashed line mesh
  55811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55812. */
  55813. static CreateDashedLines(name: string, options: {
  55814. points: Vector3[];
  55815. dashSize?: number;
  55816. gapSize?: number;
  55817. dashNb?: number;
  55818. updatable?: boolean;
  55819. instance?: LinesMesh;
  55820. }, scene?: Nullable<Scene>): LinesMesh;
  55821. /**
  55822. * 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.
  55823. * * 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.
  55824. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55825. * * 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.
  55826. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55827. * * 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
  55828. * * 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
  55829. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55832. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55834. * @param name defines the name of the mesh
  55835. * @param options defines the options used to create the mesh
  55836. * @param scene defines the hosting scene
  55837. * @returns the extruded shape mesh
  55838. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55840. */
  55841. static ExtrudeShape(name: string, options: {
  55842. shape: Vector3[];
  55843. path: Vector3[];
  55844. scale?: number;
  55845. rotation?: number;
  55846. cap?: number;
  55847. updatable?: boolean;
  55848. sideOrientation?: number;
  55849. frontUVs?: Vector4;
  55850. backUVs?: Vector4;
  55851. instance?: Mesh;
  55852. invertUV?: boolean;
  55853. }, scene?: Nullable<Scene>): Mesh;
  55854. /**
  55855. * Creates an custom extruded shape mesh.
  55856. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55857. * * 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.
  55858. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55859. * * 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
  55860. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55861. * * 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
  55862. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55863. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55864. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55865. * * 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
  55866. * * 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
  55867. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55872. * @param name defines the name of the mesh
  55873. * @param options defines the options used to create the mesh
  55874. * @param scene defines the hosting scene
  55875. * @returns the custom extruded shape mesh
  55876. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55877. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55879. */
  55880. static ExtrudeShapeCustom(name: string, options: {
  55881. shape: Vector3[];
  55882. path: Vector3[];
  55883. scaleFunction?: any;
  55884. rotationFunction?: any;
  55885. ribbonCloseArray?: boolean;
  55886. ribbonClosePath?: boolean;
  55887. cap?: number;
  55888. updatable?: boolean;
  55889. sideOrientation?: number;
  55890. frontUVs?: Vector4;
  55891. backUVs?: Vector4;
  55892. instance?: Mesh;
  55893. invertUV?: boolean;
  55894. }, scene?: Nullable<Scene>): Mesh;
  55895. /**
  55896. * Creates lathe mesh.
  55897. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55898. * * 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
  55899. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55900. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55901. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55902. * * 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
  55903. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55904. * * 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
  55905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55909. * @param name defines the name of the mesh
  55910. * @param options defines the options used to create the mesh
  55911. * @param scene defines the hosting scene
  55912. * @returns the lathe mesh
  55913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55914. */
  55915. static CreateLathe(name: string, options: {
  55916. shape: Vector3[];
  55917. radius?: number;
  55918. tessellation?: number;
  55919. clip?: number;
  55920. arc?: number;
  55921. closed?: boolean;
  55922. updatable?: boolean;
  55923. sideOrientation?: number;
  55924. frontUVs?: Vector4;
  55925. backUVs?: Vector4;
  55926. cap?: number;
  55927. invertUV?: boolean;
  55928. }, scene?: Nullable<Scene>): Mesh;
  55929. /**
  55930. * Creates a tiled plane mesh
  55931. * * You can set a limited pattern arrangement with the tiles
  55932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55935. * @param name defines the name of the mesh
  55936. * @param options defines the options used to create the mesh
  55937. * @param scene defines the hosting scene
  55938. * @returns the plane mesh
  55939. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55940. */
  55941. static CreateTiledPlane(name: string, options: {
  55942. pattern?: number;
  55943. tileSize?: number;
  55944. tileWidth?: number;
  55945. tileHeight?: number;
  55946. size?: number;
  55947. width?: number;
  55948. height?: number;
  55949. alignHorizontal?: number;
  55950. alignVertical?: number;
  55951. sideOrientation?: number;
  55952. frontUVs?: Vector4;
  55953. backUVs?: Vector4;
  55954. updatable?: boolean;
  55955. }, scene?: Nullable<Scene>): Mesh;
  55956. /**
  55957. * Creates a plane mesh
  55958. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55959. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55960. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55964. * @param name defines the name of the mesh
  55965. * @param options defines the options used to create the mesh
  55966. * @param scene defines the hosting scene
  55967. * @returns the plane mesh
  55968. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55969. */
  55970. static CreatePlane(name: string, options: {
  55971. size?: number;
  55972. width?: number;
  55973. height?: number;
  55974. sideOrientation?: number;
  55975. frontUVs?: Vector4;
  55976. backUVs?: Vector4;
  55977. updatable?: boolean;
  55978. sourcePlane?: Plane;
  55979. }, scene?: Nullable<Scene>): Mesh;
  55980. /**
  55981. * Creates a ground mesh
  55982. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55983. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55985. * @param name defines the name of the mesh
  55986. * @param options defines the options used to create the mesh
  55987. * @param scene defines the hosting scene
  55988. * @returns the ground mesh
  55989. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55990. */
  55991. static CreateGround(name: string, options: {
  55992. width?: number;
  55993. height?: number;
  55994. subdivisions?: number;
  55995. subdivisionsX?: number;
  55996. subdivisionsY?: number;
  55997. updatable?: boolean;
  55998. }, scene?: Nullable<Scene>): Mesh;
  55999. /**
  56000. * Creates a tiled ground mesh
  56001. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56002. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56003. * * 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
  56004. * * 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
  56005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56006. * @param name defines the name of the mesh
  56007. * @param options defines the options used to create the mesh
  56008. * @param scene defines the hosting scene
  56009. * @returns the tiled ground mesh
  56010. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56011. */
  56012. static CreateTiledGround(name: string, options: {
  56013. xmin: number;
  56014. zmin: number;
  56015. xmax: number;
  56016. zmax: number;
  56017. subdivisions?: {
  56018. w: number;
  56019. h: number;
  56020. };
  56021. precision?: {
  56022. w: number;
  56023. h: number;
  56024. };
  56025. updatable?: boolean;
  56026. }, scene?: Nullable<Scene>): Mesh;
  56027. /**
  56028. * Creates a ground mesh from a height map
  56029. * * The parameter `url` sets the URL of the height map image resource.
  56030. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56031. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56032. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56033. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56034. * * 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.
  56035. * * 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).
  56036. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56038. * @param name defines the name of the mesh
  56039. * @param url defines the url to the height map
  56040. * @param options defines the options used to create the mesh
  56041. * @param scene defines the hosting scene
  56042. * @returns the ground mesh
  56043. * @see https://doc.babylonjs.com/babylon101/height_map
  56044. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56045. */
  56046. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56047. width?: number;
  56048. height?: number;
  56049. subdivisions?: number;
  56050. minHeight?: number;
  56051. maxHeight?: number;
  56052. colorFilter?: Color3;
  56053. alphaFilter?: number;
  56054. updatable?: boolean;
  56055. onReady?: (mesh: GroundMesh) => void;
  56056. }, scene?: Nullable<Scene>): GroundMesh;
  56057. /**
  56058. * Creates a polygon mesh
  56059. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56060. * * 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
  56061. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56064. * * Remember you can only change the shape positions, not their number when updating a polygon
  56065. * @param name defines the name of the mesh
  56066. * @param options defines the options used to create the mesh
  56067. * @param scene defines the hosting scene
  56068. * @param earcutInjection can be used to inject your own earcut reference
  56069. * @returns the polygon mesh
  56070. */
  56071. static CreatePolygon(name: string, options: {
  56072. shape: Vector3[];
  56073. holes?: Vector3[][];
  56074. depth?: number;
  56075. faceUV?: Vector4[];
  56076. faceColors?: Color4[];
  56077. updatable?: boolean;
  56078. sideOrientation?: number;
  56079. frontUVs?: Vector4;
  56080. backUVs?: Vector4;
  56081. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56082. /**
  56083. * Creates an extruded polygon mesh, with depth in the Y direction.
  56084. * * 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)
  56085. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56086. * @param name defines the name of the mesh
  56087. * @param options defines the options used to create the mesh
  56088. * @param scene defines the hosting scene
  56089. * @param earcutInjection can be used to inject your own earcut reference
  56090. * @returns the polygon mesh
  56091. */
  56092. static ExtrudePolygon(name: string, options: {
  56093. shape: Vector3[];
  56094. holes?: Vector3[][];
  56095. depth?: number;
  56096. faceUV?: Vector4[];
  56097. faceColors?: Color4[];
  56098. updatable?: boolean;
  56099. sideOrientation?: number;
  56100. frontUVs?: Vector4;
  56101. backUVs?: Vector4;
  56102. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56103. /**
  56104. * Creates a tube mesh.
  56105. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56106. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56107. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56108. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56109. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56110. * * 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)
  56111. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56112. * * 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
  56113. * * 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
  56114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56118. * @param name defines the name of the mesh
  56119. * @param options defines the options used to create the mesh
  56120. * @param scene defines the hosting scene
  56121. * @returns the tube mesh
  56122. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56123. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56124. */
  56125. static CreateTube(name: string, options: {
  56126. path: Vector3[];
  56127. radius?: number;
  56128. tessellation?: number;
  56129. radiusFunction?: {
  56130. (i: number, distance: number): number;
  56131. };
  56132. cap?: number;
  56133. arc?: number;
  56134. updatable?: boolean;
  56135. sideOrientation?: number;
  56136. frontUVs?: Vector4;
  56137. backUVs?: Vector4;
  56138. instance?: Mesh;
  56139. invertUV?: boolean;
  56140. }, scene?: Nullable<Scene>): Mesh;
  56141. /**
  56142. * Creates a polyhedron mesh
  56143. * * 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
  56144. * * The parameter `size` (positive float, default 1) sets the polygon size
  56145. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56146. * * 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`
  56147. * * 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
  56148. * * 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)`)
  56149. * * 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
  56150. * * 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
  56151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56154. * @param name defines the name of the mesh
  56155. * @param options defines the options used to create the mesh
  56156. * @param scene defines the hosting scene
  56157. * @returns the polyhedron mesh
  56158. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56159. */
  56160. static CreatePolyhedron(name: string, options: {
  56161. type?: number;
  56162. size?: number;
  56163. sizeX?: number;
  56164. sizeY?: number;
  56165. sizeZ?: number;
  56166. custom?: any;
  56167. faceUV?: Vector4[];
  56168. faceColors?: Color4[];
  56169. flat?: boolean;
  56170. updatable?: boolean;
  56171. sideOrientation?: number;
  56172. frontUVs?: Vector4;
  56173. backUVs?: Vector4;
  56174. }, scene?: Nullable<Scene>): Mesh;
  56175. /**
  56176. * Creates a decal mesh.
  56177. * 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
  56178. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56179. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56180. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56181. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56182. * @param name defines the name of the mesh
  56183. * @param sourceMesh defines the mesh where the decal must be applied
  56184. * @param options defines the options used to create the mesh
  56185. * @param scene defines the hosting scene
  56186. * @returns the decal mesh
  56187. * @see https://doc.babylonjs.com/how_to/decals
  56188. */
  56189. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56190. position?: Vector3;
  56191. normal?: Vector3;
  56192. size?: Vector3;
  56193. angle?: number;
  56194. }): Mesh;
  56195. }
  56196. }
  56197. declare module "babylonjs/Meshes/meshSimplification" {
  56198. import { Mesh } from "babylonjs/Meshes/mesh";
  56199. /**
  56200. * A simplifier interface for future simplification implementations
  56201. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56202. */
  56203. export interface ISimplifier {
  56204. /**
  56205. * Simplification of a given mesh according to the given settings.
  56206. * Since this requires computation, it is assumed that the function runs async.
  56207. * @param settings The settings of the simplification, including quality and distance
  56208. * @param successCallback A callback that will be called after the mesh was simplified.
  56209. * @param errorCallback in case of an error, this callback will be called. optional.
  56210. */
  56211. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56212. }
  56213. /**
  56214. * Expected simplification settings.
  56215. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56216. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56217. */
  56218. export interface ISimplificationSettings {
  56219. /**
  56220. * Gets or sets the expected quality
  56221. */
  56222. quality: number;
  56223. /**
  56224. * Gets or sets the distance when this optimized version should be used
  56225. */
  56226. distance: number;
  56227. /**
  56228. * Gets an already optimized mesh
  56229. */
  56230. optimizeMesh?: boolean;
  56231. }
  56232. /**
  56233. * Class used to specify simplification options
  56234. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56235. */
  56236. export class SimplificationSettings implements ISimplificationSettings {
  56237. /** expected quality */
  56238. quality: number;
  56239. /** distance when this optimized version should be used */
  56240. distance: number;
  56241. /** already optimized mesh */
  56242. optimizeMesh?: boolean | undefined;
  56243. /**
  56244. * Creates a SimplificationSettings
  56245. * @param quality expected quality
  56246. * @param distance distance when this optimized version should be used
  56247. * @param optimizeMesh already optimized mesh
  56248. */
  56249. constructor(
  56250. /** expected quality */
  56251. quality: number,
  56252. /** distance when this optimized version should be used */
  56253. distance: number,
  56254. /** already optimized mesh */
  56255. optimizeMesh?: boolean | undefined);
  56256. }
  56257. /**
  56258. * Interface used to define a simplification task
  56259. */
  56260. export interface ISimplificationTask {
  56261. /**
  56262. * Array of settings
  56263. */
  56264. settings: Array<ISimplificationSettings>;
  56265. /**
  56266. * Simplification type
  56267. */
  56268. simplificationType: SimplificationType;
  56269. /**
  56270. * Mesh to simplify
  56271. */
  56272. mesh: Mesh;
  56273. /**
  56274. * Callback called on success
  56275. */
  56276. successCallback?: () => void;
  56277. /**
  56278. * Defines if parallel processing can be used
  56279. */
  56280. parallelProcessing: boolean;
  56281. }
  56282. /**
  56283. * Queue used to order the simplification tasks
  56284. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56285. */
  56286. export class SimplificationQueue {
  56287. private _simplificationArray;
  56288. /**
  56289. * Gets a boolean indicating that the process is still running
  56290. */
  56291. running: boolean;
  56292. /**
  56293. * Creates a new queue
  56294. */
  56295. constructor();
  56296. /**
  56297. * Adds a new simplification task
  56298. * @param task defines a task to add
  56299. */
  56300. addTask(task: ISimplificationTask): void;
  56301. /**
  56302. * Execute next task
  56303. */
  56304. executeNext(): void;
  56305. /**
  56306. * Execute a simplification task
  56307. * @param task defines the task to run
  56308. */
  56309. runSimplification(task: ISimplificationTask): void;
  56310. private getSimplifier;
  56311. }
  56312. /**
  56313. * The implemented types of simplification
  56314. * At the moment only Quadratic Error Decimation is implemented
  56315. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56316. */
  56317. export enum SimplificationType {
  56318. /** Quadratic error decimation */
  56319. QUADRATIC = 0
  56320. }
  56321. }
  56322. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56323. import { Scene } from "babylonjs/scene";
  56324. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56325. import { ISceneComponent } from "babylonjs/sceneComponent";
  56326. module "babylonjs/scene" {
  56327. interface Scene {
  56328. /** @hidden (Backing field) */
  56329. _simplificationQueue: SimplificationQueue;
  56330. /**
  56331. * Gets or sets the simplification queue attached to the scene
  56332. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56333. */
  56334. simplificationQueue: SimplificationQueue;
  56335. }
  56336. }
  56337. module "babylonjs/Meshes/mesh" {
  56338. interface Mesh {
  56339. /**
  56340. * Simplify the mesh according to the given array of settings.
  56341. * Function will return immediately and will simplify async
  56342. * @param settings a collection of simplification settings
  56343. * @param parallelProcessing should all levels calculate parallel or one after the other
  56344. * @param simplificationType the type of simplification to run
  56345. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56346. * @returns the current mesh
  56347. */
  56348. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56349. }
  56350. }
  56351. /**
  56352. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56353. * created in a scene
  56354. */
  56355. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56356. /**
  56357. * The component name helpfull to identify the component in the list of scene components.
  56358. */
  56359. readonly name: string;
  56360. /**
  56361. * The scene the component belongs to.
  56362. */
  56363. scene: Scene;
  56364. /**
  56365. * Creates a new instance of the component for the given scene
  56366. * @param scene Defines the scene to register the component in
  56367. */
  56368. constructor(scene: Scene);
  56369. /**
  56370. * Registers the component in a given scene
  56371. */
  56372. register(): void;
  56373. /**
  56374. * Rebuilds the elements related to this component in case of
  56375. * context lost for instance.
  56376. */
  56377. rebuild(): void;
  56378. /**
  56379. * Disposes the component and the associated ressources
  56380. */
  56381. dispose(): void;
  56382. private _beforeCameraUpdate;
  56383. }
  56384. }
  56385. declare module "babylonjs/Meshes/Builders/index" {
  56386. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56387. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56388. export * from "babylonjs/Meshes/Builders/discBuilder";
  56389. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56390. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56391. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56392. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56393. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56394. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56395. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56396. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56397. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56398. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56399. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56400. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56401. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56402. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56403. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56404. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56405. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56406. }
  56407. declare module "babylonjs/Meshes/index" {
  56408. export * from "babylonjs/Meshes/abstractMesh";
  56409. export * from "babylonjs/Meshes/buffer";
  56410. export * from "babylonjs/Meshes/Compression/index";
  56411. export * from "babylonjs/Meshes/csg";
  56412. export * from "babylonjs/Meshes/geometry";
  56413. export * from "babylonjs/Meshes/groundMesh";
  56414. export * from "babylonjs/Meshes/trailMesh";
  56415. export * from "babylonjs/Meshes/instancedMesh";
  56416. export * from "babylonjs/Meshes/linesMesh";
  56417. export * from "babylonjs/Meshes/mesh";
  56418. export * from "babylonjs/Meshes/mesh.vertexData";
  56419. export * from "babylonjs/Meshes/meshBuilder";
  56420. export * from "babylonjs/Meshes/meshSimplification";
  56421. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56422. export * from "babylonjs/Meshes/polygonMesh";
  56423. export * from "babylonjs/Meshes/subMesh";
  56424. export * from "babylonjs/Meshes/meshLODLevel";
  56425. export * from "babylonjs/Meshes/transformNode";
  56426. export * from "babylonjs/Meshes/Builders/index";
  56427. export * from "babylonjs/Meshes/dataBuffer";
  56428. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56429. }
  56430. declare module "babylonjs/Morph/index" {
  56431. export * from "babylonjs/Morph/morphTarget";
  56432. export * from "babylonjs/Morph/morphTargetManager";
  56433. }
  56434. declare module "babylonjs/Offline/database" {
  56435. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56436. /**
  56437. * Class used to enable access to IndexedDB
  56438. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56439. */
  56440. export class Database implements IOfflineProvider {
  56441. private _callbackManifestChecked;
  56442. private _currentSceneUrl;
  56443. private _db;
  56444. private _enableSceneOffline;
  56445. private _enableTexturesOffline;
  56446. private _manifestVersionFound;
  56447. private _mustUpdateRessources;
  56448. private _hasReachedQuota;
  56449. private _isSupported;
  56450. private _idbFactory;
  56451. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56452. private static IsUASupportingBlobStorage;
  56453. /**
  56454. * Gets a boolean indicating if Database storate is enabled (off by default)
  56455. */
  56456. static IDBStorageEnabled: boolean;
  56457. /**
  56458. * Gets a boolean indicating if scene must be saved in the database
  56459. */
  56460. readonly enableSceneOffline: boolean;
  56461. /**
  56462. * Gets a boolean indicating if textures must be saved in the database
  56463. */
  56464. readonly enableTexturesOffline: boolean;
  56465. /**
  56466. * Creates a new Database
  56467. * @param urlToScene defines the url to load the scene
  56468. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56469. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56470. */
  56471. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56472. private static _ParseURL;
  56473. private static _ReturnFullUrlLocation;
  56474. private _checkManifestFile;
  56475. /**
  56476. * Open the database and make it available
  56477. * @param successCallback defines the callback to call on success
  56478. * @param errorCallback defines the callback to call on error
  56479. */
  56480. open(successCallback: () => void, errorCallback: () => void): void;
  56481. /**
  56482. * Loads an image from the database
  56483. * @param url defines the url to load from
  56484. * @param image defines the target DOM image
  56485. */
  56486. loadImage(url: string, image: HTMLImageElement): void;
  56487. private _loadImageFromDBAsync;
  56488. private _saveImageIntoDBAsync;
  56489. private _checkVersionFromDB;
  56490. private _loadVersionFromDBAsync;
  56491. private _saveVersionIntoDBAsync;
  56492. /**
  56493. * Loads a file from database
  56494. * @param url defines the URL to load from
  56495. * @param sceneLoaded defines a callback to call on success
  56496. * @param progressCallBack defines a callback to call when progress changed
  56497. * @param errorCallback defines a callback to call on error
  56498. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56499. */
  56500. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56501. private _loadFileAsync;
  56502. private _saveFileAsync;
  56503. /**
  56504. * Validates if xhr data is correct
  56505. * @param xhr defines the request to validate
  56506. * @param dataType defines the expected data type
  56507. * @returns true if data is correct
  56508. */
  56509. private static _ValidateXHRData;
  56510. }
  56511. }
  56512. declare module "babylonjs/Offline/index" {
  56513. export * from "babylonjs/Offline/database";
  56514. export * from "babylonjs/Offline/IOfflineProvider";
  56515. }
  56516. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56517. /** @hidden */
  56518. export var gpuUpdateParticlesPixelShader: {
  56519. name: string;
  56520. shader: string;
  56521. };
  56522. }
  56523. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56524. /** @hidden */
  56525. export var gpuUpdateParticlesVertexShader: {
  56526. name: string;
  56527. shader: string;
  56528. };
  56529. }
  56530. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56531. /** @hidden */
  56532. export var clipPlaneFragmentDeclaration2: {
  56533. name: string;
  56534. shader: string;
  56535. };
  56536. }
  56537. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56538. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56539. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56540. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56541. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56542. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56543. /** @hidden */
  56544. export var gpuRenderParticlesPixelShader: {
  56545. name: string;
  56546. shader: string;
  56547. };
  56548. }
  56549. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56550. /** @hidden */
  56551. export var clipPlaneVertexDeclaration2: {
  56552. name: string;
  56553. shader: string;
  56554. };
  56555. }
  56556. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56557. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56558. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56559. /** @hidden */
  56560. export var gpuRenderParticlesVertexShader: {
  56561. name: string;
  56562. shader: string;
  56563. };
  56564. }
  56565. declare module "babylonjs/Particles/gpuParticleSystem" {
  56566. import { Nullable } from "babylonjs/types";
  56567. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56568. import { Observable } from "babylonjs/Misc/observable";
  56569. import { Color4, Color3 } from "babylonjs/Maths/math";
  56570. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56571. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56572. import { Scene, IDisposable } from "babylonjs/scene";
  56573. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56574. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56575. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56576. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56577. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56578. /**
  56579. * This represents a GPU particle system in Babylon
  56580. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56581. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56582. */
  56583. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56584. /**
  56585. * The layer mask we are rendering the particles through.
  56586. */
  56587. layerMask: number;
  56588. private _capacity;
  56589. private _activeCount;
  56590. private _currentActiveCount;
  56591. private _accumulatedCount;
  56592. private _renderEffect;
  56593. private _updateEffect;
  56594. private _buffer0;
  56595. private _buffer1;
  56596. private _spriteBuffer;
  56597. private _updateVAO;
  56598. private _renderVAO;
  56599. private _targetIndex;
  56600. private _sourceBuffer;
  56601. private _targetBuffer;
  56602. private _engine;
  56603. private _currentRenderId;
  56604. private _started;
  56605. private _stopped;
  56606. private _timeDelta;
  56607. private _randomTexture;
  56608. private _randomTexture2;
  56609. private _attributesStrideSize;
  56610. private _updateEffectOptions;
  56611. private _randomTextureSize;
  56612. private _actualFrame;
  56613. private readonly _rawTextureWidth;
  56614. /**
  56615. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56616. */
  56617. static readonly IsSupported: boolean;
  56618. /**
  56619. * An event triggered when the system is disposed.
  56620. */
  56621. onDisposeObservable: Observable<GPUParticleSystem>;
  56622. /**
  56623. * Gets the maximum number of particles active at the same time.
  56624. * @returns The max number of active particles.
  56625. */
  56626. getCapacity(): number;
  56627. /**
  56628. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56629. * to override the particles.
  56630. */
  56631. forceDepthWrite: boolean;
  56632. /**
  56633. * Gets or set the number of active particles
  56634. */
  56635. activeParticleCount: number;
  56636. private _preWarmDone;
  56637. /**
  56638. * Is this system ready to be used/rendered
  56639. * @return true if the system is ready
  56640. */
  56641. isReady(): boolean;
  56642. /**
  56643. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56644. * @returns True if it has been started, otherwise false.
  56645. */
  56646. isStarted(): boolean;
  56647. /**
  56648. * Starts the particle system and begins to emit
  56649. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56650. */
  56651. start(delay?: number): void;
  56652. /**
  56653. * Stops the particle system.
  56654. */
  56655. stop(): void;
  56656. /**
  56657. * Remove all active particles
  56658. */
  56659. reset(): void;
  56660. /**
  56661. * Returns the string "GPUParticleSystem"
  56662. * @returns a string containing the class name
  56663. */
  56664. getClassName(): string;
  56665. private _colorGradientsTexture;
  56666. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56667. /**
  56668. * Adds a new color gradient
  56669. * @param gradient defines the gradient to use (between 0 and 1)
  56670. * @param color1 defines the color to affect to the specified gradient
  56671. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56672. * @returns the current particle system
  56673. */
  56674. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56675. /**
  56676. * Remove a specific color gradient
  56677. * @param gradient defines the gradient to remove
  56678. * @returns the current particle system
  56679. */
  56680. removeColorGradient(gradient: number): GPUParticleSystem;
  56681. private _angularSpeedGradientsTexture;
  56682. private _sizeGradientsTexture;
  56683. private _velocityGradientsTexture;
  56684. private _limitVelocityGradientsTexture;
  56685. private _dragGradientsTexture;
  56686. private _addFactorGradient;
  56687. /**
  56688. * Adds a new size gradient
  56689. * @param gradient defines the gradient to use (between 0 and 1)
  56690. * @param factor defines the size factor to affect to the specified gradient
  56691. * @returns the current particle system
  56692. */
  56693. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56694. /**
  56695. * Remove a specific size gradient
  56696. * @param gradient defines the gradient to remove
  56697. * @returns the current particle system
  56698. */
  56699. removeSizeGradient(gradient: number): GPUParticleSystem;
  56700. /**
  56701. * Adds a new angular speed gradient
  56702. * @param gradient defines the gradient to use (between 0 and 1)
  56703. * @param factor defines the angular speed to affect to the specified gradient
  56704. * @returns the current particle system
  56705. */
  56706. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56707. /**
  56708. * Remove a specific angular speed gradient
  56709. * @param gradient defines the gradient to remove
  56710. * @returns the current particle system
  56711. */
  56712. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56713. /**
  56714. * Adds a new velocity gradient
  56715. * @param gradient defines the gradient to use (between 0 and 1)
  56716. * @param factor defines the velocity to affect to the specified gradient
  56717. * @returns the current particle system
  56718. */
  56719. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56720. /**
  56721. * Remove a specific velocity gradient
  56722. * @param gradient defines the gradient to remove
  56723. * @returns the current particle system
  56724. */
  56725. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56726. /**
  56727. * Adds a new limit velocity gradient
  56728. * @param gradient defines the gradient to use (between 0 and 1)
  56729. * @param factor defines the limit velocity value to affect to the specified gradient
  56730. * @returns the current particle system
  56731. */
  56732. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56733. /**
  56734. * Remove a specific limit velocity gradient
  56735. * @param gradient defines the gradient to remove
  56736. * @returns the current particle system
  56737. */
  56738. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56739. /**
  56740. * Adds a new drag gradient
  56741. * @param gradient defines the gradient to use (between 0 and 1)
  56742. * @param factor defines the drag value to affect to the specified gradient
  56743. * @returns the current particle system
  56744. */
  56745. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56746. /**
  56747. * Remove a specific drag gradient
  56748. * @param gradient defines the gradient to remove
  56749. * @returns the current particle system
  56750. */
  56751. removeDragGradient(gradient: number): GPUParticleSystem;
  56752. /**
  56753. * Not supported by GPUParticleSystem
  56754. * @param gradient defines the gradient to use (between 0 and 1)
  56755. * @param factor defines the emit rate value to affect to the specified gradient
  56756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56757. * @returns the current particle system
  56758. */
  56759. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56760. /**
  56761. * Not supported by GPUParticleSystem
  56762. * @param gradient defines the gradient to remove
  56763. * @returns the current particle system
  56764. */
  56765. removeEmitRateGradient(gradient: number): IParticleSystem;
  56766. /**
  56767. * Not supported by GPUParticleSystem
  56768. * @param gradient defines the gradient to use (between 0 and 1)
  56769. * @param factor defines the start size value to affect to the specified gradient
  56770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56771. * @returns the current particle system
  56772. */
  56773. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56774. /**
  56775. * Not supported by GPUParticleSystem
  56776. * @param gradient defines the gradient to remove
  56777. * @returns the current particle system
  56778. */
  56779. removeStartSizeGradient(gradient: number): IParticleSystem;
  56780. /**
  56781. * Not supported by GPUParticleSystem
  56782. * @param gradient defines the gradient to use (between 0 and 1)
  56783. * @param min defines the color remap minimal range
  56784. * @param max defines the color remap maximal range
  56785. * @returns the current particle system
  56786. */
  56787. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56788. /**
  56789. * Not supported by GPUParticleSystem
  56790. * @param gradient defines the gradient to remove
  56791. * @returns the current particle system
  56792. */
  56793. removeColorRemapGradient(): IParticleSystem;
  56794. /**
  56795. * Not supported by GPUParticleSystem
  56796. * @param gradient defines the gradient to use (between 0 and 1)
  56797. * @param min defines the alpha remap minimal range
  56798. * @param max defines the alpha remap maximal range
  56799. * @returns the current particle system
  56800. */
  56801. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56802. /**
  56803. * Not supported by GPUParticleSystem
  56804. * @param gradient defines the gradient to remove
  56805. * @returns the current particle system
  56806. */
  56807. removeAlphaRemapGradient(): IParticleSystem;
  56808. /**
  56809. * Not supported by GPUParticleSystem
  56810. * @param gradient defines the gradient to use (between 0 and 1)
  56811. * @param color defines the color to affect to the specified gradient
  56812. * @returns the current particle system
  56813. */
  56814. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56815. /**
  56816. * Not supported by GPUParticleSystem
  56817. * @param gradient defines the gradient to remove
  56818. * @returns the current particle system
  56819. */
  56820. removeRampGradient(): IParticleSystem;
  56821. /**
  56822. * Not supported by GPUParticleSystem
  56823. * @returns the list of ramp gradients
  56824. */
  56825. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56826. /**
  56827. * Not supported by GPUParticleSystem
  56828. * Gets or sets a boolean indicating that ramp gradients must be used
  56829. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56830. */
  56831. useRampGradients: boolean;
  56832. /**
  56833. * Not supported by GPUParticleSystem
  56834. * @param gradient defines the gradient to use (between 0 and 1)
  56835. * @param factor defines the life time factor to affect to the specified gradient
  56836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56837. * @returns the current particle system
  56838. */
  56839. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56840. /**
  56841. * Not supported by GPUParticleSystem
  56842. * @param gradient defines the gradient to remove
  56843. * @returns the current particle system
  56844. */
  56845. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56846. /**
  56847. * Instantiates a GPU particle system.
  56848. * 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.
  56849. * @param name The name of the particle system
  56850. * @param options The options used to create the system
  56851. * @param scene The scene the particle system belongs to
  56852. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56853. */
  56854. constructor(name: string, options: Partial<{
  56855. capacity: number;
  56856. randomTextureSize: number;
  56857. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56858. protected _reset(): void;
  56859. private _createUpdateVAO;
  56860. private _createRenderVAO;
  56861. private _initialize;
  56862. /** @hidden */
  56863. _recreateUpdateEffect(): void;
  56864. /** @hidden */
  56865. _recreateRenderEffect(): void;
  56866. /**
  56867. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56868. * @param preWarm defines if we are in the pre-warmimg phase
  56869. */
  56870. animate(preWarm?: boolean): void;
  56871. private _createFactorGradientTexture;
  56872. private _createSizeGradientTexture;
  56873. private _createAngularSpeedGradientTexture;
  56874. private _createVelocityGradientTexture;
  56875. private _createLimitVelocityGradientTexture;
  56876. private _createDragGradientTexture;
  56877. private _createColorGradientTexture;
  56878. /**
  56879. * Renders the particle system in its current state
  56880. * @param preWarm defines if the system should only update the particles but not render them
  56881. * @returns the current number of particles
  56882. */
  56883. render(preWarm?: boolean): number;
  56884. /**
  56885. * Rebuilds the particle system
  56886. */
  56887. rebuild(): void;
  56888. private _releaseBuffers;
  56889. private _releaseVAOs;
  56890. /**
  56891. * Disposes the particle system and free the associated resources
  56892. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56893. */
  56894. dispose(disposeTexture?: boolean): void;
  56895. /**
  56896. * Clones the particle system.
  56897. * @param name The name of the cloned object
  56898. * @param newEmitter The new emitter to use
  56899. * @returns the cloned particle system
  56900. */
  56901. clone(name: string, newEmitter: any): GPUParticleSystem;
  56902. /**
  56903. * Serializes the particle system to a JSON object.
  56904. * @returns the JSON object
  56905. */
  56906. serialize(): any;
  56907. /**
  56908. * Parses a JSON object to create a GPU particle system.
  56909. * @param parsedParticleSystem The JSON object to parse
  56910. * @param scene The scene to create the particle system in
  56911. * @param rootUrl The root url to use to load external dependencies like texture
  56912. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56913. * @returns the parsed GPU particle system
  56914. */
  56915. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56916. }
  56917. }
  56918. declare module "babylonjs/Particles/particleSystemSet" {
  56919. import { Nullable } from "babylonjs/types";
  56920. import { Color3 } from "babylonjs/Maths/math";
  56921. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56923. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56924. import { Scene, IDisposable } from "babylonjs/scene";
  56925. /**
  56926. * Represents a set of particle systems working together to create a specific effect
  56927. */
  56928. export class ParticleSystemSet implements IDisposable {
  56929. private _emitterCreationOptions;
  56930. private _emitterNode;
  56931. /**
  56932. * Gets the particle system list
  56933. */
  56934. systems: IParticleSystem[];
  56935. /**
  56936. * Gets the emitter node used with this set
  56937. */
  56938. readonly emitterNode: Nullable<TransformNode>;
  56939. /**
  56940. * Creates a new emitter mesh as a sphere
  56941. * @param options defines the options used to create the sphere
  56942. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56943. * @param scene defines the hosting scene
  56944. */
  56945. setEmitterAsSphere(options: {
  56946. diameter: number;
  56947. segments: number;
  56948. color: Color3;
  56949. }, renderingGroupId: number, scene: Scene): void;
  56950. /**
  56951. * Starts all particle systems of the set
  56952. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56953. */
  56954. start(emitter?: AbstractMesh): void;
  56955. /**
  56956. * Release all associated resources
  56957. */
  56958. dispose(): void;
  56959. /**
  56960. * Serialize the set into a JSON compatible object
  56961. * @returns a JSON compatible representation of the set
  56962. */
  56963. serialize(): any;
  56964. /**
  56965. * Parse a new ParticleSystemSet from a serialized source
  56966. * @param data defines a JSON compatible representation of the set
  56967. * @param scene defines the hosting scene
  56968. * @param gpu defines if we want GPU particles or CPU particles
  56969. * @returns a new ParticleSystemSet
  56970. */
  56971. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56972. }
  56973. }
  56974. declare module "babylonjs/Particles/particleHelper" {
  56975. import { Nullable } from "babylonjs/types";
  56976. import { Scene } from "babylonjs/scene";
  56977. import { Vector3 } from "babylonjs/Maths/math";
  56978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56979. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56980. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56981. /**
  56982. * This class is made for on one-liner static method to help creating particle system set.
  56983. */
  56984. export class ParticleHelper {
  56985. /**
  56986. * Gets or sets base Assets URL
  56987. */
  56988. static BaseAssetsUrl: string;
  56989. /**
  56990. * Create a default particle system that you can tweak
  56991. * @param emitter defines the emitter to use
  56992. * @param capacity defines the system capacity (default is 500 particles)
  56993. * @param scene defines the hosting scene
  56994. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56995. * @returns the new Particle system
  56996. */
  56997. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56998. /**
  56999. * This is the main static method (one-liner) of this helper to create different particle systems
  57000. * @param type This string represents the type to the particle system to create
  57001. * @param scene The scene where the particle system should live
  57002. * @param gpu If the system will use gpu
  57003. * @returns the ParticleSystemSet created
  57004. */
  57005. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57006. /**
  57007. * Static function used to export a particle system to a ParticleSystemSet variable.
  57008. * Please note that the emitter shape is not exported
  57009. * @param systems defines the particle systems to export
  57010. * @returns the created particle system set
  57011. */
  57012. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57013. }
  57014. }
  57015. declare module "babylonjs/Particles/particleSystemComponent" {
  57016. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57017. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57018. import "babylonjs/Shaders/particles.vertex";
  57019. module "babylonjs/Engines/engine" {
  57020. interface Engine {
  57021. /**
  57022. * Create an effect to use with particle systems.
  57023. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57024. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57025. * @param uniformsNames defines a list of attribute names
  57026. * @param samplers defines an array of string used to represent textures
  57027. * @param defines defines the string containing the defines to use to compile the shaders
  57028. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57029. * @param onCompiled defines a function to call when the effect creation is successful
  57030. * @param onError defines a function to call when the effect creation has failed
  57031. * @returns the new Effect
  57032. */
  57033. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57034. }
  57035. }
  57036. module "babylonjs/Meshes/mesh" {
  57037. interface Mesh {
  57038. /**
  57039. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57040. * @returns an array of IParticleSystem
  57041. */
  57042. getEmittedParticleSystems(): IParticleSystem[];
  57043. /**
  57044. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57045. * @returns an array of IParticleSystem
  57046. */
  57047. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57048. }
  57049. }
  57050. /**
  57051. * @hidden
  57052. */
  57053. export var _IDoNeedToBeInTheBuild: number;
  57054. }
  57055. declare module "babylonjs/Particles/index" {
  57056. export * from "babylonjs/Particles/baseParticleSystem";
  57057. export * from "babylonjs/Particles/EmitterTypes/index";
  57058. export * from "babylonjs/Particles/gpuParticleSystem";
  57059. export * from "babylonjs/Particles/IParticleSystem";
  57060. export * from "babylonjs/Particles/particle";
  57061. export * from "babylonjs/Particles/particleHelper";
  57062. export * from "babylonjs/Particles/particleSystem";
  57063. export * from "babylonjs/Particles/particleSystemComponent";
  57064. export * from "babylonjs/Particles/particleSystemSet";
  57065. export * from "babylonjs/Particles/solidParticle";
  57066. export * from "babylonjs/Particles/solidParticleSystem";
  57067. export * from "babylonjs/Particles/subEmitter";
  57068. }
  57069. declare module "babylonjs/Physics/physicsEngineComponent" {
  57070. import { Nullable } from "babylonjs/types";
  57071. import { Observable, Observer } from "babylonjs/Misc/observable";
  57072. import { Vector3 } from "babylonjs/Maths/math";
  57073. import { Mesh } from "babylonjs/Meshes/mesh";
  57074. import { ISceneComponent } from "babylonjs/sceneComponent";
  57075. import { Scene } from "babylonjs/scene";
  57076. import { Node } from "babylonjs/node";
  57077. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57079. module "babylonjs/scene" {
  57080. interface Scene {
  57081. /** @hidden (Backing field) */
  57082. _physicsEngine: Nullable<IPhysicsEngine>;
  57083. /**
  57084. * Gets the current physics engine
  57085. * @returns a IPhysicsEngine or null if none attached
  57086. */
  57087. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57088. /**
  57089. * Enables physics to the current scene
  57090. * @param gravity defines the scene's gravity for the physics engine
  57091. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57092. * @return a boolean indicating if the physics engine was initialized
  57093. */
  57094. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57095. /**
  57096. * Disables and disposes the physics engine associated with the scene
  57097. */
  57098. disablePhysicsEngine(): void;
  57099. /**
  57100. * Gets a boolean indicating if there is an active physics engine
  57101. * @returns a boolean indicating if there is an active physics engine
  57102. */
  57103. isPhysicsEnabled(): boolean;
  57104. /**
  57105. * Deletes a physics compound impostor
  57106. * @param compound defines the compound to delete
  57107. */
  57108. deleteCompoundImpostor(compound: any): void;
  57109. /**
  57110. * An event triggered when physic simulation is about to be run
  57111. */
  57112. onBeforePhysicsObservable: Observable<Scene>;
  57113. /**
  57114. * An event triggered when physic simulation has been done
  57115. */
  57116. onAfterPhysicsObservable: Observable<Scene>;
  57117. }
  57118. }
  57119. module "babylonjs/Meshes/abstractMesh" {
  57120. interface AbstractMesh {
  57121. /** @hidden */
  57122. _physicsImpostor: Nullable<PhysicsImpostor>;
  57123. /**
  57124. * Gets or sets impostor used for physic simulation
  57125. * @see http://doc.babylonjs.com/features/physics_engine
  57126. */
  57127. physicsImpostor: Nullable<PhysicsImpostor>;
  57128. /**
  57129. * Gets the current physics impostor
  57130. * @see http://doc.babylonjs.com/features/physics_engine
  57131. * @returns a physics impostor or null
  57132. */
  57133. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57134. /** Apply a physic impulse to the mesh
  57135. * @param force defines the force to apply
  57136. * @param contactPoint defines where to apply the force
  57137. * @returns the current mesh
  57138. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57139. */
  57140. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57141. /**
  57142. * Creates a physic joint between two meshes
  57143. * @param otherMesh defines the other mesh to use
  57144. * @param pivot1 defines the pivot to use on this mesh
  57145. * @param pivot2 defines the pivot to use on the other mesh
  57146. * @param options defines additional options (can be plugin dependent)
  57147. * @returns the current mesh
  57148. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57149. */
  57150. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57151. /** @hidden */
  57152. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57153. }
  57154. }
  57155. /**
  57156. * Defines the physics engine scene component responsible to manage a physics engine
  57157. */
  57158. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57159. /**
  57160. * The component name helpful to identify the component in the list of scene components.
  57161. */
  57162. readonly name: string;
  57163. /**
  57164. * The scene the component belongs to.
  57165. */
  57166. scene: Scene;
  57167. /**
  57168. * Creates a new instance of the component for the given scene
  57169. * @param scene Defines the scene to register the component in
  57170. */
  57171. constructor(scene: Scene);
  57172. /**
  57173. * Registers the component in a given scene
  57174. */
  57175. register(): void;
  57176. /**
  57177. * Rebuilds the elements related to this component in case of
  57178. * context lost for instance.
  57179. */
  57180. rebuild(): void;
  57181. /**
  57182. * Disposes the component and the associated ressources
  57183. */
  57184. dispose(): void;
  57185. }
  57186. }
  57187. declare module "babylonjs/Physics/physicsHelper" {
  57188. import { Nullable } from "babylonjs/types";
  57189. import { Vector3 } from "babylonjs/Maths/math";
  57190. import { Mesh } from "babylonjs/Meshes/mesh";
  57191. import { Scene } from "babylonjs/scene";
  57192. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57193. /**
  57194. * A helper for physics simulations
  57195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57196. */
  57197. export class PhysicsHelper {
  57198. private _scene;
  57199. private _physicsEngine;
  57200. /**
  57201. * Initializes the Physics helper
  57202. * @param scene Babylon.js scene
  57203. */
  57204. constructor(scene: Scene);
  57205. /**
  57206. * Applies a radial explosion impulse
  57207. * @param origin the origin of the explosion
  57208. * @param radiusOrEventOptions the radius or the options of radial explosion
  57209. * @param strength the explosion strength
  57210. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57211. * @returns A physics radial explosion event, or null
  57212. */
  57213. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57214. /**
  57215. * Applies a radial explosion force
  57216. * @param origin the origin of the explosion
  57217. * @param radiusOrEventOptions the radius or the options of radial explosion
  57218. * @param strength the explosion strength
  57219. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57220. * @returns A physics radial explosion event, or null
  57221. */
  57222. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57223. /**
  57224. * Creates a gravitational field
  57225. * @param origin the origin of the explosion
  57226. * @param radiusOrEventOptions the radius or the options of radial explosion
  57227. * @param strength the explosion strength
  57228. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57229. * @returns A physics gravitational field event, or null
  57230. */
  57231. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57232. /**
  57233. * Creates a physics updraft event
  57234. * @param origin the origin of the updraft
  57235. * @param radiusOrEventOptions the radius or the options of the updraft
  57236. * @param strength the strength of the updraft
  57237. * @param height the height of the updraft
  57238. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57239. * @returns A physics updraft event, or null
  57240. */
  57241. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57242. /**
  57243. * Creates a physics vortex event
  57244. * @param origin the of the vortex
  57245. * @param radiusOrEventOptions the radius or the options of the vortex
  57246. * @param strength the strength of the vortex
  57247. * @param height the height of the vortex
  57248. * @returns a Physics vortex event, or null
  57249. * A physics vortex event or null
  57250. */
  57251. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57252. }
  57253. /**
  57254. * Represents a physics radial explosion event
  57255. */
  57256. class PhysicsRadialExplosionEvent {
  57257. private _scene;
  57258. private _options;
  57259. private _sphere;
  57260. private _dataFetched;
  57261. /**
  57262. * Initializes a radial explosioin event
  57263. * @param _scene BabylonJS scene
  57264. * @param _options The options for the vortex event
  57265. */
  57266. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57267. /**
  57268. * Returns the data related to the radial explosion event (sphere).
  57269. * @returns The radial explosion event data
  57270. */
  57271. getData(): PhysicsRadialExplosionEventData;
  57272. /**
  57273. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57274. * @param impostor A physics imposter
  57275. * @param origin the origin of the explosion
  57276. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57277. */
  57278. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57279. /**
  57280. * Triggers affecterd impostors callbacks
  57281. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57282. */
  57283. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57284. /**
  57285. * Disposes the sphere.
  57286. * @param force Specifies if the sphere should be disposed by force
  57287. */
  57288. dispose(force?: boolean): void;
  57289. /*** Helpers ***/
  57290. private _prepareSphere;
  57291. private _intersectsWithSphere;
  57292. }
  57293. /**
  57294. * Represents a gravitational field event
  57295. */
  57296. class PhysicsGravitationalFieldEvent {
  57297. private _physicsHelper;
  57298. private _scene;
  57299. private _origin;
  57300. private _options;
  57301. private _tickCallback;
  57302. private _sphere;
  57303. private _dataFetched;
  57304. /**
  57305. * Initializes the physics gravitational field event
  57306. * @param _physicsHelper A physics helper
  57307. * @param _scene BabylonJS scene
  57308. * @param _origin The origin position of the gravitational field event
  57309. * @param _options The options for the vortex event
  57310. */
  57311. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57312. /**
  57313. * Returns the data related to the gravitational field event (sphere).
  57314. * @returns A gravitational field event
  57315. */
  57316. getData(): PhysicsGravitationalFieldEventData;
  57317. /**
  57318. * Enables the gravitational field.
  57319. */
  57320. enable(): void;
  57321. /**
  57322. * Disables the gravitational field.
  57323. */
  57324. disable(): void;
  57325. /**
  57326. * Disposes the sphere.
  57327. * @param force The force to dispose from the gravitational field event
  57328. */
  57329. dispose(force?: boolean): void;
  57330. private _tick;
  57331. }
  57332. /**
  57333. * Represents a physics updraft event
  57334. */
  57335. class PhysicsUpdraftEvent {
  57336. private _scene;
  57337. private _origin;
  57338. private _options;
  57339. private _physicsEngine;
  57340. private _originTop;
  57341. private _originDirection;
  57342. private _tickCallback;
  57343. private _cylinder;
  57344. private _cylinderPosition;
  57345. private _dataFetched;
  57346. /**
  57347. * Initializes the physics updraft event
  57348. * @param _scene BabylonJS scene
  57349. * @param _origin The origin position of the updraft
  57350. * @param _options The options for the updraft event
  57351. */
  57352. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57353. /**
  57354. * Returns the data related to the updraft event (cylinder).
  57355. * @returns A physics updraft event
  57356. */
  57357. getData(): PhysicsUpdraftEventData;
  57358. /**
  57359. * Enables the updraft.
  57360. */
  57361. enable(): void;
  57362. /**
  57363. * Disables the updraft.
  57364. */
  57365. disable(): void;
  57366. /**
  57367. * Disposes the cylinder.
  57368. * @param force Specifies if the updraft should be disposed by force
  57369. */
  57370. dispose(force?: boolean): void;
  57371. private getImpostorHitData;
  57372. private _tick;
  57373. /*** Helpers ***/
  57374. private _prepareCylinder;
  57375. private _intersectsWithCylinder;
  57376. }
  57377. /**
  57378. * Represents a physics vortex event
  57379. */
  57380. class PhysicsVortexEvent {
  57381. private _scene;
  57382. private _origin;
  57383. private _options;
  57384. private _physicsEngine;
  57385. private _originTop;
  57386. private _tickCallback;
  57387. private _cylinder;
  57388. private _cylinderPosition;
  57389. private _dataFetched;
  57390. /**
  57391. * Initializes the physics vortex event
  57392. * @param _scene The BabylonJS scene
  57393. * @param _origin The origin position of the vortex
  57394. * @param _options The options for the vortex event
  57395. */
  57396. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57397. /**
  57398. * Returns the data related to the vortex event (cylinder).
  57399. * @returns The physics vortex event data
  57400. */
  57401. getData(): PhysicsVortexEventData;
  57402. /**
  57403. * Enables the vortex.
  57404. */
  57405. enable(): void;
  57406. /**
  57407. * Disables the cortex.
  57408. */
  57409. disable(): void;
  57410. /**
  57411. * Disposes the sphere.
  57412. * @param force
  57413. */
  57414. dispose(force?: boolean): void;
  57415. private getImpostorHitData;
  57416. private _tick;
  57417. /*** Helpers ***/
  57418. private _prepareCylinder;
  57419. private _intersectsWithCylinder;
  57420. }
  57421. /**
  57422. * Options fot the radial explosion event
  57423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57424. */
  57425. export class PhysicsRadialExplosionEventOptions {
  57426. /**
  57427. * The radius of the sphere for the radial explosion.
  57428. */
  57429. radius: number;
  57430. /**
  57431. * The strenth of the explosion.
  57432. */
  57433. strength: number;
  57434. /**
  57435. * The strenght of the force in correspondence to the distance of the affected object
  57436. */
  57437. falloff: PhysicsRadialImpulseFalloff;
  57438. /**
  57439. * Sphere options for the radial explosion.
  57440. */
  57441. sphere: {
  57442. segments: number;
  57443. diameter: number;
  57444. };
  57445. /**
  57446. * Sphere options for the radial explosion.
  57447. */
  57448. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57449. }
  57450. /**
  57451. * Options fot the updraft event
  57452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57453. */
  57454. export class PhysicsUpdraftEventOptions {
  57455. /**
  57456. * The radius of the cylinder for the vortex
  57457. */
  57458. radius: number;
  57459. /**
  57460. * The strenth of the updraft.
  57461. */
  57462. strength: number;
  57463. /**
  57464. * The height of the cylinder for the updraft.
  57465. */
  57466. height: number;
  57467. /**
  57468. * The mode for the the updraft.
  57469. */
  57470. updraftMode: PhysicsUpdraftMode;
  57471. }
  57472. /**
  57473. * Options fot the vortex event
  57474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57475. */
  57476. export class PhysicsVortexEventOptions {
  57477. /**
  57478. * The radius of the cylinder for the vortex
  57479. */
  57480. radius: number;
  57481. /**
  57482. * The strenth of the vortex.
  57483. */
  57484. strength: number;
  57485. /**
  57486. * The height of the cylinder for the vortex.
  57487. */
  57488. height: number;
  57489. /**
  57490. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57491. */
  57492. centripetalForceThreshold: number;
  57493. /**
  57494. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57495. */
  57496. centripetalForceMultiplier: number;
  57497. /**
  57498. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57499. */
  57500. centrifugalForceMultiplier: number;
  57501. /**
  57502. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57503. */
  57504. updraftForceMultiplier: number;
  57505. }
  57506. /**
  57507. * The strenght of the force in correspondence to the distance of the affected object
  57508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57509. */
  57510. export enum PhysicsRadialImpulseFalloff {
  57511. /** Defines that impulse is constant in strength across it's whole radius */
  57512. Constant = 0,
  57513. /** Defines that impulse gets weaker if it's further from the origin */
  57514. Linear = 1
  57515. }
  57516. /**
  57517. * The strength of the force in correspondence to the distance of the affected object
  57518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57519. */
  57520. export enum PhysicsUpdraftMode {
  57521. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57522. Center = 0,
  57523. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57524. Perpendicular = 1
  57525. }
  57526. /**
  57527. * Interface for a physics hit data
  57528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57529. */
  57530. export interface PhysicsHitData {
  57531. /**
  57532. * The force applied at the contact point
  57533. */
  57534. force: Vector3;
  57535. /**
  57536. * The contact point
  57537. */
  57538. contactPoint: Vector3;
  57539. /**
  57540. * The distance from the origin to the contact point
  57541. */
  57542. distanceFromOrigin: number;
  57543. }
  57544. /**
  57545. * Interface for radial explosion event data
  57546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57547. */
  57548. export interface PhysicsRadialExplosionEventData {
  57549. /**
  57550. * A sphere used for the radial explosion event
  57551. */
  57552. sphere: Mesh;
  57553. }
  57554. /**
  57555. * Interface for gravitational field event data
  57556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57557. */
  57558. export interface PhysicsGravitationalFieldEventData {
  57559. /**
  57560. * A sphere mesh used for the gravitational field event
  57561. */
  57562. sphere: Mesh;
  57563. }
  57564. /**
  57565. * Interface for updraft event data
  57566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57567. */
  57568. export interface PhysicsUpdraftEventData {
  57569. /**
  57570. * A cylinder used for the updraft event
  57571. */
  57572. cylinder: Mesh;
  57573. }
  57574. /**
  57575. * Interface for vortex event data
  57576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57577. */
  57578. export interface PhysicsVortexEventData {
  57579. /**
  57580. * A cylinder used for the vortex event
  57581. */
  57582. cylinder: Mesh;
  57583. }
  57584. /**
  57585. * Interface for an affected physics impostor
  57586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57587. */
  57588. export interface PhysicsAffectedImpostorWithData {
  57589. /**
  57590. * The impostor affected by the effect
  57591. */
  57592. impostor: PhysicsImpostor;
  57593. /**
  57594. * The data about the hit/horce from the explosion
  57595. */
  57596. hitData: PhysicsHitData;
  57597. }
  57598. }
  57599. declare module "babylonjs/Physics/Plugins/index" {
  57600. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57601. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57602. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57603. }
  57604. declare module "babylonjs/Physics/index" {
  57605. export * from "babylonjs/Physics/IPhysicsEngine";
  57606. export * from "babylonjs/Physics/physicsEngine";
  57607. export * from "babylonjs/Physics/physicsEngineComponent";
  57608. export * from "babylonjs/Physics/physicsHelper";
  57609. export * from "babylonjs/Physics/physicsImpostor";
  57610. export * from "babylonjs/Physics/physicsJoint";
  57611. export * from "babylonjs/Physics/Plugins/index";
  57612. }
  57613. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57614. /** @hidden */
  57615. export var blackAndWhitePixelShader: {
  57616. name: string;
  57617. shader: string;
  57618. };
  57619. }
  57620. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57621. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57622. import { Camera } from "babylonjs/Cameras/camera";
  57623. import { Engine } from "babylonjs/Engines/engine";
  57624. import "babylonjs/Shaders/blackAndWhite.fragment";
  57625. /**
  57626. * Post process used to render in black and white
  57627. */
  57628. export class BlackAndWhitePostProcess extends PostProcess {
  57629. /**
  57630. * Linear about to convert he result to black and white (default: 1)
  57631. */
  57632. degree: number;
  57633. /**
  57634. * Creates a black and white post process
  57635. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57636. * @param name The name of the effect.
  57637. * @param options The required width/height ratio to downsize to before computing the render pass.
  57638. * @param camera The camera to apply the render pass to.
  57639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57640. * @param engine The engine which the post process will be applied. (default: current engine)
  57641. * @param reusable If the post process can be reused on the same frame. (default: false)
  57642. */
  57643. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57644. }
  57645. }
  57646. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57647. import { Nullable } from "babylonjs/types";
  57648. import { Camera } from "babylonjs/Cameras/camera";
  57649. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57650. import { Engine } from "babylonjs/Engines/engine";
  57651. /**
  57652. * This represents a set of one or more post processes in Babylon.
  57653. * A post process can be used to apply a shader to a texture after it is rendered.
  57654. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57655. */
  57656. export class PostProcessRenderEffect {
  57657. private _postProcesses;
  57658. private _getPostProcesses;
  57659. private _singleInstance;
  57660. private _cameras;
  57661. private _indicesForCamera;
  57662. /**
  57663. * Name of the effect
  57664. * @hidden
  57665. */
  57666. _name: string;
  57667. /**
  57668. * Instantiates a post process render effect.
  57669. * A post process can be used to apply a shader to a texture after it is rendered.
  57670. * @param engine The engine the effect is tied to
  57671. * @param name The name of the effect
  57672. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57673. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57674. */
  57675. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57676. /**
  57677. * Checks if all the post processes in the effect are supported.
  57678. */
  57679. readonly isSupported: boolean;
  57680. /**
  57681. * Updates the current state of the effect
  57682. * @hidden
  57683. */
  57684. _update(): void;
  57685. /**
  57686. * Attaches the effect on cameras
  57687. * @param cameras The camera to attach to.
  57688. * @hidden
  57689. */
  57690. _attachCameras(cameras: Camera): void;
  57691. /**
  57692. * Attaches the effect on cameras
  57693. * @param cameras The camera to attach to.
  57694. * @hidden
  57695. */
  57696. _attachCameras(cameras: Camera[]): void;
  57697. /**
  57698. * Detaches the effect on cameras
  57699. * @param cameras The camera to detatch from.
  57700. * @hidden
  57701. */
  57702. _detachCameras(cameras: Camera): void;
  57703. /**
  57704. * Detatches the effect on cameras
  57705. * @param cameras The camera to detatch from.
  57706. * @hidden
  57707. */
  57708. _detachCameras(cameras: Camera[]): void;
  57709. /**
  57710. * Enables the effect on given cameras
  57711. * @param cameras The camera to enable.
  57712. * @hidden
  57713. */
  57714. _enable(cameras: Camera): void;
  57715. /**
  57716. * Enables the effect on given cameras
  57717. * @param cameras The camera to enable.
  57718. * @hidden
  57719. */
  57720. _enable(cameras: Nullable<Camera[]>): void;
  57721. /**
  57722. * Disables the effect on the given cameras
  57723. * @param cameras The camera to disable.
  57724. * @hidden
  57725. */
  57726. _disable(cameras: Camera): void;
  57727. /**
  57728. * Disables the effect on the given cameras
  57729. * @param cameras The camera to disable.
  57730. * @hidden
  57731. */
  57732. _disable(cameras: Nullable<Camera[]>): void;
  57733. /**
  57734. * Gets a list of the post processes contained in the effect.
  57735. * @param camera The camera to get the post processes on.
  57736. * @returns The list of the post processes in the effect.
  57737. */
  57738. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57739. }
  57740. }
  57741. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57742. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57743. /** @hidden */
  57744. export var extractHighlightsPixelShader: {
  57745. name: string;
  57746. shader: string;
  57747. };
  57748. }
  57749. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57750. import { Nullable } from "babylonjs/types";
  57751. import { Camera } from "babylonjs/Cameras/camera";
  57752. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57753. import { Engine } from "babylonjs/Engines/engine";
  57754. import "babylonjs/Shaders/extractHighlights.fragment";
  57755. /**
  57756. * 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.
  57757. */
  57758. export class ExtractHighlightsPostProcess extends PostProcess {
  57759. /**
  57760. * The luminance threshold, pixels below this value will be set to black.
  57761. */
  57762. threshold: number;
  57763. /** @hidden */
  57764. _exposure: number;
  57765. /**
  57766. * Post process which has the input texture to be used when performing highlight extraction
  57767. * @hidden
  57768. */
  57769. _inputPostProcess: Nullable<PostProcess>;
  57770. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57771. }
  57772. }
  57773. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57774. /** @hidden */
  57775. export var bloomMergePixelShader: {
  57776. name: string;
  57777. shader: string;
  57778. };
  57779. }
  57780. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57781. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57782. import { Nullable } from "babylonjs/types";
  57783. import { Engine } from "babylonjs/Engines/engine";
  57784. import { Camera } from "babylonjs/Cameras/camera";
  57785. import "babylonjs/Shaders/bloomMerge.fragment";
  57786. /**
  57787. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57788. */
  57789. export class BloomMergePostProcess extends PostProcess {
  57790. /** Weight of the bloom to be added to the original input. */
  57791. weight: number;
  57792. /**
  57793. * Creates a new instance of @see BloomMergePostProcess
  57794. * @param name The name of the effect.
  57795. * @param originalFromInput Post process which's input will be used for the merge.
  57796. * @param blurred Blurred highlights post process which's output will be used.
  57797. * @param weight Weight of the bloom to be added to the original input.
  57798. * @param options The required width/height ratio to downsize to before computing the render pass.
  57799. * @param camera The camera to apply the render pass to.
  57800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57801. * @param engine The engine which the post process will be applied. (default: current engine)
  57802. * @param reusable If the post process can be reused on the same frame. (default: false)
  57803. * @param textureType Type of textures used when performing the post process. (default: 0)
  57804. * @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)
  57805. */
  57806. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57807. /** Weight of the bloom to be added to the original input. */
  57808. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57809. }
  57810. }
  57811. declare module "babylonjs/PostProcesses/bloomEffect" {
  57812. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57813. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57814. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57815. import { Camera } from "babylonjs/Cameras/camera";
  57816. import { Scene } from "babylonjs/scene";
  57817. /**
  57818. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57819. */
  57820. export class BloomEffect extends PostProcessRenderEffect {
  57821. private bloomScale;
  57822. /**
  57823. * @hidden Internal
  57824. */
  57825. _effects: Array<PostProcess>;
  57826. /**
  57827. * @hidden Internal
  57828. */
  57829. _downscale: ExtractHighlightsPostProcess;
  57830. private _blurX;
  57831. private _blurY;
  57832. private _merge;
  57833. /**
  57834. * The luminance threshold to find bright areas of the image to bloom.
  57835. */
  57836. threshold: number;
  57837. /**
  57838. * The strength of the bloom.
  57839. */
  57840. weight: number;
  57841. /**
  57842. * Specifies the size of the bloom blur kernel, relative to the final output size
  57843. */
  57844. kernel: number;
  57845. /**
  57846. * Creates a new instance of @see BloomEffect
  57847. * @param scene The scene the effect belongs to.
  57848. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57849. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57850. * @param bloomWeight The the strength of bloom.
  57851. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57852. * @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)
  57853. */
  57854. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57855. /**
  57856. * Disposes each of the internal effects for a given camera.
  57857. * @param camera The camera to dispose the effect on.
  57858. */
  57859. disposeEffects(camera: Camera): void;
  57860. /**
  57861. * @hidden Internal
  57862. */
  57863. _updateEffects(): void;
  57864. /**
  57865. * Internal
  57866. * @returns if all the contained post processes are ready.
  57867. * @hidden
  57868. */
  57869. _isReady(): boolean;
  57870. }
  57871. }
  57872. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57873. /** @hidden */
  57874. export var chromaticAberrationPixelShader: {
  57875. name: string;
  57876. shader: string;
  57877. };
  57878. }
  57879. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57880. import { Vector2 } from "babylonjs/Maths/math";
  57881. import { Nullable } from "babylonjs/types";
  57882. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57883. import { Camera } from "babylonjs/Cameras/camera";
  57884. import { Engine } from "babylonjs/Engines/engine";
  57885. import "babylonjs/Shaders/chromaticAberration.fragment";
  57886. /**
  57887. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57888. */
  57889. export class ChromaticAberrationPostProcess extends PostProcess {
  57890. /**
  57891. * The amount of seperation of rgb channels (default: 30)
  57892. */
  57893. aberrationAmount: number;
  57894. /**
  57895. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57896. */
  57897. radialIntensity: number;
  57898. /**
  57899. * 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))
  57900. */
  57901. direction: Vector2;
  57902. /**
  57903. * 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))
  57904. */
  57905. centerPosition: Vector2;
  57906. /**
  57907. * Creates a new instance ChromaticAberrationPostProcess
  57908. * @param name The name of the effect.
  57909. * @param screenWidth The width of the screen to apply the effect on.
  57910. * @param screenHeight The height of the screen to apply the effect on.
  57911. * @param options The required width/height ratio to downsize to before computing the render pass.
  57912. * @param camera The camera to apply the render pass to.
  57913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57914. * @param engine The engine which the post process will be applied. (default: current engine)
  57915. * @param reusable If the post process can be reused on the same frame. (default: false)
  57916. * @param textureType Type of textures used when performing the post process. (default: 0)
  57917. * @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)
  57918. */
  57919. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57920. }
  57921. }
  57922. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57923. /** @hidden */
  57924. export var circleOfConfusionPixelShader: {
  57925. name: string;
  57926. shader: string;
  57927. };
  57928. }
  57929. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57930. import { Nullable } from "babylonjs/types";
  57931. import { Engine } from "babylonjs/Engines/engine";
  57932. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57933. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57934. import { Camera } from "babylonjs/Cameras/camera";
  57935. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57936. /**
  57937. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57938. */
  57939. export class CircleOfConfusionPostProcess extends PostProcess {
  57940. /**
  57941. * 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.
  57942. */
  57943. lensSize: number;
  57944. /**
  57945. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57946. */
  57947. fStop: number;
  57948. /**
  57949. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57950. */
  57951. focusDistance: number;
  57952. /**
  57953. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57954. */
  57955. focalLength: number;
  57956. private _depthTexture;
  57957. /**
  57958. * Creates a new instance CircleOfConfusionPostProcess
  57959. * @param name The name of the effect.
  57960. * @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.
  57961. * @param options The required width/height ratio to downsize to before computing the render pass.
  57962. * @param camera The camera to apply the render pass to.
  57963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57964. * @param engine The engine which the post process will be applied. (default: current engine)
  57965. * @param reusable If the post process can be reused on the same frame. (default: false)
  57966. * @param textureType Type of textures used when performing the post process. (default: 0)
  57967. * @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)
  57968. */
  57969. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57970. /**
  57971. * 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.
  57972. */
  57973. depthTexture: RenderTargetTexture;
  57974. }
  57975. }
  57976. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57977. /** @hidden */
  57978. export var colorCorrectionPixelShader: {
  57979. name: string;
  57980. shader: string;
  57981. };
  57982. }
  57983. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57984. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57985. import { Engine } from "babylonjs/Engines/engine";
  57986. import { Camera } from "babylonjs/Cameras/camera";
  57987. import "babylonjs/Shaders/colorCorrection.fragment";
  57988. /**
  57989. *
  57990. * This post-process allows the modification of rendered colors by using
  57991. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57992. *
  57993. * The object needs to be provided an url to a texture containing the color
  57994. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57995. * Use an image editing software to tweak the LUT to match your needs.
  57996. *
  57997. * For an example of a color LUT, see here:
  57998. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57999. * For explanations on color grading, see here:
  58000. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58001. *
  58002. */
  58003. export class ColorCorrectionPostProcess extends PostProcess {
  58004. private _colorTableTexture;
  58005. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58006. }
  58007. }
  58008. declare module "babylonjs/Shaders/convolution.fragment" {
  58009. /** @hidden */
  58010. export var convolutionPixelShader: {
  58011. name: string;
  58012. shader: string;
  58013. };
  58014. }
  58015. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58016. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58017. import { Nullable } from "babylonjs/types";
  58018. import { Camera } from "babylonjs/Cameras/camera";
  58019. import { Engine } from "babylonjs/Engines/engine";
  58020. import "babylonjs/Shaders/convolution.fragment";
  58021. /**
  58022. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58023. * input texture to perform effects such as edge detection or sharpening
  58024. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58025. */
  58026. export class ConvolutionPostProcess extends PostProcess {
  58027. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58028. kernel: number[];
  58029. /**
  58030. * Creates a new instance ConvolutionPostProcess
  58031. * @param name The name of the effect.
  58032. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58033. * @param options The required width/height ratio to downsize to before computing the render pass.
  58034. * @param camera The camera to apply the render pass to.
  58035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58036. * @param engine The engine which the post process will be applied. (default: current engine)
  58037. * @param reusable If the post process can be reused on the same frame. (default: false)
  58038. * @param textureType Type of textures used when performing the post process. (default: 0)
  58039. */
  58040. constructor(name: string,
  58041. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58042. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58043. /**
  58044. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58045. */
  58046. static EdgeDetect0Kernel: number[];
  58047. /**
  58048. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58049. */
  58050. static EdgeDetect1Kernel: number[];
  58051. /**
  58052. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58053. */
  58054. static EdgeDetect2Kernel: number[];
  58055. /**
  58056. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58057. */
  58058. static SharpenKernel: number[];
  58059. /**
  58060. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58061. */
  58062. static EmbossKernel: number[];
  58063. /**
  58064. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58065. */
  58066. static GaussianKernel: number[];
  58067. }
  58068. }
  58069. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58070. import { Nullable } from "babylonjs/types";
  58071. import { Vector2 } from "babylonjs/Maths/math";
  58072. import { Camera } from "babylonjs/Cameras/camera";
  58073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58074. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58075. import { Engine } from "babylonjs/Engines/engine";
  58076. import { Scene } from "babylonjs/scene";
  58077. /**
  58078. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58079. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58080. * based on samples that have a large difference in distance than the center pixel.
  58081. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58082. */
  58083. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58084. direction: Vector2;
  58085. /**
  58086. * Creates a new instance CircleOfConfusionPostProcess
  58087. * @param name The name of the effect.
  58088. * @param scene The scene the effect belongs to.
  58089. * @param direction The direction the blur should be applied.
  58090. * @param kernel The size of the kernel used to blur.
  58091. * @param options The required width/height ratio to downsize to before computing the render pass.
  58092. * @param camera The camera to apply the render pass to.
  58093. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58094. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58096. * @param engine The engine which the post process will be applied. (default: current engine)
  58097. * @param reusable If the post process can be reused on the same frame. (default: false)
  58098. * @param textureType Type of textures used when performing the post process. (default: 0)
  58099. * @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)
  58100. */
  58101. 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);
  58102. }
  58103. }
  58104. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58105. /** @hidden */
  58106. export var depthOfFieldMergePixelShader: {
  58107. name: string;
  58108. shader: string;
  58109. };
  58110. }
  58111. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58112. import { Nullable } from "babylonjs/types";
  58113. import { Camera } from "babylonjs/Cameras/camera";
  58114. import { Effect } from "babylonjs/Materials/effect";
  58115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58116. import { Engine } from "babylonjs/Engines/engine";
  58117. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58118. /**
  58119. * Options to be set when merging outputs from the default pipeline.
  58120. */
  58121. export class DepthOfFieldMergePostProcessOptions {
  58122. /**
  58123. * The original image to merge on top of
  58124. */
  58125. originalFromInput: PostProcess;
  58126. /**
  58127. * Parameters to perform the merge of the depth of field effect
  58128. */
  58129. depthOfField?: {
  58130. circleOfConfusion: PostProcess;
  58131. blurSteps: Array<PostProcess>;
  58132. };
  58133. /**
  58134. * Parameters to perform the merge of bloom effect
  58135. */
  58136. bloom?: {
  58137. blurred: PostProcess;
  58138. weight: number;
  58139. };
  58140. }
  58141. /**
  58142. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58143. */
  58144. export class DepthOfFieldMergePostProcess extends PostProcess {
  58145. private blurSteps;
  58146. /**
  58147. * Creates a new instance of DepthOfFieldMergePostProcess
  58148. * @param name The name of the effect.
  58149. * @param originalFromInput Post process which's input will be used for the merge.
  58150. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58151. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58152. * @param options The required width/height ratio to downsize to before computing the render pass.
  58153. * @param camera The camera to apply the render pass to.
  58154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58155. * @param engine The engine which the post process will be applied. (default: current engine)
  58156. * @param reusable If the post process can be reused on the same frame. (default: false)
  58157. * @param textureType Type of textures used when performing the post process. (default: 0)
  58158. * @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)
  58159. */
  58160. 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);
  58161. /**
  58162. * Updates the effect with the current post process compile time values and recompiles the shader.
  58163. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58164. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58165. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58166. * @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
  58167. * @param onCompiled Called when the shader has been compiled.
  58168. * @param onError Called if there is an error when compiling a shader.
  58169. */
  58170. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58171. }
  58172. }
  58173. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58174. import { Nullable } from "babylonjs/types";
  58175. import { Camera } from "babylonjs/Cameras/camera";
  58176. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58177. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58178. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58179. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58180. import { Scene } from "babylonjs/scene";
  58181. /**
  58182. * Specifies the level of max blur that should be applied when using the depth of field effect
  58183. */
  58184. export enum DepthOfFieldEffectBlurLevel {
  58185. /**
  58186. * Subtle blur
  58187. */
  58188. Low = 0,
  58189. /**
  58190. * Medium blur
  58191. */
  58192. Medium = 1,
  58193. /**
  58194. * Large blur
  58195. */
  58196. High = 2
  58197. }
  58198. /**
  58199. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58200. */
  58201. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58202. private _circleOfConfusion;
  58203. /**
  58204. * @hidden Internal, blurs from high to low
  58205. */
  58206. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58207. private _depthOfFieldBlurY;
  58208. private _dofMerge;
  58209. /**
  58210. * @hidden Internal post processes in depth of field effect
  58211. */
  58212. _effects: Array<PostProcess>;
  58213. /**
  58214. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58215. */
  58216. focalLength: number;
  58217. /**
  58218. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58219. */
  58220. fStop: number;
  58221. /**
  58222. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58223. */
  58224. focusDistance: number;
  58225. /**
  58226. * 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.
  58227. */
  58228. lensSize: number;
  58229. /**
  58230. * Creates a new instance DepthOfFieldEffect
  58231. * @param scene The scene the effect belongs to.
  58232. * @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.
  58233. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58234. * @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)
  58235. */
  58236. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58237. /**
  58238. * Get the current class name of the current effet
  58239. * @returns "DepthOfFieldEffect"
  58240. */
  58241. getClassName(): string;
  58242. /**
  58243. * 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.
  58244. */
  58245. depthTexture: RenderTargetTexture;
  58246. /**
  58247. * Disposes each of the internal effects for a given camera.
  58248. * @param camera The camera to dispose the effect on.
  58249. */
  58250. disposeEffects(camera: Camera): void;
  58251. /**
  58252. * @hidden Internal
  58253. */
  58254. _updateEffects(): void;
  58255. /**
  58256. * Internal
  58257. * @returns if all the contained post processes are ready.
  58258. * @hidden
  58259. */
  58260. _isReady(): boolean;
  58261. }
  58262. }
  58263. declare module "babylonjs/Shaders/displayPass.fragment" {
  58264. /** @hidden */
  58265. export var displayPassPixelShader: {
  58266. name: string;
  58267. shader: string;
  58268. };
  58269. }
  58270. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58271. import { Nullable } from "babylonjs/types";
  58272. import { Camera } from "babylonjs/Cameras/camera";
  58273. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58274. import { Engine } from "babylonjs/Engines/engine";
  58275. import "babylonjs/Shaders/displayPass.fragment";
  58276. /**
  58277. * DisplayPassPostProcess which produces an output the same as it's input
  58278. */
  58279. export class DisplayPassPostProcess extends PostProcess {
  58280. /**
  58281. * Creates the DisplayPassPostProcess
  58282. * @param name The name of the effect.
  58283. * @param options The required width/height ratio to downsize to before computing the render pass.
  58284. * @param camera The camera to apply the render pass to.
  58285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58286. * @param engine The engine which the post process will be applied. (default: current engine)
  58287. * @param reusable If the post process can be reused on the same frame. (default: false)
  58288. */
  58289. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58290. }
  58291. }
  58292. declare module "babylonjs/Shaders/filter.fragment" {
  58293. /** @hidden */
  58294. export var filterPixelShader: {
  58295. name: string;
  58296. shader: string;
  58297. };
  58298. }
  58299. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58300. import { Nullable } from "babylonjs/types";
  58301. import { Matrix } from "babylonjs/Maths/math";
  58302. import { Camera } from "babylonjs/Cameras/camera";
  58303. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58304. import { Engine } from "babylonjs/Engines/engine";
  58305. import "babylonjs/Shaders/filter.fragment";
  58306. /**
  58307. * Applies a kernel filter to the image
  58308. */
  58309. export class FilterPostProcess extends PostProcess {
  58310. /** The matrix to be applied to the image */
  58311. kernelMatrix: Matrix;
  58312. /**
  58313. *
  58314. * @param name The name of the effect.
  58315. * @param kernelMatrix The matrix to be applied to the image
  58316. * @param options The required width/height ratio to downsize to before computing the render pass.
  58317. * @param camera The camera to apply the render pass to.
  58318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58319. * @param engine The engine which the post process will be applied. (default: current engine)
  58320. * @param reusable If the post process can be reused on the same frame. (default: false)
  58321. */
  58322. constructor(name: string,
  58323. /** The matrix to be applied to the image */
  58324. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58325. }
  58326. }
  58327. declare module "babylonjs/Shaders/fxaa.fragment" {
  58328. /** @hidden */
  58329. export var fxaaPixelShader: {
  58330. name: string;
  58331. shader: string;
  58332. };
  58333. }
  58334. declare module "babylonjs/Shaders/fxaa.vertex" {
  58335. /** @hidden */
  58336. export var fxaaVertexShader: {
  58337. name: string;
  58338. shader: string;
  58339. };
  58340. }
  58341. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58342. import { Nullable } from "babylonjs/types";
  58343. import { Camera } from "babylonjs/Cameras/camera";
  58344. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58345. import { Engine } from "babylonjs/Engines/engine";
  58346. import "babylonjs/Shaders/fxaa.fragment";
  58347. import "babylonjs/Shaders/fxaa.vertex";
  58348. /**
  58349. * Fxaa post process
  58350. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58351. */
  58352. export class FxaaPostProcess extends PostProcess {
  58353. /** @hidden */
  58354. texelWidth: number;
  58355. /** @hidden */
  58356. texelHeight: number;
  58357. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58358. private _getDefines;
  58359. }
  58360. }
  58361. declare module "babylonjs/Shaders/grain.fragment" {
  58362. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58363. /** @hidden */
  58364. export var grainPixelShader: {
  58365. name: string;
  58366. shader: string;
  58367. };
  58368. }
  58369. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58370. import { Nullable } from "babylonjs/types";
  58371. import { Camera } from "babylonjs/Cameras/camera";
  58372. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58373. import { Engine } from "babylonjs/Engines/engine";
  58374. import "babylonjs/Shaders/grain.fragment";
  58375. /**
  58376. * The GrainPostProcess adds noise to the image at mid luminance levels
  58377. */
  58378. export class GrainPostProcess extends PostProcess {
  58379. /**
  58380. * The intensity of the grain added (default: 30)
  58381. */
  58382. intensity: number;
  58383. /**
  58384. * If the grain should be randomized on every frame
  58385. */
  58386. animated: boolean;
  58387. /**
  58388. * Creates a new instance of @see GrainPostProcess
  58389. * @param name The name of the effect.
  58390. * @param options The required width/height ratio to downsize to before computing the render pass.
  58391. * @param camera The camera to apply the render pass to.
  58392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58393. * @param engine The engine which the post process will be applied. (default: current engine)
  58394. * @param reusable If the post process can be reused on the same frame. (default: false)
  58395. * @param textureType Type of textures used when performing the post process. (default: 0)
  58396. * @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)
  58397. */
  58398. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58399. }
  58400. }
  58401. declare module "babylonjs/Shaders/highlights.fragment" {
  58402. /** @hidden */
  58403. export var highlightsPixelShader: {
  58404. name: string;
  58405. shader: string;
  58406. };
  58407. }
  58408. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58409. import { Nullable } from "babylonjs/types";
  58410. import { Camera } from "babylonjs/Cameras/camera";
  58411. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58412. import { Engine } from "babylonjs/Engines/engine";
  58413. import "babylonjs/Shaders/highlights.fragment";
  58414. /**
  58415. * Extracts highlights from the image
  58416. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58417. */
  58418. export class HighlightsPostProcess extends PostProcess {
  58419. /**
  58420. * Extracts highlights from the image
  58421. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58422. * @param name The name of the effect.
  58423. * @param options The required width/height ratio to downsize to before computing the render pass.
  58424. * @param camera The camera to apply the render pass to.
  58425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58426. * @param engine The engine which the post process will be applied. (default: current engine)
  58427. * @param reusable If the post process can be reused on the same frame. (default: false)
  58428. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58429. */
  58430. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58431. }
  58432. }
  58433. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58434. /** @hidden */
  58435. export var mrtFragmentDeclaration: {
  58436. name: string;
  58437. shader: string;
  58438. };
  58439. }
  58440. declare module "babylonjs/Shaders/geometry.fragment" {
  58441. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58442. /** @hidden */
  58443. export var geometryPixelShader: {
  58444. name: string;
  58445. shader: string;
  58446. };
  58447. }
  58448. declare module "babylonjs/Shaders/geometry.vertex" {
  58449. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58450. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58451. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58452. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58453. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58454. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58455. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58456. /** @hidden */
  58457. export var geometryVertexShader: {
  58458. name: string;
  58459. shader: string;
  58460. };
  58461. }
  58462. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58463. import { Matrix } from "babylonjs/Maths/math";
  58464. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58465. import { Mesh } from "babylonjs/Meshes/mesh";
  58466. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58467. import { Effect } from "babylonjs/Materials/effect";
  58468. import { Scene } from "babylonjs/scene";
  58469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58470. import "babylonjs/Shaders/geometry.fragment";
  58471. import "babylonjs/Shaders/geometry.vertex";
  58472. /** @hidden */
  58473. interface ISavedTransformationMatrix {
  58474. world: Matrix;
  58475. viewProjection: Matrix;
  58476. }
  58477. /**
  58478. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58479. */
  58480. export class GeometryBufferRenderer {
  58481. /**
  58482. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58483. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58484. */
  58485. static readonly POSITION_TEXTURE_TYPE: number;
  58486. /**
  58487. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58488. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58489. */
  58490. static readonly VELOCITY_TEXTURE_TYPE: number;
  58491. /**
  58492. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58493. * in order to compute objects velocities when enableVelocity is set to "true"
  58494. * @hidden
  58495. */
  58496. _previousTransformationMatrices: {
  58497. [index: number]: ISavedTransformationMatrix;
  58498. };
  58499. /**
  58500. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58501. * in order to compute objects velocities when enableVelocity is set to "true"
  58502. * @hidden
  58503. */
  58504. _previousBonesTransformationMatrices: {
  58505. [index: number]: Float32Array;
  58506. };
  58507. /**
  58508. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58509. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58510. */
  58511. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58512. private _scene;
  58513. private _multiRenderTarget;
  58514. private _ratio;
  58515. private _enablePosition;
  58516. private _enableVelocity;
  58517. private _positionIndex;
  58518. private _velocityIndex;
  58519. protected _effect: Effect;
  58520. protected _cachedDefines: string;
  58521. /**
  58522. * Set the render list (meshes to be rendered) used in the G buffer.
  58523. */
  58524. renderList: Mesh[];
  58525. /**
  58526. * Gets wether or not G buffer are supported by the running hardware.
  58527. * This requires draw buffer supports
  58528. */
  58529. readonly isSupported: boolean;
  58530. /**
  58531. * Returns the index of the given texture type in the G-Buffer textures array
  58532. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58533. * @returns the index of the given texture type in the G-Buffer textures array
  58534. */
  58535. getTextureIndex(textureType: number): number;
  58536. /**
  58537. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58538. */
  58539. /**
  58540. * Sets whether or not objects positions are enabled for the G buffer.
  58541. */
  58542. enablePosition: boolean;
  58543. /**
  58544. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58545. */
  58546. /**
  58547. * Sets wether or not objects velocities are enabled for the G buffer.
  58548. */
  58549. enableVelocity: boolean;
  58550. /**
  58551. * Gets the scene associated with the buffer.
  58552. */
  58553. readonly scene: Scene;
  58554. /**
  58555. * Gets the ratio used by the buffer during its creation.
  58556. * How big is the buffer related to the main canvas.
  58557. */
  58558. readonly ratio: number;
  58559. /** @hidden */
  58560. static _SceneComponentInitialization: (scene: Scene) => void;
  58561. /**
  58562. * Creates a new G Buffer for the scene
  58563. * @param scene The scene the buffer belongs to
  58564. * @param ratio How big is the buffer related to the main canvas.
  58565. */
  58566. constructor(scene: Scene, ratio?: number);
  58567. /**
  58568. * Checks wether everything is ready to render a submesh to the G buffer.
  58569. * @param subMesh the submesh to check readiness for
  58570. * @param useInstances is the mesh drawn using instance or not
  58571. * @returns true if ready otherwise false
  58572. */
  58573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58574. /**
  58575. * Gets the current underlying G Buffer.
  58576. * @returns the buffer
  58577. */
  58578. getGBuffer(): MultiRenderTarget;
  58579. /**
  58580. * Gets the number of samples used to render the buffer (anti aliasing).
  58581. */
  58582. /**
  58583. * Sets the number of samples used to render the buffer (anti aliasing).
  58584. */
  58585. samples: number;
  58586. /**
  58587. * Disposes the renderer and frees up associated resources.
  58588. */
  58589. dispose(): void;
  58590. protected _createRenderTargets(): void;
  58591. private _copyBonesTransformationMatrices;
  58592. }
  58593. }
  58594. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58595. import { Nullable } from "babylonjs/types";
  58596. import { Scene } from "babylonjs/scene";
  58597. import { ISceneComponent } from "babylonjs/sceneComponent";
  58598. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58599. module "babylonjs/scene" {
  58600. interface Scene {
  58601. /** @hidden (Backing field) */
  58602. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58603. /**
  58604. * Gets or Sets the current geometry buffer associated to the scene.
  58605. */
  58606. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58607. /**
  58608. * Enables a GeometryBufferRender and associates it with the scene
  58609. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58610. * @returns the GeometryBufferRenderer
  58611. */
  58612. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58613. /**
  58614. * Disables the GeometryBufferRender associated with the scene
  58615. */
  58616. disableGeometryBufferRenderer(): void;
  58617. }
  58618. }
  58619. /**
  58620. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58621. * in several rendering techniques.
  58622. */
  58623. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58624. /**
  58625. * The component name helpful to identify the component in the list of scene components.
  58626. */
  58627. readonly name: string;
  58628. /**
  58629. * The scene the component belongs to.
  58630. */
  58631. scene: Scene;
  58632. /**
  58633. * Creates a new instance of the component for the given scene
  58634. * @param scene Defines the scene to register the component in
  58635. */
  58636. constructor(scene: Scene);
  58637. /**
  58638. * Registers the component in a given scene
  58639. */
  58640. register(): void;
  58641. /**
  58642. * Rebuilds the elements related to this component in case of
  58643. * context lost for instance.
  58644. */
  58645. rebuild(): void;
  58646. /**
  58647. * Disposes the component and the associated ressources
  58648. */
  58649. dispose(): void;
  58650. private _gatherRenderTargets;
  58651. }
  58652. }
  58653. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58654. /** @hidden */
  58655. export var motionBlurPixelShader: {
  58656. name: string;
  58657. shader: string;
  58658. };
  58659. }
  58660. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58661. import { Nullable } from "babylonjs/types";
  58662. import { Camera } from "babylonjs/Cameras/camera";
  58663. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58664. import { Scene } from "babylonjs/scene";
  58665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58666. import "babylonjs/Animations/animatable";
  58667. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58668. import "babylonjs/Shaders/motionBlur.fragment";
  58669. import { Engine } from "babylonjs/Engines/engine";
  58670. /**
  58671. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58672. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58673. * As an example, all you have to do is to create the post-process:
  58674. * var mb = new BABYLON.MotionBlurPostProcess(
  58675. * 'mb', // The name of the effect.
  58676. * scene, // The scene containing the objects to blur according to their velocity.
  58677. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58678. * camera // The camera to apply the render pass to.
  58679. * );
  58680. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58681. */
  58682. export class MotionBlurPostProcess extends PostProcess {
  58683. /**
  58684. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58685. */
  58686. motionStrength: number;
  58687. /**
  58688. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58689. */
  58690. /**
  58691. * Sets the number of iterations to be used for motion blur quality
  58692. */
  58693. motionBlurSamples: number;
  58694. private _motionBlurSamples;
  58695. private _geometryBufferRenderer;
  58696. /**
  58697. * Creates a new instance MotionBlurPostProcess
  58698. * @param name The name of the effect.
  58699. * @param scene The scene containing the objects to blur according to their velocity.
  58700. * @param options The required width/height ratio to downsize to before computing the render pass.
  58701. * @param camera The camera to apply the render pass to.
  58702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58703. * @param engine The engine which the post process will be applied. (default: current engine)
  58704. * @param reusable If the post process can be reused on the same frame. (default: false)
  58705. * @param textureType Type of textures used when performing the post process. (default: 0)
  58706. * @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)
  58707. */
  58708. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58709. /**
  58710. * Excludes the given skinned mesh from computing bones velocities.
  58711. * 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.
  58712. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58713. */
  58714. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58715. /**
  58716. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58717. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58718. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58719. */
  58720. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58721. /**
  58722. * Disposes the post process.
  58723. * @param camera The camera to dispose the post process on.
  58724. */
  58725. dispose(camera?: Camera): void;
  58726. }
  58727. }
  58728. declare module "babylonjs/Shaders/refraction.fragment" {
  58729. /** @hidden */
  58730. export var refractionPixelShader: {
  58731. name: string;
  58732. shader: string;
  58733. };
  58734. }
  58735. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58736. import { Color3 } from "babylonjs/Maths/math";
  58737. import { Camera } from "babylonjs/Cameras/camera";
  58738. import { Texture } from "babylonjs/Materials/Textures/texture";
  58739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58740. import { Engine } from "babylonjs/Engines/engine";
  58741. import "babylonjs/Shaders/refraction.fragment";
  58742. /**
  58743. * Post process which applies a refractin texture
  58744. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58745. */
  58746. export class RefractionPostProcess extends PostProcess {
  58747. /** the base color of the refraction (used to taint the rendering) */
  58748. color: Color3;
  58749. /** simulated refraction depth */
  58750. depth: number;
  58751. /** the coefficient of the base color (0 to remove base color tainting) */
  58752. colorLevel: number;
  58753. private _refTexture;
  58754. private _ownRefractionTexture;
  58755. /**
  58756. * Gets or sets the refraction texture
  58757. * Please note that you are responsible for disposing the texture if you set it manually
  58758. */
  58759. refractionTexture: Texture;
  58760. /**
  58761. * Initializes the RefractionPostProcess
  58762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58763. * @param name The name of the effect.
  58764. * @param refractionTextureUrl Url of the refraction texture to use
  58765. * @param color the base color of the refraction (used to taint the rendering)
  58766. * @param depth simulated refraction depth
  58767. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58768. * @param camera The camera to apply the render pass to.
  58769. * @param options The required width/height ratio to downsize to before computing the render pass.
  58770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58771. * @param engine The engine which the post process will be applied. (default: current engine)
  58772. * @param reusable If the post process can be reused on the same frame. (default: false)
  58773. */
  58774. constructor(name: string, refractionTextureUrl: string,
  58775. /** the base color of the refraction (used to taint the rendering) */
  58776. color: Color3,
  58777. /** simulated refraction depth */
  58778. depth: number,
  58779. /** the coefficient of the base color (0 to remove base color tainting) */
  58780. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58781. /**
  58782. * Disposes of the post process
  58783. * @param camera Camera to dispose post process on
  58784. */
  58785. dispose(camera: Camera): void;
  58786. }
  58787. }
  58788. declare module "babylonjs/Shaders/sharpen.fragment" {
  58789. /** @hidden */
  58790. export var sharpenPixelShader: {
  58791. name: string;
  58792. shader: string;
  58793. };
  58794. }
  58795. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58796. import { Nullable } from "babylonjs/types";
  58797. import { Camera } from "babylonjs/Cameras/camera";
  58798. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58799. import "babylonjs/Shaders/sharpen.fragment";
  58800. import { Engine } from "babylonjs/Engines/engine";
  58801. /**
  58802. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58803. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58804. */
  58805. export class SharpenPostProcess extends PostProcess {
  58806. /**
  58807. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58808. */
  58809. colorAmount: number;
  58810. /**
  58811. * How much sharpness should be applied (default: 0.3)
  58812. */
  58813. edgeAmount: number;
  58814. /**
  58815. * Creates a new instance ConvolutionPostProcess
  58816. * @param name The name of the effect.
  58817. * @param options The required width/height ratio to downsize to before computing the render pass.
  58818. * @param camera The camera to apply the render pass to.
  58819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58820. * @param engine The engine which the post process will be applied. (default: current engine)
  58821. * @param reusable If the post process can be reused on the same frame. (default: false)
  58822. * @param textureType Type of textures used when performing the post process. (default: 0)
  58823. * @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)
  58824. */
  58825. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58826. }
  58827. }
  58828. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58829. import { Nullable } from "babylonjs/types";
  58830. import { Camera } from "babylonjs/Cameras/camera";
  58831. import { Engine } from "babylonjs/Engines/engine";
  58832. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58833. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58834. /**
  58835. * PostProcessRenderPipeline
  58836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58837. */
  58838. export class PostProcessRenderPipeline {
  58839. private engine;
  58840. private _renderEffects;
  58841. private _renderEffectsForIsolatedPass;
  58842. /**
  58843. * List of inspectable custom properties (used by the Inspector)
  58844. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58845. */
  58846. inspectableCustomProperties: IInspectable[];
  58847. /**
  58848. * @hidden
  58849. */
  58850. protected _cameras: Camera[];
  58851. /** @hidden */
  58852. _name: string;
  58853. /**
  58854. * Gets pipeline name
  58855. */
  58856. readonly name: string;
  58857. /**
  58858. * Initializes a PostProcessRenderPipeline
  58859. * @param engine engine to add the pipeline to
  58860. * @param name name of the pipeline
  58861. */
  58862. constructor(engine: Engine, name: string);
  58863. /**
  58864. * Gets the class name
  58865. * @returns "PostProcessRenderPipeline"
  58866. */
  58867. getClassName(): string;
  58868. /**
  58869. * If all the render effects in the pipeline are supported
  58870. */
  58871. readonly isSupported: boolean;
  58872. /**
  58873. * Adds an effect to the pipeline
  58874. * @param renderEffect the effect to add
  58875. */
  58876. addEffect(renderEffect: PostProcessRenderEffect): void;
  58877. /** @hidden */
  58878. _rebuild(): void;
  58879. /** @hidden */
  58880. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58881. /** @hidden */
  58882. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58883. /** @hidden */
  58884. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58885. /** @hidden */
  58886. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58887. /** @hidden */
  58888. _attachCameras(cameras: Camera, unique: boolean): void;
  58889. /** @hidden */
  58890. _attachCameras(cameras: Camera[], unique: boolean): void;
  58891. /** @hidden */
  58892. _detachCameras(cameras: Camera): void;
  58893. /** @hidden */
  58894. _detachCameras(cameras: Nullable<Camera[]>): void;
  58895. /** @hidden */
  58896. _update(): void;
  58897. /** @hidden */
  58898. _reset(): void;
  58899. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58900. /**
  58901. * Disposes of the pipeline
  58902. */
  58903. dispose(): void;
  58904. }
  58905. }
  58906. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58907. import { Camera } from "babylonjs/Cameras/camera";
  58908. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58909. /**
  58910. * PostProcessRenderPipelineManager class
  58911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58912. */
  58913. export class PostProcessRenderPipelineManager {
  58914. private _renderPipelines;
  58915. /**
  58916. * Initializes a PostProcessRenderPipelineManager
  58917. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58918. */
  58919. constructor();
  58920. /**
  58921. * Gets the list of supported render pipelines
  58922. */
  58923. readonly supportedPipelines: PostProcessRenderPipeline[];
  58924. /**
  58925. * Adds a pipeline to the manager
  58926. * @param renderPipeline The pipeline to add
  58927. */
  58928. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58929. /**
  58930. * Attaches a camera to the pipeline
  58931. * @param renderPipelineName The name of the pipeline to attach to
  58932. * @param cameras the camera to attach
  58933. * @param unique if the camera can be attached multiple times to the pipeline
  58934. */
  58935. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58936. /**
  58937. * Detaches a camera from the pipeline
  58938. * @param renderPipelineName The name of the pipeline to detach from
  58939. * @param cameras the camera to detach
  58940. */
  58941. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58942. /**
  58943. * Enables an effect by name on a pipeline
  58944. * @param renderPipelineName the name of the pipeline to enable the effect in
  58945. * @param renderEffectName the name of the effect to enable
  58946. * @param cameras the cameras that the effect should be enabled on
  58947. */
  58948. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58949. /**
  58950. * Disables an effect by name on a pipeline
  58951. * @param renderPipelineName the name of the pipeline to disable the effect in
  58952. * @param renderEffectName the name of the effect to disable
  58953. * @param cameras the cameras that the effect should be disabled on
  58954. */
  58955. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58956. /**
  58957. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58958. */
  58959. update(): void;
  58960. /** @hidden */
  58961. _rebuild(): void;
  58962. /**
  58963. * Disposes of the manager and pipelines
  58964. */
  58965. dispose(): void;
  58966. }
  58967. }
  58968. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58969. import { ISceneComponent } from "babylonjs/sceneComponent";
  58970. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58971. import { Scene } from "babylonjs/scene";
  58972. module "babylonjs/scene" {
  58973. interface Scene {
  58974. /** @hidden (Backing field) */
  58975. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58976. /**
  58977. * Gets the postprocess render pipeline manager
  58978. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58979. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58980. */
  58981. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58982. }
  58983. }
  58984. /**
  58985. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58986. */
  58987. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58988. /**
  58989. * The component name helpfull to identify the component in the list of scene components.
  58990. */
  58991. readonly name: string;
  58992. /**
  58993. * The scene the component belongs to.
  58994. */
  58995. scene: Scene;
  58996. /**
  58997. * Creates a new instance of the component for the given scene
  58998. * @param scene Defines the scene to register the component in
  58999. */
  59000. constructor(scene: Scene);
  59001. /**
  59002. * Registers the component in a given scene
  59003. */
  59004. register(): void;
  59005. /**
  59006. * Rebuilds the elements related to this component in case of
  59007. * context lost for instance.
  59008. */
  59009. rebuild(): void;
  59010. /**
  59011. * Disposes the component and the associated ressources
  59012. */
  59013. dispose(): void;
  59014. private _gatherRenderTargets;
  59015. }
  59016. }
  59017. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59018. import { Nullable } from "babylonjs/types";
  59019. import { IAnimatable } from "babylonjs/Misc/tools";
  59020. import { Camera } from "babylonjs/Cameras/camera";
  59021. import { IDisposable } from "babylonjs/scene";
  59022. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59023. import { Scene } from "babylonjs/scene";
  59024. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59025. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59026. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59027. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59028. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59029. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59030. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59031. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59032. import { Animation } from "babylonjs/Animations/animation";
  59033. /**
  59034. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59035. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59036. */
  59037. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59038. private _scene;
  59039. private _camerasToBeAttached;
  59040. /**
  59041. * ID of the sharpen post process,
  59042. */
  59043. private readonly SharpenPostProcessId;
  59044. /**
  59045. * @ignore
  59046. * ID of the image processing post process;
  59047. */
  59048. readonly ImageProcessingPostProcessId: string;
  59049. /**
  59050. * @ignore
  59051. * ID of the Fast Approximate Anti-Aliasing post process;
  59052. */
  59053. readonly FxaaPostProcessId: string;
  59054. /**
  59055. * ID of the chromatic aberration post process,
  59056. */
  59057. private readonly ChromaticAberrationPostProcessId;
  59058. /**
  59059. * ID of the grain post process
  59060. */
  59061. private readonly GrainPostProcessId;
  59062. /**
  59063. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59064. */
  59065. sharpen: SharpenPostProcess;
  59066. private _sharpenEffect;
  59067. private bloom;
  59068. /**
  59069. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59070. */
  59071. depthOfField: DepthOfFieldEffect;
  59072. /**
  59073. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59074. */
  59075. fxaa: FxaaPostProcess;
  59076. /**
  59077. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59078. */
  59079. imageProcessing: ImageProcessingPostProcess;
  59080. /**
  59081. * Chromatic aberration post process which will shift rgb colors in the image
  59082. */
  59083. chromaticAberration: ChromaticAberrationPostProcess;
  59084. private _chromaticAberrationEffect;
  59085. /**
  59086. * Grain post process which add noise to the image
  59087. */
  59088. grain: GrainPostProcess;
  59089. private _grainEffect;
  59090. /**
  59091. * Glow post process which adds a glow to emissive areas of the image
  59092. */
  59093. private _glowLayer;
  59094. /**
  59095. * Animations which can be used to tweak settings over a period of time
  59096. */
  59097. animations: Animation[];
  59098. private _imageProcessingConfigurationObserver;
  59099. private _sharpenEnabled;
  59100. private _bloomEnabled;
  59101. private _depthOfFieldEnabled;
  59102. private _depthOfFieldBlurLevel;
  59103. private _fxaaEnabled;
  59104. private _imageProcessingEnabled;
  59105. private _defaultPipelineTextureType;
  59106. private _bloomScale;
  59107. private _chromaticAberrationEnabled;
  59108. private _grainEnabled;
  59109. private _buildAllowed;
  59110. /**
  59111. * Gets active scene
  59112. */
  59113. readonly scene: Scene;
  59114. /**
  59115. * Enable or disable the sharpen process from the pipeline
  59116. */
  59117. sharpenEnabled: boolean;
  59118. private _resizeObserver;
  59119. private _hardwareScaleLevel;
  59120. private _bloomKernel;
  59121. /**
  59122. * Specifies the size of the bloom blur kernel, relative to the final output size
  59123. */
  59124. bloomKernel: number;
  59125. /**
  59126. * Specifies the weight of the bloom in the final rendering
  59127. */
  59128. private _bloomWeight;
  59129. /**
  59130. * Specifies the luma threshold for the area that will be blurred by the bloom
  59131. */
  59132. private _bloomThreshold;
  59133. private _hdr;
  59134. /**
  59135. * The strength of the bloom.
  59136. */
  59137. bloomWeight: number;
  59138. /**
  59139. * The strength of the bloom.
  59140. */
  59141. bloomThreshold: number;
  59142. /**
  59143. * The scale of the bloom, lower value will provide better performance.
  59144. */
  59145. bloomScale: number;
  59146. /**
  59147. * Enable or disable the bloom from the pipeline
  59148. */
  59149. bloomEnabled: boolean;
  59150. private _rebuildBloom;
  59151. /**
  59152. * If the depth of field is enabled.
  59153. */
  59154. depthOfFieldEnabled: boolean;
  59155. /**
  59156. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59157. */
  59158. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59159. /**
  59160. * If the anti aliasing is enabled.
  59161. */
  59162. fxaaEnabled: boolean;
  59163. private _samples;
  59164. /**
  59165. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59166. */
  59167. samples: number;
  59168. /**
  59169. * If image processing is enabled.
  59170. */
  59171. imageProcessingEnabled: boolean;
  59172. /**
  59173. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59174. */
  59175. glowLayerEnabled: boolean;
  59176. /**
  59177. * Gets the glow layer (or null if not defined)
  59178. */
  59179. readonly glowLayer: Nullable<GlowLayer>;
  59180. /**
  59181. * Enable or disable the chromaticAberration process from the pipeline
  59182. */
  59183. chromaticAberrationEnabled: boolean;
  59184. /**
  59185. * Enable or disable the grain process from the pipeline
  59186. */
  59187. grainEnabled: boolean;
  59188. /**
  59189. * @constructor
  59190. * @param name - The rendering pipeline name (default: "")
  59191. * @param hdr - If high dynamic range textures should be used (default: true)
  59192. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59193. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59194. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59195. */
  59196. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59197. /**
  59198. * Get the class name
  59199. * @returns "DefaultRenderingPipeline"
  59200. */
  59201. getClassName(): string;
  59202. /**
  59203. * Force the compilation of the entire pipeline.
  59204. */
  59205. prepare(): void;
  59206. private _hasCleared;
  59207. private _prevPostProcess;
  59208. private _prevPrevPostProcess;
  59209. private _setAutoClearAndTextureSharing;
  59210. private _depthOfFieldSceneObserver;
  59211. private _buildPipeline;
  59212. private _disposePostProcesses;
  59213. /**
  59214. * Adds a camera to the pipeline
  59215. * @param camera the camera to be added
  59216. */
  59217. addCamera(camera: Camera): void;
  59218. /**
  59219. * Removes a camera from the pipeline
  59220. * @param camera the camera to remove
  59221. */
  59222. removeCamera(camera: Camera): void;
  59223. /**
  59224. * Dispose of the pipeline and stop all post processes
  59225. */
  59226. dispose(): void;
  59227. /**
  59228. * Serialize the rendering pipeline (Used when exporting)
  59229. * @returns the serialized object
  59230. */
  59231. serialize(): any;
  59232. /**
  59233. * Parse the serialized pipeline
  59234. * @param source Source pipeline.
  59235. * @param scene The scene to load the pipeline to.
  59236. * @param rootUrl The URL of the serialized pipeline.
  59237. * @returns An instantiated pipeline from the serialized object.
  59238. */
  59239. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59240. }
  59241. }
  59242. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59243. /** @hidden */
  59244. export var lensHighlightsPixelShader: {
  59245. name: string;
  59246. shader: string;
  59247. };
  59248. }
  59249. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59250. /** @hidden */
  59251. export var depthOfFieldPixelShader: {
  59252. name: string;
  59253. shader: string;
  59254. };
  59255. }
  59256. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59257. import { Camera } from "babylonjs/Cameras/camera";
  59258. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59259. import { Scene } from "babylonjs/scene";
  59260. import "babylonjs/Shaders/chromaticAberration.fragment";
  59261. import "babylonjs/Shaders/lensHighlights.fragment";
  59262. import "babylonjs/Shaders/depthOfField.fragment";
  59263. /**
  59264. * BABYLON.JS Chromatic Aberration GLSL Shader
  59265. * Author: Olivier Guyot
  59266. * Separates very slightly R, G and B colors on the edges of the screen
  59267. * Inspired by Francois Tarlier & Martins Upitis
  59268. */
  59269. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59270. /**
  59271. * @ignore
  59272. * The chromatic aberration PostProcess id in the pipeline
  59273. */
  59274. LensChromaticAberrationEffect: string;
  59275. /**
  59276. * @ignore
  59277. * The highlights enhancing PostProcess id in the pipeline
  59278. */
  59279. HighlightsEnhancingEffect: string;
  59280. /**
  59281. * @ignore
  59282. * The depth-of-field PostProcess id in the pipeline
  59283. */
  59284. LensDepthOfFieldEffect: string;
  59285. private _scene;
  59286. private _depthTexture;
  59287. private _grainTexture;
  59288. private _chromaticAberrationPostProcess;
  59289. private _highlightsPostProcess;
  59290. private _depthOfFieldPostProcess;
  59291. private _edgeBlur;
  59292. private _grainAmount;
  59293. private _chromaticAberration;
  59294. private _distortion;
  59295. private _highlightsGain;
  59296. private _highlightsThreshold;
  59297. private _dofDistance;
  59298. private _dofAperture;
  59299. private _dofDarken;
  59300. private _dofPentagon;
  59301. private _blurNoise;
  59302. /**
  59303. * @constructor
  59304. *
  59305. * Effect parameters are as follow:
  59306. * {
  59307. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59308. * edge_blur: number; // from 0 to x (1 for realism)
  59309. * distortion: number; // from 0 to x (1 for realism)
  59310. * grain_amount: number; // from 0 to 1
  59311. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59312. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59313. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59314. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59315. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59316. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59317. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59318. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59319. * }
  59320. * Note: if an effect parameter is unset, effect is disabled
  59321. *
  59322. * @param name The rendering pipeline name
  59323. * @param parameters - An object containing all parameters (see above)
  59324. * @param scene The scene linked to this pipeline
  59325. * @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)
  59326. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59327. */
  59328. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59329. /**
  59330. * Get the class name
  59331. * @returns "LensRenderingPipeline"
  59332. */
  59333. getClassName(): string;
  59334. /**
  59335. * Gets associated scene
  59336. */
  59337. readonly scene: Scene;
  59338. /**
  59339. * Gets or sets the edge blur
  59340. */
  59341. edgeBlur: number;
  59342. /**
  59343. * Gets or sets the grain amount
  59344. */
  59345. grainAmount: number;
  59346. /**
  59347. * Gets or sets the chromatic aberration amount
  59348. */
  59349. chromaticAberration: number;
  59350. /**
  59351. * Gets or sets the depth of field aperture
  59352. */
  59353. dofAperture: number;
  59354. /**
  59355. * Gets or sets the edge distortion
  59356. */
  59357. edgeDistortion: number;
  59358. /**
  59359. * Gets or sets the depth of field distortion
  59360. */
  59361. dofDistortion: number;
  59362. /**
  59363. * Gets or sets the darken out of focus amount
  59364. */
  59365. darkenOutOfFocus: number;
  59366. /**
  59367. * Gets or sets a boolean indicating if blur noise is enabled
  59368. */
  59369. blurNoise: boolean;
  59370. /**
  59371. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59372. */
  59373. pentagonBokeh: boolean;
  59374. /**
  59375. * Gets or sets the highlight grain amount
  59376. */
  59377. highlightsGain: number;
  59378. /**
  59379. * Gets or sets the highlight threshold
  59380. */
  59381. highlightsThreshold: number;
  59382. /**
  59383. * Sets the amount of blur at the edges
  59384. * @param amount blur amount
  59385. */
  59386. setEdgeBlur(amount: number): void;
  59387. /**
  59388. * Sets edge blur to 0
  59389. */
  59390. disableEdgeBlur(): void;
  59391. /**
  59392. * Sets the amout of grain
  59393. * @param amount Amount of grain
  59394. */
  59395. setGrainAmount(amount: number): void;
  59396. /**
  59397. * Set grain amount to 0
  59398. */
  59399. disableGrain(): void;
  59400. /**
  59401. * Sets the chromatic aberration amount
  59402. * @param amount amount of chromatic aberration
  59403. */
  59404. setChromaticAberration(amount: number): void;
  59405. /**
  59406. * Sets chromatic aberration amount to 0
  59407. */
  59408. disableChromaticAberration(): void;
  59409. /**
  59410. * Sets the EdgeDistortion amount
  59411. * @param amount amount of EdgeDistortion
  59412. */
  59413. setEdgeDistortion(amount: number): void;
  59414. /**
  59415. * Sets edge distortion to 0
  59416. */
  59417. disableEdgeDistortion(): void;
  59418. /**
  59419. * Sets the FocusDistance amount
  59420. * @param amount amount of FocusDistance
  59421. */
  59422. setFocusDistance(amount: number): void;
  59423. /**
  59424. * Disables depth of field
  59425. */
  59426. disableDepthOfField(): void;
  59427. /**
  59428. * Sets the Aperture amount
  59429. * @param amount amount of Aperture
  59430. */
  59431. setAperture(amount: number): void;
  59432. /**
  59433. * Sets the DarkenOutOfFocus amount
  59434. * @param amount amount of DarkenOutOfFocus
  59435. */
  59436. setDarkenOutOfFocus(amount: number): void;
  59437. private _pentagonBokehIsEnabled;
  59438. /**
  59439. * Creates a pentagon bokeh effect
  59440. */
  59441. enablePentagonBokeh(): void;
  59442. /**
  59443. * Disables the pentagon bokeh effect
  59444. */
  59445. disablePentagonBokeh(): void;
  59446. /**
  59447. * Enables noise blur
  59448. */
  59449. enableNoiseBlur(): void;
  59450. /**
  59451. * Disables noise blur
  59452. */
  59453. disableNoiseBlur(): void;
  59454. /**
  59455. * Sets the HighlightsGain amount
  59456. * @param amount amount of HighlightsGain
  59457. */
  59458. setHighlightsGain(amount: number): void;
  59459. /**
  59460. * Sets the HighlightsThreshold amount
  59461. * @param amount amount of HighlightsThreshold
  59462. */
  59463. setHighlightsThreshold(amount: number): void;
  59464. /**
  59465. * Disables highlights
  59466. */
  59467. disableHighlights(): void;
  59468. /**
  59469. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59470. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59471. */
  59472. dispose(disableDepthRender?: boolean): void;
  59473. private _createChromaticAberrationPostProcess;
  59474. private _createHighlightsPostProcess;
  59475. private _createDepthOfFieldPostProcess;
  59476. private _createGrainTexture;
  59477. }
  59478. }
  59479. declare module "babylonjs/Shaders/ssao2.fragment" {
  59480. /** @hidden */
  59481. export var ssao2PixelShader: {
  59482. name: string;
  59483. shader: string;
  59484. };
  59485. }
  59486. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59487. /** @hidden */
  59488. export var ssaoCombinePixelShader: {
  59489. name: string;
  59490. shader: string;
  59491. };
  59492. }
  59493. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59494. import { Camera } from "babylonjs/Cameras/camera";
  59495. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59496. import { Scene } from "babylonjs/scene";
  59497. import "babylonjs/Shaders/ssao2.fragment";
  59498. import "babylonjs/Shaders/ssaoCombine.fragment";
  59499. /**
  59500. * Render pipeline to produce ssao effect
  59501. */
  59502. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59503. /**
  59504. * @ignore
  59505. * The PassPostProcess id in the pipeline that contains the original scene color
  59506. */
  59507. SSAOOriginalSceneColorEffect: string;
  59508. /**
  59509. * @ignore
  59510. * The SSAO PostProcess id in the pipeline
  59511. */
  59512. SSAORenderEffect: string;
  59513. /**
  59514. * @ignore
  59515. * The horizontal blur PostProcess id in the pipeline
  59516. */
  59517. SSAOBlurHRenderEffect: string;
  59518. /**
  59519. * @ignore
  59520. * The vertical blur PostProcess id in the pipeline
  59521. */
  59522. SSAOBlurVRenderEffect: string;
  59523. /**
  59524. * @ignore
  59525. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59526. */
  59527. SSAOCombineRenderEffect: string;
  59528. /**
  59529. * The output strength of the SSAO post-process. Default value is 1.0.
  59530. */
  59531. totalStrength: number;
  59532. /**
  59533. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59534. */
  59535. maxZ: number;
  59536. /**
  59537. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59538. */
  59539. minZAspect: number;
  59540. private _samples;
  59541. /**
  59542. * Number of samples used for the SSAO calculations. Default value is 8
  59543. */
  59544. samples: number;
  59545. private _textureSamples;
  59546. /**
  59547. * Number of samples to use for antialiasing
  59548. */
  59549. textureSamples: number;
  59550. /**
  59551. * Ratio object used for SSAO ratio and blur ratio
  59552. */
  59553. private _ratio;
  59554. /**
  59555. * Dynamically generated sphere sampler.
  59556. */
  59557. private _sampleSphere;
  59558. /**
  59559. * Blur filter offsets
  59560. */
  59561. private _samplerOffsets;
  59562. private _expensiveBlur;
  59563. /**
  59564. * If bilateral blur should be used
  59565. */
  59566. expensiveBlur: boolean;
  59567. /**
  59568. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59569. */
  59570. radius: number;
  59571. /**
  59572. * The base color of the SSAO post-process
  59573. * The final result is "base + ssao" between [0, 1]
  59574. */
  59575. base: number;
  59576. /**
  59577. * Support test.
  59578. */
  59579. static readonly IsSupported: boolean;
  59580. private _scene;
  59581. private _depthTexture;
  59582. private _normalTexture;
  59583. private _randomTexture;
  59584. private _originalColorPostProcess;
  59585. private _ssaoPostProcess;
  59586. private _blurHPostProcess;
  59587. private _blurVPostProcess;
  59588. private _ssaoCombinePostProcess;
  59589. private _firstUpdate;
  59590. /**
  59591. * Gets active scene
  59592. */
  59593. readonly scene: Scene;
  59594. /**
  59595. * @constructor
  59596. * @param name The rendering pipeline name
  59597. * @param scene The scene linked to this pipeline
  59598. * @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 }
  59599. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59600. */
  59601. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59602. /**
  59603. * Get the class name
  59604. * @returns "SSAO2RenderingPipeline"
  59605. */
  59606. getClassName(): string;
  59607. /**
  59608. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59609. */
  59610. dispose(disableGeometryBufferRenderer?: boolean): void;
  59611. private _createBlurPostProcess;
  59612. /** @hidden */
  59613. _rebuild(): void;
  59614. private _bits;
  59615. private _radicalInverse_VdC;
  59616. private _hammersley;
  59617. private _hemisphereSample_uniform;
  59618. private _generateHemisphere;
  59619. private _createSSAOPostProcess;
  59620. private _createSSAOCombinePostProcess;
  59621. private _createRandomTexture;
  59622. /**
  59623. * Serialize the rendering pipeline (Used when exporting)
  59624. * @returns the serialized object
  59625. */
  59626. serialize(): any;
  59627. /**
  59628. * Parse the serialized pipeline
  59629. * @param source Source pipeline.
  59630. * @param scene The scene to load the pipeline to.
  59631. * @param rootUrl The URL of the serialized pipeline.
  59632. * @returns An instantiated pipeline from the serialized object.
  59633. */
  59634. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59635. }
  59636. }
  59637. declare module "babylonjs/Shaders/ssao.fragment" {
  59638. /** @hidden */
  59639. export var ssaoPixelShader: {
  59640. name: string;
  59641. shader: string;
  59642. };
  59643. }
  59644. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59645. import { Camera } from "babylonjs/Cameras/camera";
  59646. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59647. import { Scene } from "babylonjs/scene";
  59648. import "babylonjs/Shaders/ssao.fragment";
  59649. import "babylonjs/Shaders/ssaoCombine.fragment";
  59650. /**
  59651. * Render pipeline to produce ssao effect
  59652. */
  59653. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59654. /**
  59655. * @ignore
  59656. * The PassPostProcess id in the pipeline that contains the original scene color
  59657. */
  59658. SSAOOriginalSceneColorEffect: string;
  59659. /**
  59660. * @ignore
  59661. * The SSAO PostProcess id in the pipeline
  59662. */
  59663. SSAORenderEffect: string;
  59664. /**
  59665. * @ignore
  59666. * The horizontal blur PostProcess id in the pipeline
  59667. */
  59668. SSAOBlurHRenderEffect: string;
  59669. /**
  59670. * @ignore
  59671. * The vertical blur PostProcess id in the pipeline
  59672. */
  59673. SSAOBlurVRenderEffect: string;
  59674. /**
  59675. * @ignore
  59676. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59677. */
  59678. SSAOCombineRenderEffect: string;
  59679. /**
  59680. * The output strength of the SSAO post-process. Default value is 1.0.
  59681. */
  59682. totalStrength: number;
  59683. /**
  59684. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59685. */
  59686. radius: number;
  59687. /**
  59688. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59689. * Must not be equal to fallOff and superior to fallOff.
  59690. * Default value is 0.0075
  59691. */
  59692. area: number;
  59693. /**
  59694. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59695. * Must not be equal to area and inferior to area.
  59696. * Default value is 0.000001
  59697. */
  59698. fallOff: number;
  59699. /**
  59700. * The base color of the SSAO post-process
  59701. * The final result is "base + ssao" between [0, 1]
  59702. */
  59703. base: number;
  59704. private _scene;
  59705. private _depthTexture;
  59706. private _randomTexture;
  59707. private _originalColorPostProcess;
  59708. private _ssaoPostProcess;
  59709. private _blurHPostProcess;
  59710. private _blurVPostProcess;
  59711. private _ssaoCombinePostProcess;
  59712. private _firstUpdate;
  59713. /**
  59714. * Gets active scene
  59715. */
  59716. readonly scene: Scene;
  59717. /**
  59718. * @constructor
  59719. * @param name - The rendering pipeline name
  59720. * @param scene - The scene linked to this pipeline
  59721. * @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 }
  59722. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59723. */
  59724. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59725. /**
  59726. * Get the class name
  59727. * @returns "SSAORenderingPipeline"
  59728. */
  59729. getClassName(): string;
  59730. /**
  59731. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59732. */
  59733. dispose(disableDepthRender?: boolean): void;
  59734. private _createBlurPostProcess;
  59735. /** @hidden */
  59736. _rebuild(): void;
  59737. private _createSSAOPostProcess;
  59738. private _createSSAOCombinePostProcess;
  59739. private _createRandomTexture;
  59740. }
  59741. }
  59742. declare module "babylonjs/Shaders/standard.fragment" {
  59743. /** @hidden */
  59744. export var standardPixelShader: {
  59745. name: string;
  59746. shader: string;
  59747. };
  59748. }
  59749. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59750. import { Nullable } from "babylonjs/types";
  59751. import { IAnimatable } from "babylonjs/Misc/tools";
  59752. import { Camera } from "babylonjs/Cameras/camera";
  59753. import { Texture } from "babylonjs/Materials/Textures/texture";
  59754. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59755. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59756. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59757. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59758. import { IDisposable } from "babylonjs/scene";
  59759. import { SpotLight } from "babylonjs/Lights/spotLight";
  59760. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59761. import { Scene } from "babylonjs/scene";
  59762. import { Animation } from "babylonjs/Animations/animation";
  59763. import "babylonjs/Shaders/standard.fragment";
  59764. /**
  59765. * Standard rendering pipeline
  59766. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59767. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59768. */
  59769. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59770. /**
  59771. * Public members
  59772. */
  59773. /**
  59774. * Post-process which contains the original scene color before the pipeline applies all the effects
  59775. */
  59776. originalPostProcess: Nullable<PostProcess>;
  59777. /**
  59778. * Post-process used to down scale an image x4
  59779. */
  59780. downSampleX4PostProcess: Nullable<PostProcess>;
  59781. /**
  59782. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59783. */
  59784. brightPassPostProcess: Nullable<PostProcess>;
  59785. /**
  59786. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59787. */
  59788. blurHPostProcesses: PostProcess[];
  59789. /**
  59790. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59791. */
  59792. blurVPostProcesses: PostProcess[];
  59793. /**
  59794. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59795. */
  59796. textureAdderPostProcess: Nullable<PostProcess>;
  59797. /**
  59798. * Post-process used to create volumetric lighting effect
  59799. */
  59800. volumetricLightPostProcess: Nullable<PostProcess>;
  59801. /**
  59802. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59803. */
  59804. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59805. /**
  59806. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59807. */
  59808. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59809. /**
  59810. * Post-process used to merge the volumetric light effect and the real scene color
  59811. */
  59812. volumetricLightMergePostProces: Nullable<PostProcess>;
  59813. /**
  59814. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59815. */
  59816. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59817. /**
  59818. * Base post-process used to calculate the average luminance of the final image for HDR
  59819. */
  59820. luminancePostProcess: Nullable<PostProcess>;
  59821. /**
  59822. * Post-processes used to create down sample post-processes in order to get
  59823. * the average luminance of the final image for HDR
  59824. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59825. */
  59826. luminanceDownSamplePostProcesses: PostProcess[];
  59827. /**
  59828. * Post-process used to create a HDR effect (light adaptation)
  59829. */
  59830. hdrPostProcess: Nullable<PostProcess>;
  59831. /**
  59832. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59833. */
  59834. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59835. /**
  59836. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59837. */
  59838. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59839. /**
  59840. * Post-process used to merge the final HDR post-process and the real scene color
  59841. */
  59842. hdrFinalPostProcess: Nullable<PostProcess>;
  59843. /**
  59844. * Post-process used to create a lens flare effect
  59845. */
  59846. lensFlarePostProcess: Nullable<PostProcess>;
  59847. /**
  59848. * Post-process that merges the result of the lens flare post-process and the real scene color
  59849. */
  59850. lensFlareComposePostProcess: Nullable<PostProcess>;
  59851. /**
  59852. * Post-process used to create a motion blur effect
  59853. */
  59854. motionBlurPostProcess: Nullable<PostProcess>;
  59855. /**
  59856. * Post-process used to create a depth of field effect
  59857. */
  59858. depthOfFieldPostProcess: Nullable<PostProcess>;
  59859. /**
  59860. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59861. */
  59862. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59863. /**
  59864. * Represents the brightness threshold in order to configure the illuminated surfaces
  59865. */
  59866. brightThreshold: number;
  59867. /**
  59868. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59869. */
  59870. blurWidth: number;
  59871. /**
  59872. * Sets if the blur for highlighted surfaces must be only horizontal
  59873. */
  59874. horizontalBlur: boolean;
  59875. /**
  59876. * Gets the overall exposure used by the pipeline
  59877. */
  59878. /**
  59879. * Sets the overall exposure used by the pipeline
  59880. */
  59881. exposure: number;
  59882. /**
  59883. * Texture used typically to simulate "dirty" on camera lens
  59884. */
  59885. lensTexture: Nullable<Texture>;
  59886. /**
  59887. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59888. */
  59889. volumetricLightCoefficient: number;
  59890. /**
  59891. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59892. */
  59893. volumetricLightPower: number;
  59894. /**
  59895. * Used the set the blur intensity to smooth the volumetric lights
  59896. */
  59897. volumetricLightBlurScale: number;
  59898. /**
  59899. * Light (spot or directional) used to generate the volumetric lights rays
  59900. * The source light must have a shadow generate so the pipeline can get its
  59901. * depth map
  59902. */
  59903. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59904. /**
  59905. * For eye adaptation, represents the minimum luminance the eye can see
  59906. */
  59907. hdrMinimumLuminance: number;
  59908. /**
  59909. * For eye adaptation, represents the decrease luminance speed
  59910. */
  59911. hdrDecreaseRate: number;
  59912. /**
  59913. * For eye adaptation, represents the increase luminance speed
  59914. */
  59915. hdrIncreaseRate: number;
  59916. /**
  59917. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59918. */
  59919. /**
  59920. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59921. */
  59922. hdrAutoExposure: boolean;
  59923. /**
  59924. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59925. */
  59926. lensColorTexture: Nullable<Texture>;
  59927. /**
  59928. * The overall strengh for the lens flare effect
  59929. */
  59930. lensFlareStrength: number;
  59931. /**
  59932. * Dispersion coefficient for lens flare ghosts
  59933. */
  59934. lensFlareGhostDispersal: number;
  59935. /**
  59936. * Main lens flare halo width
  59937. */
  59938. lensFlareHaloWidth: number;
  59939. /**
  59940. * Based on the lens distortion effect, defines how much the lens flare result
  59941. * is distorted
  59942. */
  59943. lensFlareDistortionStrength: number;
  59944. /**
  59945. * Lens star texture must be used to simulate rays on the flares and is available
  59946. * in the documentation
  59947. */
  59948. lensStarTexture: Nullable<Texture>;
  59949. /**
  59950. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59951. * flare effect by taking account of the dirt texture
  59952. */
  59953. lensFlareDirtTexture: Nullable<Texture>;
  59954. /**
  59955. * Represents the focal length for the depth of field effect
  59956. */
  59957. depthOfFieldDistance: number;
  59958. /**
  59959. * Represents the blur intensity for the blurred part of the depth of field effect
  59960. */
  59961. depthOfFieldBlurWidth: number;
  59962. /**
  59963. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59964. */
  59965. /**
  59966. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59967. */
  59968. motionStrength: number;
  59969. /**
  59970. * Gets wether or not the motion blur post-process is object based or screen based.
  59971. */
  59972. /**
  59973. * Sets wether or not the motion blur post-process should be object based or screen based
  59974. */
  59975. objectBasedMotionBlur: boolean;
  59976. /**
  59977. * List of animations for the pipeline (IAnimatable implementation)
  59978. */
  59979. animations: Animation[];
  59980. /**
  59981. * Private members
  59982. */
  59983. private _scene;
  59984. private _currentDepthOfFieldSource;
  59985. private _basePostProcess;
  59986. private _fixedExposure;
  59987. private _currentExposure;
  59988. private _hdrAutoExposure;
  59989. private _hdrCurrentLuminance;
  59990. private _motionStrength;
  59991. private _isObjectBasedMotionBlur;
  59992. private _floatTextureType;
  59993. private _ratio;
  59994. private _bloomEnabled;
  59995. private _depthOfFieldEnabled;
  59996. private _vlsEnabled;
  59997. private _lensFlareEnabled;
  59998. private _hdrEnabled;
  59999. private _motionBlurEnabled;
  60000. private _fxaaEnabled;
  60001. private _motionBlurSamples;
  60002. private _volumetricLightStepsCount;
  60003. private _samples;
  60004. /**
  60005. * @ignore
  60006. * Specifies if the bloom pipeline is enabled
  60007. */
  60008. BloomEnabled: boolean;
  60009. /**
  60010. * @ignore
  60011. * Specifies if the depth of field pipeline is enabed
  60012. */
  60013. DepthOfFieldEnabled: boolean;
  60014. /**
  60015. * @ignore
  60016. * Specifies if the lens flare pipeline is enabed
  60017. */
  60018. LensFlareEnabled: boolean;
  60019. /**
  60020. * @ignore
  60021. * Specifies if the HDR pipeline is enabled
  60022. */
  60023. HDREnabled: boolean;
  60024. /**
  60025. * @ignore
  60026. * Specifies if the volumetric lights scattering effect is enabled
  60027. */
  60028. VLSEnabled: boolean;
  60029. /**
  60030. * @ignore
  60031. * Specifies if the motion blur effect is enabled
  60032. */
  60033. MotionBlurEnabled: boolean;
  60034. /**
  60035. * Specifies if anti-aliasing is enabled
  60036. */
  60037. fxaaEnabled: boolean;
  60038. /**
  60039. * Specifies the number of steps used to calculate the volumetric lights
  60040. * Typically in interval [50, 200]
  60041. */
  60042. volumetricLightStepsCount: number;
  60043. /**
  60044. * Specifies the number of samples used for the motion blur effect
  60045. * Typically in interval [16, 64]
  60046. */
  60047. motionBlurSamples: number;
  60048. /**
  60049. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60050. */
  60051. samples: number;
  60052. /**
  60053. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60054. * @constructor
  60055. * @param name The rendering pipeline name
  60056. * @param scene The scene linked to this pipeline
  60057. * @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)
  60058. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60059. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60060. */
  60061. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60062. private _buildPipeline;
  60063. private _createDownSampleX4PostProcess;
  60064. private _createBrightPassPostProcess;
  60065. private _createBlurPostProcesses;
  60066. private _createTextureAdderPostProcess;
  60067. private _createVolumetricLightPostProcess;
  60068. private _createLuminancePostProcesses;
  60069. private _createHdrPostProcess;
  60070. private _createLensFlarePostProcess;
  60071. private _createDepthOfFieldPostProcess;
  60072. private _createMotionBlurPostProcess;
  60073. private _getDepthTexture;
  60074. private _disposePostProcesses;
  60075. /**
  60076. * Dispose of the pipeline and stop all post processes
  60077. */
  60078. dispose(): void;
  60079. /**
  60080. * Serialize the rendering pipeline (Used when exporting)
  60081. * @returns the serialized object
  60082. */
  60083. serialize(): any;
  60084. /**
  60085. * Parse the serialized pipeline
  60086. * @param source Source pipeline.
  60087. * @param scene The scene to load the pipeline to.
  60088. * @param rootUrl The URL of the serialized pipeline.
  60089. * @returns An instantiated pipeline from the serialized object.
  60090. */
  60091. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60092. /**
  60093. * Luminance steps
  60094. */
  60095. static LuminanceSteps: number;
  60096. }
  60097. }
  60098. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60099. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60100. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60101. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60102. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60103. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60104. }
  60105. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60106. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60107. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60108. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60109. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60110. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60111. }
  60112. declare module "babylonjs/Shaders/tonemap.fragment" {
  60113. /** @hidden */
  60114. export var tonemapPixelShader: {
  60115. name: string;
  60116. shader: string;
  60117. };
  60118. }
  60119. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60120. import { Camera } from "babylonjs/Cameras/camera";
  60121. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60122. import "babylonjs/Shaders/tonemap.fragment";
  60123. import { Engine } from "babylonjs/Engines/engine";
  60124. /** Defines operator used for tonemapping */
  60125. export enum TonemappingOperator {
  60126. /** Hable */
  60127. Hable = 0,
  60128. /** Reinhard */
  60129. Reinhard = 1,
  60130. /** HejiDawson */
  60131. HejiDawson = 2,
  60132. /** Photographic */
  60133. Photographic = 3
  60134. }
  60135. /**
  60136. * Defines a post process to apply tone mapping
  60137. */
  60138. export class TonemapPostProcess extends PostProcess {
  60139. private _operator;
  60140. /** Defines the required exposure adjustement */
  60141. exposureAdjustment: number;
  60142. /**
  60143. * Creates a new TonemapPostProcess
  60144. * @param name defines the name of the postprocess
  60145. * @param _operator defines the operator to use
  60146. * @param exposureAdjustment defines the required exposure adjustement
  60147. * @param camera defines the camera to use (can be null)
  60148. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60149. * @param engine defines the hosting engine (can be ignore if camera is set)
  60150. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60151. */
  60152. constructor(name: string, _operator: TonemappingOperator,
  60153. /** Defines the required exposure adjustement */
  60154. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60155. }
  60156. }
  60157. declare module "babylonjs/Shaders/depth.vertex" {
  60158. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60159. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60160. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60161. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60162. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60163. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60164. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60165. /** @hidden */
  60166. export var depthVertexShader: {
  60167. name: string;
  60168. shader: string;
  60169. };
  60170. }
  60171. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60172. /** @hidden */
  60173. export var volumetricLightScatteringPixelShader: {
  60174. name: string;
  60175. shader: string;
  60176. };
  60177. }
  60178. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60179. /** @hidden */
  60180. export var volumetricLightScatteringPassPixelShader: {
  60181. name: string;
  60182. shader: string;
  60183. };
  60184. }
  60185. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60186. import { Vector3 } from "babylonjs/Maths/math";
  60187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60188. import { Mesh } from "babylonjs/Meshes/mesh";
  60189. import { Camera } from "babylonjs/Cameras/camera";
  60190. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60191. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60192. import { Scene } from "babylonjs/scene";
  60193. import "babylonjs/Meshes/Builders/planeBuilder";
  60194. import "babylonjs/Shaders/depth.vertex";
  60195. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60196. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60197. import { Engine } from "babylonjs/Engines/engine";
  60198. /**
  60199. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60200. */
  60201. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60202. private _volumetricLightScatteringPass;
  60203. private _volumetricLightScatteringRTT;
  60204. private _viewPort;
  60205. private _screenCoordinates;
  60206. private _cachedDefines;
  60207. /**
  60208. * If not undefined, the mesh position is computed from the attached node position
  60209. */
  60210. attachedNode: {
  60211. position: Vector3;
  60212. };
  60213. /**
  60214. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60215. */
  60216. customMeshPosition: Vector3;
  60217. /**
  60218. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60219. */
  60220. useCustomMeshPosition: boolean;
  60221. /**
  60222. * If the post-process should inverse the light scattering direction
  60223. */
  60224. invert: boolean;
  60225. /**
  60226. * The internal mesh used by the post-process
  60227. */
  60228. mesh: Mesh;
  60229. /**
  60230. * @hidden
  60231. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60232. */
  60233. useDiffuseColor: boolean;
  60234. /**
  60235. * Array containing the excluded meshes not rendered in the internal pass
  60236. */
  60237. excludedMeshes: AbstractMesh[];
  60238. /**
  60239. * Controls the overall intensity of the post-process
  60240. */
  60241. exposure: number;
  60242. /**
  60243. * Dissipates each sample's contribution in range [0, 1]
  60244. */
  60245. decay: number;
  60246. /**
  60247. * Controls the overall intensity of each sample
  60248. */
  60249. weight: number;
  60250. /**
  60251. * Controls the density of each sample
  60252. */
  60253. density: number;
  60254. /**
  60255. * @constructor
  60256. * @param name The post-process name
  60257. * @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)
  60258. * @param camera The camera that the post-process will be attached to
  60259. * @param mesh The mesh used to create the light scattering
  60260. * @param samples The post-process quality, default 100
  60261. * @param samplingModeThe post-process filtering mode
  60262. * @param engine The babylon engine
  60263. * @param reusable If the post-process is reusable
  60264. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60265. */
  60266. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60267. /**
  60268. * Returns the string "VolumetricLightScatteringPostProcess"
  60269. * @returns "VolumetricLightScatteringPostProcess"
  60270. */
  60271. getClassName(): string;
  60272. private _isReady;
  60273. /**
  60274. * Sets the new light position for light scattering effect
  60275. * @param position The new custom light position
  60276. */
  60277. setCustomMeshPosition(position: Vector3): void;
  60278. /**
  60279. * Returns the light position for light scattering effect
  60280. * @return Vector3 The custom light position
  60281. */
  60282. getCustomMeshPosition(): Vector3;
  60283. /**
  60284. * Disposes the internal assets and detaches the post-process from the camera
  60285. */
  60286. dispose(camera: Camera): void;
  60287. /**
  60288. * Returns the render target texture used by the post-process
  60289. * @return the render target texture used by the post-process
  60290. */
  60291. getPass(): RenderTargetTexture;
  60292. private _meshExcluded;
  60293. private _createPass;
  60294. private _updateMeshScreenCoordinates;
  60295. /**
  60296. * Creates a default mesh for the Volumeric Light Scattering post-process
  60297. * @param name The mesh name
  60298. * @param scene The scene where to create the mesh
  60299. * @return the default mesh
  60300. */
  60301. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60302. }
  60303. }
  60304. declare module "babylonjs/PostProcesses/index" {
  60305. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60306. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60307. export * from "babylonjs/PostProcesses/bloomEffect";
  60308. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60309. export * from "babylonjs/PostProcesses/blurPostProcess";
  60310. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60311. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60312. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60313. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60314. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60315. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60316. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60317. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60318. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60319. export * from "babylonjs/PostProcesses/filterPostProcess";
  60320. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60321. export * from "babylonjs/PostProcesses/grainPostProcess";
  60322. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60323. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60324. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60325. export * from "babylonjs/PostProcesses/passPostProcess";
  60326. export * from "babylonjs/PostProcesses/postProcess";
  60327. export * from "babylonjs/PostProcesses/postProcessManager";
  60328. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60329. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60330. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60331. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60332. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60333. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60334. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60335. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60336. }
  60337. declare module "babylonjs/Probes/index" {
  60338. export * from "babylonjs/Probes/reflectionProbe";
  60339. }
  60340. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60341. import { Scene } from "babylonjs/scene";
  60342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60343. import { Color3 } from "babylonjs/Maths/math";
  60344. import { SmartArray } from "babylonjs/Misc/smartArray";
  60345. import { ISceneComponent } from "babylonjs/sceneComponent";
  60346. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60347. import "babylonjs/Meshes/Builders/boxBuilder";
  60348. import "babylonjs/Shaders/color.fragment";
  60349. import "babylonjs/Shaders/color.vertex";
  60350. module "babylonjs/scene" {
  60351. interface Scene {
  60352. /** @hidden (Backing field) */
  60353. _boundingBoxRenderer: BoundingBoxRenderer;
  60354. /** @hidden (Backing field) */
  60355. _forceShowBoundingBoxes: boolean;
  60356. /**
  60357. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60358. */
  60359. forceShowBoundingBoxes: boolean;
  60360. /**
  60361. * Gets the bounding box renderer associated with the scene
  60362. * @returns a BoundingBoxRenderer
  60363. */
  60364. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60365. }
  60366. }
  60367. module "babylonjs/Meshes/abstractMesh" {
  60368. interface AbstractMesh {
  60369. /** @hidden (Backing field) */
  60370. _showBoundingBox: boolean;
  60371. /**
  60372. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60373. */
  60374. showBoundingBox: boolean;
  60375. }
  60376. }
  60377. /**
  60378. * Component responsible of rendering the bounding box of the meshes in a scene.
  60379. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60380. */
  60381. export class BoundingBoxRenderer implements ISceneComponent {
  60382. /**
  60383. * The component name helpfull to identify the component in the list of scene components.
  60384. */
  60385. readonly name: string;
  60386. /**
  60387. * The scene the component belongs to.
  60388. */
  60389. scene: Scene;
  60390. /**
  60391. * Color of the bounding box lines placed in front of an object
  60392. */
  60393. frontColor: Color3;
  60394. /**
  60395. * Color of the bounding box lines placed behind an object
  60396. */
  60397. backColor: Color3;
  60398. /**
  60399. * Defines if the renderer should show the back lines or not
  60400. */
  60401. showBackLines: boolean;
  60402. /**
  60403. * @hidden
  60404. */
  60405. renderList: SmartArray<BoundingBox>;
  60406. private _colorShader;
  60407. private _vertexBuffers;
  60408. private _indexBuffer;
  60409. private _fillIndexBuffer;
  60410. private _fillIndexData;
  60411. /**
  60412. * Instantiates a new bounding box renderer in a scene.
  60413. * @param scene the scene the renderer renders in
  60414. */
  60415. constructor(scene: Scene);
  60416. /**
  60417. * Registers the component in a given scene
  60418. */
  60419. register(): void;
  60420. private _evaluateSubMesh;
  60421. private _activeMesh;
  60422. private _prepareRessources;
  60423. private _createIndexBuffer;
  60424. /**
  60425. * Rebuilds the elements related to this component in case of
  60426. * context lost for instance.
  60427. */
  60428. rebuild(): void;
  60429. /**
  60430. * @hidden
  60431. */
  60432. reset(): void;
  60433. /**
  60434. * Render the bounding boxes of a specific rendering group
  60435. * @param renderingGroupId defines the rendering group to render
  60436. */
  60437. render(renderingGroupId: number): void;
  60438. /**
  60439. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60440. * @param mesh Define the mesh to render the occlusion bounding box for
  60441. */
  60442. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60443. /**
  60444. * Dispose and release the resources attached to this renderer.
  60445. */
  60446. dispose(): void;
  60447. }
  60448. }
  60449. declare module "babylonjs/Shaders/depth.fragment" {
  60450. /** @hidden */
  60451. export var depthPixelShader: {
  60452. name: string;
  60453. shader: string;
  60454. };
  60455. }
  60456. declare module "babylonjs/Rendering/depthRenderer" {
  60457. import { Nullable } from "babylonjs/types";
  60458. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60459. import { Scene } from "babylonjs/scene";
  60460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60461. import { Camera } from "babylonjs/Cameras/camera";
  60462. import "babylonjs/Shaders/depth.fragment";
  60463. import "babylonjs/Shaders/depth.vertex";
  60464. /**
  60465. * This represents a depth renderer in Babylon.
  60466. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60467. */
  60468. export class DepthRenderer {
  60469. private _scene;
  60470. private _depthMap;
  60471. private _effect;
  60472. private _cachedDefines;
  60473. private _camera;
  60474. /**
  60475. * Specifiess that the depth renderer will only be used within
  60476. * the camera it is created for.
  60477. * This can help forcing its rendering during the camera processing.
  60478. */
  60479. useOnlyInActiveCamera: boolean;
  60480. /** @hidden */
  60481. static _SceneComponentInitialization: (scene: Scene) => void;
  60482. /**
  60483. * Instantiates a depth renderer
  60484. * @param scene The scene the renderer belongs to
  60485. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60486. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60487. */
  60488. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60489. /**
  60490. * Creates the depth rendering effect and checks if the effect is ready.
  60491. * @param subMesh The submesh to be used to render the depth map of
  60492. * @param useInstances If multiple world instances should be used
  60493. * @returns if the depth renderer is ready to render the depth map
  60494. */
  60495. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60496. /**
  60497. * Gets the texture which the depth map will be written to.
  60498. * @returns The depth map texture
  60499. */
  60500. getDepthMap(): RenderTargetTexture;
  60501. /**
  60502. * Disposes of the depth renderer.
  60503. */
  60504. dispose(): void;
  60505. }
  60506. }
  60507. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60508. import { Nullable } from "babylonjs/types";
  60509. import { Scene } from "babylonjs/scene";
  60510. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60511. import { Camera } from "babylonjs/Cameras/camera";
  60512. import { ISceneComponent } from "babylonjs/sceneComponent";
  60513. module "babylonjs/scene" {
  60514. interface Scene {
  60515. /** @hidden (Backing field) */
  60516. _depthRenderer: {
  60517. [id: string]: DepthRenderer;
  60518. };
  60519. /**
  60520. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60521. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60522. * @returns the created depth renderer
  60523. */
  60524. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60525. /**
  60526. * Disables a depth renderer for a given camera
  60527. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60528. */
  60529. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60530. }
  60531. }
  60532. /**
  60533. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60534. * in several rendering techniques.
  60535. */
  60536. export class DepthRendererSceneComponent implements ISceneComponent {
  60537. /**
  60538. * The component name helpfull to identify the component in the list of scene components.
  60539. */
  60540. readonly name: string;
  60541. /**
  60542. * The scene the component belongs to.
  60543. */
  60544. scene: Scene;
  60545. /**
  60546. * Creates a new instance of the component for the given scene
  60547. * @param scene Defines the scene to register the component in
  60548. */
  60549. constructor(scene: Scene);
  60550. /**
  60551. * Registers the component in a given scene
  60552. */
  60553. register(): void;
  60554. /**
  60555. * Rebuilds the elements related to this component in case of
  60556. * context lost for instance.
  60557. */
  60558. rebuild(): void;
  60559. /**
  60560. * Disposes the component and the associated ressources
  60561. */
  60562. dispose(): void;
  60563. private _gatherRenderTargets;
  60564. private _gatherActiveCameraRenderTargets;
  60565. }
  60566. }
  60567. declare module "babylonjs/Shaders/outline.fragment" {
  60568. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60569. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60570. /** @hidden */
  60571. export var outlinePixelShader: {
  60572. name: string;
  60573. shader: string;
  60574. };
  60575. }
  60576. declare module "babylonjs/Shaders/outline.vertex" {
  60577. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60578. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60580. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60581. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60582. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60583. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60584. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60585. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60586. /** @hidden */
  60587. export var outlineVertexShader: {
  60588. name: string;
  60589. shader: string;
  60590. };
  60591. }
  60592. declare module "babylonjs/Rendering/outlineRenderer" {
  60593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60594. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60595. import { Scene } from "babylonjs/scene";
  60596. import { ISceneComponent } from "babylonjs/sceneComponent";
  60597. import "babylonjs/Shaders/outline.fragment";
  60598. import "babylonjs/Shaders/outline.vertex";
  60599. module "babylonjs/scene" {
  60600. interface Scene {
  60601. /** @hidden */
  60602. _outlineRenderer: OutlineRenderer;
  60603. /**
  60604. * Gets the outline renderer associated with the scene
  60605. * @returns a OutlineRenderer
  60606. */
  60607. getOutlineRenderer(): OutlineRenderer;
  60608. }
  60609. }
  60610. module "babylonjs/Meshes/abstractMesh" {
  60611. interface AbstractMesh {
  60612. /** @hidden (Backing field) */
  60613. _renderOutline: boolean;
  60614. /**
  60615. * Gets or sets a boolean indicating if the outline must be rendered as well
  60616. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60617. */
  60618. renderOutline: boolean;
  60619. /** @hidden (Backing field) */
  60620. _renderOverlay: boolean;
  60621. /**
  60622. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60623. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60624. */
  60625. renderOverlay: boolean;
  60626. }
  60627. }
  60628. /**
  60629. * This class is responsible to draw bothe outline/overlay of meshes.
  60630. * It should not be used directly but through the available method on mesh.
  60631. */
  60632. export class OutlineRenderer implements ISceneComponent {
  60633. /**
  60634. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60635. */
  60636. private static _StencilReference;
  60637. /**
  60638. * The name of the component. Each component must have a unique name.
  60639. */
  60640. name: string;
  60641. /**
  60642. * The scene the component belongs to.
  60643. */
  60644. scene: Scene;
  60645. /**
  60646. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60647. */
  60648. zOffset: number;
  60649. private _engine;
  60650. private _effect;
  60651. private _cachedDefines;
  60652. private _savedDepthWrite;
  60653. /**
  60654. * Instantiates a new outline renderer. (There could be only one per scene).
  60655. * @param scene Defines the scene it belongs to
  60656. */
  60657. constructor(scene: Scene);
  60658. /**
  60659. * Register the component to one instance of a scene.
  60660. */
  60661. register(): void;
  60662. /**
  60663. * Rebuilds the elements related to this component in case of
  60664. * context lost for instance.
  60665. */
  60666. rebuild(): void;
  60667. /**
  60668. * Disposes the component and the associated ressources.
  60669. */
  60670. dispose(): void;
  60671. /**
  60672. * Renders the outline in the canvas.
  60673. * @param subMesh Defines the sumesh to render
  60674. * @param batch Defines the batch of meshes in case of instances
  60675. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60676. */
  60677. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60678. /**
  60679. * Returns whether or not the outline renderer is ready for a given submesh.
  60680. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60681. * @param subMesh Defines the submesh to check readyness for
  60682. * @param useInstances Defines wheter wee are trying to render instances or not
  60683. * @returns true if ready otherwise false
  60684. */
  60685. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60686. private _beforeRenderingMesh;
  60687. private _afterRenderingMesh;
  60688. }
  60689. }
  60690. declare module "babylonjs/Rendering/index" {
  60691. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60692. export * from "babylonjs/Rendering/depthRenderer";
  60693. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60694. export * from "babylonjs/Rendering/edgesRenderer";
  60695. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60696. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60697. export * from "babylonjs/Rendering/outlineRenderer";
  60698. export * from "babylonjs/Rendering/renderingGroup";
  60699. export * from "babylonjs/Rendering/renderingManager";
  60700. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60701. }
  60702. declare module "babylonjs/Sprites/index" {
  60703. export * from "babylonjs/Sprites/sprite";
  60704. export * from "babylonjs/Sprites/spriteManager";
  60705. export * from "babylonjs/Sprites/spriteSceneComponent";
  60706. }
  60707. declare module "babylonjs/Misc/assetsManager" {
  60708. import { Scene } from "babylonjs/scene";
  60709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60710. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60711. import { Skeleton } from "babylonjs/Bones/skeleton";
  60712. import { Observable } from "babylonjs/Misc/observable";
  60713. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60714. import { Texture } from "babylonjs/Materials/Textures/texture";
  60715. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60716. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60717. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60718. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60719. /**
  60720. * Defines the list of states available for a task inside a AssetsManager
  60721. */
  60722. export enum AssetTaskState {
  60723. /**
  60724. * Initialization
  60725. */
  60726. INIT = 0,
  60727. /**
  60728. * Running
  60729. */
  60730. RUNNING = 1,
  60731. /**
  60732. * Done
  60733. */
  60734. DONE = 2,
  60735. /**
  60736. * Error
  60737. */
  60738. ERROR = 3
  60739. }
  60740. /**
  60741. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60742. */
  60743. export abstract class AbstractAssetTask {
  60744. /**
  60745. * Task name
  60746. */ name: string;
  60747. /**
  60748. * Callback called when the task is successful
  60749. */
  60750. onSuccess: (task: any) => void;
  60751. /**
  60752. * Callback called when the task is not successful
  60753. */
  60754. onError: (task: any, message?: string, exception?: any) => void;
  60755. /**
  60756. * Creates a new AssetsManager
  60757. * @param name defines the name of the task
  60758. */
  60759. constructor(
  60760. /**
  60761. * Task name
  60762. */ name: string);
  60763. private _isCompleted;
  60764. private _taskState;
  60765. private _errorObject;
  60766. /**
  60767. * Get if the task is completed
  60768. */
  60769. readonly isCompleted: boolean;
  60770. /**
  60771. * Gets the current state of the task
  60772. */
  60773. readonly taskState: AssetTaskState;
  60774. /**
  60775. * Gets the current error object (if task is in error)
  60776. */
  60777. readonly errorObject: {
  60778. message?: string;
  60779. exception?: any;
  60780. };
  60781. /**
  60782. * Internal only
  60783. * @hidden
  60784. */
  60785. _setErrorObject(message?: string, exception?: any): void;
  60786. /**
  60787. * Execute the current task
  60788. * @param scene defines the scene where you want your assets to be loaded
  60789. * @param onSuccess is a callback called when the task is successfully executed
  60790. * @param onError is a callback called if an error occurs
  60791. */
  60792. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60793. /**
  60794. * Execute the current task
  60795. * @param scene defines the scene where you want your assets to be loaded
  60796. * @param onSuccess is a callback called when the task is successfully executed
  60797. * @param onError is a callback called if an error occurs
  60798. */
  60799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60800. /**
  60801. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60802. * This can be used with failed tasks that have the reason for failure fixed.
  60803. */
  60804. reset(): void;
  60805. private onErrorCallback;
  60806. private onDoneCallback;
  60807. }
  60808. /**
  60809. * Define the interface used by progress events raised during assets loading
  60810. */
  60811. export interface IAssetsProgressEvent {
  60812. /**
  60813. * Defines the number of remaining tasks to process
  60814. */
  60815. remainingCount: number;
  60816. /**
  60817. * Defines the total number of tasks
  60818. */
  60819. totalCount: number;
  60820. /**
  60821. * Defines the task that was just processed
  60822. */
  60823. task: AbstractAssetTask;
  60824. }
  60825. /**
  60826. * Class used to share progress information about assets loading
  60827. */
  60828. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60829. /**
  60830. * Defines the number of remaining tasks to process
  60831. */
  60832. remainingCount: number;
  60833. /**
  60834. * Defines the total number of tasks
  60835. */
  60836. totalCount: number;
  60837. /**
  60838. * Defines the task that was just processed
  60839. */
  60840. task: AbstractAssetTask;
  60841. /**
  60842. * Creates a AssetsProgressEvent
  60843. * @param remainingCount defines the number of remaining tasks to process
  60844. * @param totalCount defines the total number of tasks
  60845. * @param task defines the task that was just processed
  60846. */
  60847. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60848. }
  60849. /**
  60850. * Define a task used by AssetsManager to load meshes
  60851. */
  60852. export class MeshAssetTask extends AbstractAssetTask {
  60853. /**
  60854. * Defines the name of the task
  60855. */
  60856. name: string;
  60857. /**
  60858. * Defines the list of mesh's names you want to load
  60859. */
  60860. meshesNames: any;
  60861. /**
  60862. * Defines the root url to use as a base to load your meshes and associated resources
  60863. */
  60864. rootUrl: string;
  60865. /**
  60866. * Defines the filename of the scene to load from
  60867. */
  60868. sceneFilename: string;
  60869. /**
  60870. * Gets the list of loaded meshes
  60871. */
  60872. loadedMeshes: Array<AbstractMesh>;
  60873. /**
  60874. * Gets the list of loaded particle systems
  60875. */
  60876. loadedParticleSystems: Array<IParticleSystem>;
  60877. /**
  60878. * Gets the list of loaded skeletons
  60879. */
  60880. loadedSkeletons: Array<Skeleton>;
  60881. /**
  60882. * Gets the list of loaded animation groups
  60883. */
  60884. loadedAnimationGroups: Array<AnimationGroup>;
  60885. /**
  60886. * Callback called when the task is successful
  60887. */
  60888. onSuccess: (task: MeshAssetTask) => void;
  60889. /**
  60890. * Callback called when the task is successful
  60891. */
  60892. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60893. /**
  60894. * Creates a new MeshAssetTask
  60895. * @param name defines the name of the task
  60896. * @param meshesNames defines the list of mesh's names you want to load
  60897. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60898. * @param sceneFilename defines the filename of the scene to load from
  60899. */
  60900. constructor(
  60901. /**
  60902. * Defines the name of the task
  60903. */
  60904. name: string,
  60905. /**
  60906. * Defines the list of mesh's names you want to load
  60907. */
  60908. meshesNames: any,
  60909. /**
  60910. * Defines the root url to use as a base to load your meshes and associated resources
  60911. */
  60912. rootUrl: string,
  60913. /**
  60914. * Defines the filename of the scene to load from
  60915. */
  60916. sceneFilename: string);
  60917. /**
  60918. * Execute the current task
  60919. * @param scene defines the scene where you want your assets to be loaded
  60920. * @param onSuccess is a callback called when the task is successfully executed
  60921. * @param onError is a callback called if an error occurs
  60922. */
  60923. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60924. }
  60925. /**
  60926. * Define a task used by AssetsManager to load text content
  60927. */
  60928. export class TextFileAssetTask extends AbstractAssetTask {
  60929. /**
  60930. * Defines the name of the task
  60931. */
  60932. name: string;
  60933. /**
  60934. * Defines the location of the file to load
  60935. */
  60936. url: string;
  60937. /**
  60938. * Gets the loaded text string
  60939. */
  60940. text: string;
  60941. /**
  60942. * Callback called when the task is successful
  60943. */
  60944. onSuccess: (task: TextFileAssetTask) => void;
  60945. /**
  60946. * Callback called when the task is successful
  60947. */
  60948. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60949. /**
  60950. * Creates a new TextFileAssetTask object
  60951. * @param name defines the name of the task
  60952. * @param url defines the location of the file to load
  60953. */
  60954. constructor(
  60955. /**
  60956. * Defines the name of the task
  60957. */
  60958. name: string,
  60959. /**
  60960. * Defines the location of the file to load
  60961. */
  60962. url: string);
  60963. /**
  60964. * Execute the current task
  60965. * @param scene defines the scene where you want your assets to be loaded
  60966. * @param onSuccess is a callback called when the task is successfully executed
  60967. * @param onError is a callback called if an error occurs
  60968. */
  60969. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60970. }
  60971. /**
  60972. * Define a task used by AssetsManager to load binary data
  60973. */
  60974. export class BinaryFileAssetTask extends AbstractAssetTask {
  60975. /**
  60976. * Defines the name of the task
  60977. */
  60978. name: string;
  60979. /**
  60980. * Defines the location of the file to load
  60981. */
  60982. url: string;
  60983. /**
  60984. * Gets the lodaded data (as an array buffer)
  60985. */
  60986. data: ArrayBuffer;
  60987. /**
  60988. * Callback called when the task is successful
  60989. */
  60990. onSuccess: (task: BinaryFileAssetTask) => void;
  60991. /**
  60992. * Callback called when the task is successful
  60993. */
  60994. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60995. /**
  60996. * Creates a new BinaryFileAssetTask object
  60997. * @param name defines the name of the new task
  60998. * @param url defines the location of the file to load
  60999. */
  61000. constructor(
  61001. /**
  61002. * Defines the name of the task
  61003. */
  61004. name: string,
  61005. /**
  61006. * Defines the location of the file to load
  61007. */
  61008. url: string);
  61009. /**
  61010. * Execute the current task
  61011. * @param scene defines the scene where you want your assets to be loaded
  61012. * @param onSuccess is a callback called when the task is successfully executed
  61013. * @param onError is a callback called if an error occurs
  61014. */
  61015. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61016. }
  61017. /**
  61018. * Define a task used by AssetsManager to load images
  61019. */
  61020. export class ImageAssetTask extends AbstractAssetTask {
  61021. /**
  61022. * Defines the name of the task
  61023. */
  61024. name: string;
  61025. /**
  61026. * Defines the location of the image to load
  61027. */
  61028. url: string;
  61029. /**
  61030. * Gets the loaded images
  61031. */
  61032. image: HTMLImageElement;
  61033. /**
  61034. * Callback called when the task is successful
  61035. */
  61036. onSuccess: (task: ImageAssetTask) => void;
  61037. /**
  61038. * Callback called when the task is successful
  61039. */
  61040. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61041. /**
  61042. * Creates a new ImageAssetTask
  61043. * @param name defines the name of the task
  61044. * @param url defines the location of the image to load
  61045. */
  61046. constructor(
  61047. /**
  61048. * Defines the name of the task
  61049. */
  61050. name: string,
  61051. /**
  61052. * Defines the location of the image to load
  61053. */
  61054. url: string);
  61055. /**
  61056. * Execute the current task
  61057. * @param scene defines the scene where you want your assets to be loaded
  61058. * @param onSuccess is a callback called when the task is successfully executed
  61059. * @param onError is a callback called if an error occurs
  61060. */
  61061. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61062. }
  61063. /**
  61064. * Defines the interface used by texture loading tasks
  61065. */
  61066. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61067. /**
  61068. * Gets the loaded texture
  61069. */
  61070. texture: TEX;
  61071. }
  61072. /**
  61073. * Define a task used by AssetsManager to load 2D textures
  61074. */
  61075. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61076. /**
  61077. * Defines the name of the task
  61078. */
  61079. name: string;
  61080. /**
  61081. * Defines the location of the file to load
  61082. */
  61083. url: string;
  61084. /**
  61085. * Defines if mipmap should not be generated (default is false)
  61086. */
  61087. noMipmap?: boolean | undefined;
  61088. /**
  61089. * Defines if texture must be inverted on Y axis (default is false)
  61090. */
  61091. invertY?: boolean | undefined;
  61092. /**
  61093. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61094. */
  61095. samplingMode: number;
  61096. /**
  61097. * Gets the loaded texture
  61098. */
  61099. texture: Texture;
  61100. /**
  61101. * Callback called when the task is successful
  61102. */
  61103. onSuccess: (task: TextureAssetTask) => void;
  61104. /**
  61105. * Callback called when the task is successful
  61106. */
  61107. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61108. /**
  61109. * Creates a new TextureAssetTask object
  61110. * @param name defines the name of the task
  61111. * @param url defines the location of the file to load
  61112. * @param noMipmap defines if mipmap should not be generated (default is false)
  61113. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61114. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61115. */
  61116. constructor(
  61117. /**
  61118. * Defines the name of the task
  61119. */
  61120. name: string,
  61121. /**
  61122. * Defines the location of the file to load
  61123. */
  61124. url: string,
  61125. /**
  61126. * Defines if mipmap should not be generated (default is false)
  61127. */
  61128. noMipmap?: boolean | undefined,
  61129. /**
  61130. * Defines if texture must be inverted on Y axis (default is false)
  61131. */
  61132. invertY?: boolean | undefined,
  61133. /**
  61134. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61135. */
  61136. samplingMode?: number);
  61137. /**
  61138. * Execute the current task
  61139. * @param scene defines the scene where you want your assets to be loaded
  61140. * @param onSuccess is a callback called when the task is successfully executed
  61141. * @param onError is a callback called if an error occurs
  61142. */
  61143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61144. }
  61145. /**
  61146. * Define a task used by AssetsManager to load cube textures
  61147. */
  61148. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61149. /**
  61150. * Defines the name of the task
  61151. */
  61152. name: string;
  61153. /**
  61154. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61155. */
  61156. url: string;
  61157. /**
  61158. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61159. */
  61160. extensions?: string[] | undefined;
  61161. /**
  61162. * Defines if mipmaps should not be generated (default is false)
  61163. */
  61164. noMipmap?: boolean | undefined;
  61165. /**
  61166. * Defines the explicit list of files (undefined by default)
  61167. */
  61168. files?: string[] | undefined;
  61169. /**
  61170. * Gets the loaded texture
  61171. */
  61172. texture: CubeTexture;
  61173. /**
  61174. * Callback called when the task is successful
  61175. */
  61176. onSuccess: (task: CubeTextureAssetTask) => void;
  61177. /**
  61178. * Callback called when the task is successful
  61179. */
  61180. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61181. /**
  61182. * Creates a new CubeTextureAssetTask
  61183. * @param name defines the name of the task
  61184. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61185. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61186. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61187. * @param files defines the explicit list of files (undefined by default)
  61188. */
  61189. constructor(
  61190. /**
  61191. * Defines the name of the task
  61192. */
  61193. name: string,
  61194. /**
  61195. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61196. */
  61197. url: string,
  61198. /**
  61199. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61200. */
  61201. extensions?: string[] | undefined,
  61202. /**
  61203. * Defines if mipmaps should not be generated (default is false)
  61204. */
  61205. noMipmap?: boolean | undefined,
  61206. /**
  61207. * Defines the explicit list of files (undefined by default)
  61208. */
  61209. files?: string[] | undefined);
  61210. /**
  61211. * Execute the current task
  61212. * @param scene defines the scene where you want your assets to be loaded
  61213. * @param onSuccess is a callback called when the task is successfully executed
  61214. * @param onError is a callback called if an error occurs
  61215. */
  61216. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61217. }
  61218. /**
  61219. * Define a task used by AssetsManager to load HDR cube textures
  61220. */
  61221. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61222. /**
  61223. * Defines the name of the task
  61224. */
  61225. name: string;
  61226. /**
  61227. * Defines the location of the file to load
  61228. */
  61229. url: string;
  61230. /**
  61231. * Defines the desired size (the more it increases the longer the generation will be)
  61232. */
  61233. size: number;
  61234. /**
  61235. * Defines if mipmaps should not be generated (default is false)
  61236. */
  61237. noMipmap: boolean;
  61238. /**
  61239. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61240. */
  61241. generateHarmonics: boolean;
  61242. /**
  61243. * 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)
  61244. */
  61245. gammaSpace: boolean;
  61246. /**
  61247. * Internal Use Only
  61248. */
  61249. reserved: boolean;
  61250. /**
  61251. * Gets the loaded texture
  61252. */
  61253. texture: HDRCubeTexture;
  61254. /**
  61255. * Callback called when the task is successful
  61256. */
  61257. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61258. /**
  61259. * Callback called when the task is successful
  61260. */
  61261. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61262. /**
  61263. * Creates a new HDRCubeTextureAssetTask object
  61264. * @param name defines the name of the task
  61265. * @param url defines the location of the file to load
  61266. * @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.
  61267. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61268. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61269. * @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)
  61270. * @param reserved Internal use only
  61271. */
  61272. constructor(
  61273. /**
  61274. * Defines the name of the task
  61275. */
  61276. name: string,
  61277. /**
  61278. * Defines the location of the file to load
  61279. */
  61280. url: string,
  61281. /**
  61282. * Defines the desired size (the more it increases the longer the generation will be)
  61283. */
  61284. size: number,
  61285. /**
  61286. * Defines if mipmaps should not be generated (default is false)
  61287. */
  61288. noMipmap?: boolean,
  61289. /**
  61290. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61291. */
  61292. generateHarmonics?: boolean,
  61293. /**
  61294. * 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)
  61295. */
  61296. gammaSpace?: boolean,
  61297. /**
  61298. * Internal Use Only
  61299. */
  61300. reserved?: boolean);
  61301. /**
  61302. * Execute the current task
  61303. * @param scene defines the scene where you want your assets to be loaded
  61304. * @param onSuccess is a callback called when the task is successfully executed
  61305. * @param onError is a callback called if an error occurs
  61306. */
  61307. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61308. }
  61309. /**
  61310. * Define a task used by AssetsManager to load Equirectangular cube textures
  61311. */
  61312. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61313. /**
  61314. * Defines the name of the task
  61315. */
  61316. name: string;
  61317. /**
  61318. * Defines the location of the file to load
  61319. */
  61320. url: string;
  61321. /**
  61322. * Defines the desired size (the more it increases the longer the generation will be)
  61323. */
  61324. size: number;
  61325. /**
  61326. * Defines if mipmaps should not be generated (default is false)
  61327. */
  61328. noMipmap: boolean;
  61329. /**
  61330. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61331. * but the standard material would require them in Gamma space) (default is true)
  61332. */
  61333. gammaSpace: boolean;
  61334. /**
  61335. * Gets the loaded texture
  61336. */
  61337. texture: EquiRectangularCubeTexture;
  61338. /**
  61339. * Callback called when the task is successful
  61340. */
  61341. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61342. /**
  61343. * Callback called when the task is successful
  61344. */
  61345. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61346. /**
  61347. * Creates a new EquiRectangularCubeTextureAssetTask object
  61348. * @param name defines the name of the task
  61349. * @param url defines the location of the file to load
  61350. * @param size defines the desired size (the more it increases the longer the generation will be)
  61351. * If the size is omitted this implies you are using a preprocessed cubemap.
  61352. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61353. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61354. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61355. * (default is true)
  61356. */
  61357. constructor(
  61358. /**
  61359. * Defines the name of the task
  61360. */
  61361. name: string,
  61362. /**
  61363. * Defines the location of the file to load
  61364. */
  61365. url: string,
  61366. /**
  61367. * Defines the desired size (the more it increases the longer the generation will be)
  61368. */
  61369. size: number,
  61370. /**
  61371. * Defines if mipmaps should not be generated (default is false)
  61372. */
  61373. noMipmap?: boolean,
  61374. /**
  61375. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61376. * but the standard material would require them in Gamma space) (default is true)
  61377. */
  61378. gammaSpace?: boolean);
  61379. /**
  61380. * Execute the current task
  61381. * @param scene defines the scene where you want your assets to be loaded
  61382. * @param onSuccess is a callback called when the task is successfully executed
  61383. * @param onError is a callback called if an error occurs
  61384. */
  61385. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61386. }
  61387. /**
  61388. * This class can be used to easily import assets into a scene
  61389. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61390. */
  61391. export class AssetsManager {
  61392. private _scene;
  61393. private _isLoading;
  61394. protected _tasks: AbstractAssetTask[];
  61395. protected _waitingTasksCount: number;
  61396. protected _totalTasksCount: number;
  61397. /**
  61398. * Callback called when all tasks are processed
  61399. */
  61400. onFinish: (tasks: AbstractAssetTask[]) => void;
  61401. /**
  61402. * Callback called when a task is successful
  61403. */
  61404. onTaskSuccess: (task: AbstractAssetTask) => void;
  61405. /**
  61406. * Callback called when a task had an error
  61407. */
  61408. onTaskError: (task: AbstractAssetTask) => void;
  61409. /**
  61410. * Callback called when a task is done (whatever the result is)
  61411. */
  61412. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61413. /**
  61414. * Observable called when all tasks are processed
  61415. */
  61416. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61417. /**
  61418. * Observable called when a task had an error
  61419. */
  61420. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61421. /**
  61422. * Observable called when all tasks were executed
  61423. */
  61424. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61425. /**
  61426. * Observable called when a task is done (whatever the result is)
  61427. */
  61428. onProgressObservable: Observable<IAssetsProgressEvent>;
  61429. /**
  61430. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61431. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61432. */
  61433. useDefaultLoadingScreen: boolean;
  61434. /**
  61435. * Creates a new AssetsManager
  61436. * @param scene defines the scene to work on
  61437. */
  61438. constructor(scene: Scene);
  61439. /**
  61440. * Add a MeshAssetTask to the list of active tasks
  61441. * @param taskName defines the name of the new task
  61442. * @param meshesNames defines the name of meshes to load
  61443. * @param rootUrl defines the root url to use to locate files
  61444. * @param sceneFilename defines the filename of the scene file
  61445. * @returns a new MeshAssetTask object
  61446. */
  61447. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61448. /**
  61449. * Add a TextFileAssetTask to the list of active tasks
  61450. * @param taskName defines the name of the new task
  61451. * @param url defines the url of the file to load
  61452. * @returns a new TextFileAssetTask object
  61453. */
  61454. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61455. /**
  61456. * Add a BinaryFileAssetTask to the list of active tasks
  61457. * @param taskName defines the name of the new task
  61458. * @param url defines the url of the file to load
  61459. * @returns a new BinaryFileAssetTask object
  61460. */
  61461. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61462. /**
  61463. * Add a ImageAssetTask to the list of active tasks
  61464. * @param taskName defines the name of the new task
  61465. * @param url defines the url of the file to load
  61466. * @returns a new ImageAssetTask object
  61467. */
  61468. addImageTask(taskName: string, url: string): ImageAssetTask;
  61469. /**
  61470. * Add a TextureAssetTask to the list of active tasks
  61471. * @param taskName defines the name of the new task
  61472. * @param url defines the url of the file to load
  61473. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61474. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61475. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61476. * @returns a new TextureAssetTask object
  61477. */
  61478. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61479. /**
  61480. * Add a CubeTextureAssetTask to the list of active tasks
  61481. * @param taskName defines the name of the new task
  61482. * @param url defines the url of the file to load
  61483. * @param extensions defines the extension to use to load the cube map (can be null)
  61484. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61485. * @param files defines the list of files to load (can be null)
  61486. * @returns a new CubeTextureAssetTask object
  61487. */
  61488. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61489. /**
  61490. *
  61491. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61492. * @param taskName defines the name of the new task
  61493. * @param url defines the url of the file to load
  61494. * @param size defines the size you want for the cubemap (can be null)
  61495. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61496. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61497. * @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)
  61498. * @param reserved Internal use only
  61499. * @returns a new HDRCubeTextureAssetTask object
  61500. */
  61501. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61502. /**
  61503. *
  61504. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61505. * @param taskName defines the name of the new task
  61506. * @param url defines the url of the file to load
  61507. * @param size defines the size you want for the cubemap (can be null)
  61508. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61509. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61510. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61511. * @returns a new EquiRectangularCubeTextureAssetTask object
  61512. */
  61513. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61514. /**
  61515. * Remove a task from the assets manager.
  61516. * @param task the task to remove
  61517. */
  61518. removeTask(task: AbstractAssetTask): void;
  61519. private _decreaseWaitingTasksCount;
  61520. private _runTask;
  61521. /**
  61522. * Reset the AssetsManager and remove all tasks
  61523. * @return the current instance of the AssetsManager
  61524. */
  61525. reset(): AssetsManager;
  61526. /**
  61527. * Start the loading process
  61528. * @return the current instance of the AssetsManager
  61529. */
  61530. load(): AssetsManager;
  61531. /**
  61532. * Start the loading process as an async operation
  61533. * @return a promise returning the list of failed tasks
  61534. */
  61535. loadAsync(): Promise<void>;
  61536. }
  61537. }
  61538. declare module "babylonjs/Misc/deferred" {
  61539. /**
  61540. * Wrapper class for promise with external resolve and reject.
  61541. */
  61542. export class Deferred<T> {
  61543. /**
  61544. * The promise associated with this deferred object.
  61545. */
  61546. readonly promise: Promise<T>;
  61547. private _resolve;
  61548. private _reject;
  61549. /**
  61550. * The resolve method of the promise associated with this deferred object.
  61551. */
  61552. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61553. /**
  61554. * The reject method of the promise associated with this deferred object.
  61555. */
  61556. readonly reject: (reason?: any) => void;
  61557. /**
  61558. * Constructor for this deferred object.
  61559. */
  61560. constructor();
  61561. }
  61562. }
  61563. declare module "babylonjs/Misc/meshExploder" {
  61564. import { Mesh } from "babylonjs/Meshes/mesh";
  61565. /**
  61566. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61567. */
  61568. export class MeshExploder {
  61569. private _centerMesh;
  61570. private _meshes;
  61571. private _meshesOrigins;
  61572. private _toCenterVectors;
  61573. private _scaledDirection;
  61574. private _newPosition;
  61575. private _centerPosition;
  61576. /**
  61577. * Explodes meshes from a center mesh.
  61578. * @param meshes The meshes to explode.
  61579. * @param centerMesh The mesh to be center of explosion.
  61580. */
  61581. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61582. private _setCenterMesh;
  61583. /**
  61584. * Get class name
  61585. * @returns "MeshExploder"
  61586. */
  61587. getClassName(): string;
  61588. /**
  61589. * "Exploded meshes"
  61590. * @returns Array of meshes with the centerMesh at index 0.
  61591. */
  61592. getMeshes(): Array<Mesh>;
  61593. /**
  61594. * Explodes meshes giving a specific direction
  61595. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61596. */
  61597. explode(direction?: number): void;
  61598. }
  61599. }
  61600. declare module "babylonjs/Misc/filesInput" {
  61601. import { Engine } from "babylonjs/Engines/engine";
  61602. import { Scene } from "babylonjs/scene";
  61603. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61604. /**
  61605. * Class used to help managing file picking and drag'n'drop
  61606. */
  61607. export class FilesInput {
  61608. /**
  61609. * List of files ready to be loaded
  61610. */
  61611. static readonly FilesToLoad: {
  61612. [key: string]: File;
  61613. };
  61614. /**
  61615. * Callback called when a file is processed
  61616. */
  61617. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61618. private _engine;
  61619. private _currentScene;
  61620. private _sceneLoadedCallback;
  61621. private _progressCallback;
  61622. private _additionalRenderLoopLogicCallback;
  61623. private _textureLoadingCallback;
  61624. private _startingProcessingFilesCallback;
  61625. private _onReloadCallback;
  61626. private _errorCallback;
  61627. private _elementToMonitor;
  61628. private _sceneFileToLoad;
  61629. private _filesToLoad;
  61630. /**
  61631. * Creates a new FilesInput
  61632. * @param engine defines the rendering engine
  61633. * @param scene defines the hosting scene
  61634. * @param sceneLoadedCallback callback called when scene is loaded
  61635. * @param progressCallback callback called to track progress
  61636. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61637. * @param textureLoadingCallback callback called when a texture is loading
  61638. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61639. * @param onReloadCallback callback called when a reload is requested
  61640. * @param errorCallback callback call if an error occurs
  61641. */
  61642. 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);
  61643. private _dragEnterHandler;
  61644. private _dragOverHandler;
  61645. private _dropHandler;
  61646. /**
  61647. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61648. * @param elementToMonitor defines the DOM element to track
  61649. */
  61650. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61651. /**
  61652. * Release all associated resources
  61653. */
  61654. dispose(): void;
  61655. private renderFunction;
  61656. private drag;
  61657. private drop;
  61658. private _traverseFolder;
  61659. private _processFiles;
  61660. /**
  61661. * Load files from a drop event
  61662. * @param event defines the drop event to use as source
  61663. */
  61664. loadFiles(event: any): void;
  61665. private _processReload;
  61666. /**
  61667. * Reload the current scene from the loaded files
  61668. */
  61669. reload(): void;
  61670. }
  61671. }
  61672. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61673. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61674. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61675. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61676. }
  61677. declare module "babylonjs/Misc/sceneOptimizer" {
  61678. import { Scene, IDisposable } from "babylonjs/scene";
  61679. import { Observable } from "babylonjs/Misc/observable";
  61680. /**
  61681. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61682. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61683. */
  61684. export class SceneOptimization {
  61685. /**
  61686. * Defines the priority of this optimization (0 by default which means first in the list)
  61687. */
  61688. priority: number;
  61689. /**
  61690. * Gets a string describing the action executed by the current optimization
  61691. * @returns description string
  61692. */
  61693. getDescription(): string;
  61694. /**
  61695. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61696. * @param scene defines the current scene where to apply this optimization
  61697. * @param optimizer defines the current optimizer
  61698. * @returns true if everything that can be done was applied
  61699. */
  61700. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61701. /**
  61702. * Creates the SceneOptimization object
  61703. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61704. * @param desc defines the description associated with the optimization
  61705. */
  61706. constructor(
  61707. /**
  61708. * Defines the priority of this optimization (0 by default which means first in the list)
  61709. */
  61710. priority?: number);
  61711. }
  61712. /**
  61713. * Defines an optimization used to reduce the size of render target textures
  61714. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61715. */
  61716. export class TextureOptimization extends SceneOptimization {
  61717. /**
  61718. * Defines the priority of this optimization (0 by default which means first in the list)
  61719. */
  61720. priority: number;
  61721. /**
  61722. * 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
  61723. */
  61724. maximumSize: number;
  61725. /**
  61726. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61727. */
  61728. step: number;
  61729. /**
  61730. * Gets a string describing the action executed by the current optimization
  61731. * @returns description string
  61732. */
  61733. getDescription(): string;
  61734. /**
  61735. * Creates the TextureOptimization object
  61736. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61737. * @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
  61738. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61739. */
  61740. constructor(
  61741. /**
  61742. * Defines the priority of this optimization (0 by default which means first in the list)
  61743. */
  61744. priority?: number,
  61745. /**
  61746. * 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
  61747. */
  61748. maximumSize?: number,
  61749. /**
  61750. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61751. */
  61752. step?: number);
  61753. /**
  61754. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61755. * @param scene defines the current scene where to apply this optimization
  61756. * @param optimizer defines the current optimizer
  61757. * @returns true if everything that can be done was applied
  61758. */
  61759. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61760. }
  61761. /**
  61762. * Defines an optimization used to increase or decrease the rendering resolution
  61763. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61764. */
  61765. export class HardwareScalingOptimization extends SceneOptimization {
  61766. /**
  61767. * Defines the priority of this optimization (0 by default which means first in the list)
  61768. */
  61769. priority: number;
  61770. /**
  61771. * Defines the maximum scale to use (2 by default)
  61772. */
  61773. maximumScale: number;
  61774. /**
  61775. * Defines the step to use between two passes (0.5 by default)
  61776. */
  61777. step: number;
  61778. private _currentScale;
  61779. private _directionOffset;
  61780. /**
  61781. * Gets a string describing the action executed by the current optimization
  61782. * @return description string
  61783. */
  61784. getDescription(): string;
  61785. /**
  61786. * Creates the HardwareScalingOptimization object
  61787. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61788. * @param maximumScale defines the maximum scale to use (2 by default)
  61789. * @param step defines the step to use between two passes (0.5 by default)
  61790. */
  61791. constructor(
  61792. /**
  61793. * Defines the priority of this optimization (0 by default which means first in the list)
  61794. */
  61795. priority?: number,
  61796. /**
  61797. * Defines the maximum scale to use (2 by default)
  61798. */
  61799. maximumScale?: number,
  61800. /**
  61801. * Defines the step to use between two passes (0.5 by default)
  61802. */
  61803. step?: number);
  61804. /**
  61805. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61806. * @param scene defines the current scene where to apply this optimization
  61807. * @param optimizer defines the current optimizer
  61808. * @returns true if everything that can be done was applied
  61809. */
  61810. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61811. }
  61812. /**
  61813. * Defines an optimization used to remove shadows
  61814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61815. */
  61816. export class ShadowsOptimization extends SceneOptimization {
  61817. /**
  61818. * Gets a string describing the action executed by the current optimization
  61819. * @return description string
  61820. */
  61821. getDescription(): string;
  61822. /**
  61823. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61824. * @param scene defines the current scene where to apply this optimization
  61825. * @param optimizer defines the current optimizer
  61826. * @returns true if everything that can be done was applied
  61827. */
  61828. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61829. }
  61830. /**
  61831. * Defines an optimization used to turn post-processes off
  61832. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61833. */
  61834. export class PostProcessesOptimization extends SceneOptimization {
  61835. /**
  61836. * Gets a string describing the action executed by the current optimization
  61837. * @return description string
  61838. */
  61839. getDescription(): string;
  61840. /**
  61841. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61842. * @param scene defines the current scene where to apply this optimization
  61843. * @param optimizer defines the current optimizer
  61844. * @returns true if everything that can be done was applied
  61845. */
  61846. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61847. }
  61848. /**
  61849. * Defines an optimization used to turn lens flares off
  61850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61851. */
  61852. export class LensFlaresOptimization extends SceneOptimization {
  61853. /**
  61854. * Gets a string describing the action executed by the current optimization
  61855. * @return description string
  61856. */
  61857. getDescription(): string;
  61858. /**
  61859. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61860. * @param scene defines the current scene where to apply this optimization
  61861. * @param optimizer defines the current optimizer
  61862. * @returns true if everything that can be done was applied
  61863. */
  61864. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61865. }
  61866. /**
  61867. * Defines an optimization based on user defined callback.
  61868. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61869. */
  61870. export class CustomOptimization extends SceneOptimization {
  61871. /**
  61872. * Callback called to apply the custom optimization.
  61873. */
  61874. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61875. /**
  61876. * Callback called to get custom description
  61877. */
  61878. onGetDescription: () => string;
  61879. /**
  61880. * Gets a string describing the action executed by the current optimization
  61881. * @returns description string
  61882. */
  61883. getDescription(): string;
  61884. /**
  61885. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61886. * @param scene defines the current scene where to apply this optimization
  61887. * @param optimizer defines the current optimizer
  61888. * @returns true if everything that can be done was applied
  61889. */
  61890. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61891. }
  61892. /**
  61893. * Defines an optimization used to turn particles off
  61894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61895. */
  61896. export class ParticlesOptimization extends SceneOptimization {
  61897. /**
  61898. * Gets a string describing the action executed by the current optimization
  61899. * @return description string
  61900. */
  61901. getDescription(): string;
  61902. /**
  61903. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61904. * @param scene defines the current scene where to apply this optimization
  61905. * @param optimizer defines the current optimizer
  61906. * @returns true if everything that can be done was applied
  61907. */
  61908. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61909. }
  61910. /**
  61911. * Defines an optimization used to turn render targets off
  61912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61913. */
  61914. export class RenderTargetsOptimization extends SceneOptimization {
  61915. /**
  61916. * Gets a string describing the action executed by the current optimization
  61917. * @return description string
  61918. */
  61919. getDescription(): string;
  61920. /**
  61921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61922. * @param scene defines the current scene where to apply this optimization
  61923. * @param optimizer defines the current optimizer
  61924. * @returns true if everything that can be done was applied
  61925. */
  61926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61927. }
  61928. /**
  61929. * Defines an optimization used to merge meshes with compatible materials
  61930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61931. */
  61932. export class MergeMeshesOptimization extends SceneOptimization {
  61933. private static _UpdateSelectionTree;
  61934. /**
  61935. * Gets or sets a boolean which defines if optimization octree has to be updated
  61936. */
  61937. /**
  61938. * Gets or sets a boolean which defines if optimization octree has to be updated
  61939. */
  61940. static UpdateSelectionTree: boolean;
  61941. /**
  61942. * Gets a string describing the action executed by the current optimization
  61943. * @return description string
  61944. */
  61945. getDescription(): string;
  61946. private _canBeMerged;
  61947. /**
  61948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61949. * @param scene defines the current scene where to apply this optimization
  61950. * @param optimizer defines the current optimizer
  61951. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61952. * @returns true if everything that can be done was applied
  61953. */
  61954. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61955. }
  61956. /**
  61957. * Defines a list of options used by SceneOptimizer
  61958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61959. */
  61960. export class SceneOptimizerOptions {
  61961. /**
  61962. * Defines the target frame rate to reach (60 by default)
  61963. */
  61964. targetFrameRate: number;
  61965. /**
  61966. * Defines the interval between two checkes (2000ms by default)
  61967. */
  61968. trackerDuration: number;
  61969. /**
  61970. * Gets the list of optimizations to apply
  61971. */
  61972. optimizations: SceneOptimization[];
  61973. /**
  61974. * Creates a new list of options used by SceneOptimizer
  61975. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61976. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61977. */
  61978. constructor(
  61979. /**
  61980. * Defines the target frame rate to reach (60 by default)
  61981. */
  61982. targetFrameRate?: number,
  61983. /**
  61984. * Defines the interval between two checkes (2000ms by default)
  61985. */
  61986. trackerDuration?: number);
  61987. /**
  61988. * Add a new optimization
  61989. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61990. * @returns the current SceneOptimizerOptions
  61991. */
  61992. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61993. /**
  61994. * Add a new custom optimization
  61995. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61996. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61997. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61998. * @returns the current SceneOptimizerOptions
  61999. */
  62000. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62001. /**
  62002. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62003. * @param targetFrameRate defines the target frame rate (60 by default)
  62004. * @returns a SceneOptimizerOptions object
  62005. */
  62006. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62007. /**
  62008. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62009. * @param targetFrameRate defines the target frame rate (60 by default)
  62010. * @returns a SceneOptimizerOptions object
  62011. */
  62012. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62013. /**
  62014. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62015. * @param targetFrameRate defines the target frame rate (60 by default)
  62016. * @returns a SceneOptimizerOptions object
  62017. */
  62018. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62019. }
  62020. /**
  62021. * Class used to run optimizations in order to reach a target frame rate
  62022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62023. */
  62024. export class SceneOptimizer implements IDisposable {
  62025. private _isRunning;
  62026. private _options;
  62027. private _scene;
  62028. private _currentPriorityLevel;
  62029. private _targetFrameRate;
  62030. private _trackerDuration;
  62031. private _currentFrameRate;
  62032. private _sceneDisposeObserver;
  62033. private _improvementMode;
  62034. /**
  62035. * Defines an observable called when the optimizer reaches the target frame rate
  62036. */
  62037. onSuccessObservable: Observable<SceneOptimizer>;
  62038. /**
  62039. * Defines an observable called when the optimizer enables an optimization
  62040. */
  62041. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62042. /**
  62043. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62044. */
  62045. onFailureObservable: Observable<SceneOptimizer>;
  62046. /**
  62047. * Gets a boolean indicating if the optimizer is in improvement mode
  62048. */
  62049. readonly isInImprovementMode: boolean;
  62050. /**
  62051. * Gets the current priority level (0 at start)
  62052. */
  62053. readonly currentPriorityLevel: number;
  62054. /**
  62055. * Gets the current frame rate checked by the SceneOptimizer
  62056. */
  62057. readonly currentFrameRate: number;
  62058. /**
  62059. * Gets or sets the current target frame rate (60 by default)
  62060. */
  62061. /**
  62062. * Gets or sets the current target frame rate (60 by default)
  62063. */
  62064. targetFrameRate: number;
  62065. /**
  62066. * Gets or sets the current interval between two checks (every 2000ms by default)
  62067. */
  62068. /**
  62069. * Gets or sets the current interval between two checks (every 2000ms by default)
  62070. */
  62071. trackerDuration: number;
  62072. /**
  62073. * Gets the list of active optimizations
  62074. */
  62075. readonly optimizations: SceneOptimization[];
  62076. /**
  62077. * Creates a new SceneOptimizer
  62078. * @param scene defines the scene to work on
  62079. * @param options defines the options to use with the SceneOptimizer
  62080. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62081. * @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)
  62082. */
  62083. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62084. /**
  62085. * Stops the current optimizer
  62086. */
  62087. stop(): void;
  62088. /**
  62089. * Reset the optimizer to initial step (current priority level = 0)
  62090. */
  62091. reset(): void;
  62092. /**
  62093. * Start the optimizer. By default it will try to reach a specific framerate
  62094. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62095. */
  62096. start(): void;
  62097. private _checkCurrentState;
  62098. /**
  62099. * Release all resources
  62100. */
  62101. dispose(): void;
  62102. /**
  62103. * Helper function to create a SceneOptimizer with one single line of code
  62104. * @param scene defines the scene to work on
  62105. * @param options defines the options to use with the SceneOptimizer
  62106. * @param onSuccess defines a callback to call on success
  62107. * @param onFailure defines a callback to call on failure
  62108. * @returns the new SceneOptimizer object
  62109. */
  62110. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62111. }
  62112. }
  62113. declare module "babylonjs/Misc/sceneSerializer" {
  62114. import { Scene } from "babylonjs/scene";
  62115. /**
  62116. * Class used to serialize a scene into a string
  62117. */
  62118. export class SceneSerializer {
  62119. /**
  62120. * Clear cache used by a previous serialization
  62121. */
  62122. static ClearCache(): void;
  62123. /**
  62124. * Serialize a scene into a JSON compatible object
  62125. * @param scene defines the scene to serialize
  62126. * @returns a JSON compatible object
  62127. */
  62128. static Serialize(scene: Scene): any;
  62129. /**
  62130. * Serialize a mesh into a JSON compatible object
  62131. * @param toSerialize defines the mesh to serialize
  62132. * @param withParents defines if parents must be serialized as well
  62133. * @param withChildren defines if children must be serialized as well
  62134. * @returns a JSON compatible object
  62135. */
  62136. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62137. }
  62138. }
  62139. declare module "babylonjs/Misc/textureTools" {
  62140. import { Texture } from "babylonjs/Materials/Textures/texture";
  62141. /**
  62142. * Class used to host texture specific utilities
  62143. */
  62144. export class TextureTools {
  62145. /**
  62146. * Uses the GPU to create a copy texture rescaled at a given size
  62147. * @param texture Texture to copy from
  62148. * @param width defines the desired width
  62149. * @param height defines the desired height
  62150. * @param useBilinearMode defines if bilinear mode has to be used
  62151. * @return the generated texture
  62152. */
  62153. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62154. }
  62155. }
  62156. declare module "babylonjs/Misc/videoRecorder" {
  62157. import { Nullable } from "babylonjs/types";
  62158. import { Engine } from "babylonjs/Engines/engine";
  62159. /**
  62160. * This represents the different options available for the video capture.
  62161. */
  62162. export interface VideoRecorderOptions {
  62163. /** Defines the mime type of the video. */
  62164. mimeType: string;
  62165. /** Defines the FPS the video should be recorded at. */
  62166. fps: number;
  62167. /** Defines the chunk size for the recording data. */
  62168. recordChunckSize: number;
  62169. /** The audio tracks to attach to the recording. */
  62170. audioTracks?: MediaStreamTrack[];
  62171. }
  62172. /**
  62173. * This can help with recording videos from BabylonJS.
  62174. * This is based on the available WebRTC functionalities of the browser.
  62175. *
  62176. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62177. */
  62178. export class VideoRecorder {
  62179. private static readonly _defaultOptions;
  62180. /**
  62181. * Returns whether or not the VideoRecorder is available in your browser.
  62182. * @param engine Defines the Babylon Engine.
  62183. * @returns true if supported otherwise false.
  62184. */
  62185. static IsSupported(engine: Engine): boolean;
  62186. private readonly _options;
  62187. private _canvas;
  62188. private _mediaRecorder;
  62189. private _recordedChunks;
  62190. private _fileName;
  62191. private _resolve;
  62192. private _reject;
  62193. /**
  62194. * True when a recording is already in progress.
  62195. */
  62196. readonly isRecording: boolean;
  62197. /**
  62198. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62199. * @param engine Defines the BabylonJS Engine you wish to record.
  62200. * @param options Defines options that can be used to customize the capture.
  62201. */
  62202. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62203. /**
  62204. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62205. */
  62206. stopRecording(): void;
  62207. /**
  62208. * Starts recording the canvas for a max duration specified in parameters.
  62209. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62210. * If null no automatic download will start and you can rely on the promise to get the data back.
  62211. * @param maxDuration Defines the maximum recording time in seconds.
  62212. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62213. * @return A promise callback at the end of the recording with the video data in Blob.
  62214. */
  62215. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62216. /**
  62217. * Releases internal resources used during the recording.
  62218. */
  62219. dispose(): void;
  62220. private _handleDataAvailable;
  62221. private _handleError;
  62222. private _handleStop;
  62223. }
  62224. }
  62225. declare module "babylonjs/Misc/screenshotTools" {
  62226. import { Camera } from "babylonjs/Cameras/camera";
  62227. import { Engine } from "babylonjs/Engines/engine";
  62228. /**
  62229. * Class containing a set of static utilities functions for screenshots
  62230. */
  62231. export class ScreenshotTools {
  62232. /**
  62233. * Captures a screenshot of the current rendering
  62234. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62235. * @param engine defines the rendering engine
  62236. * @param camera defines the source camera
  62237. * @param size This parameter can be set to a single number or to an object with the
  62238. * following (optional) properties: precision, width, height. If a single number is passed,
  62239. * it will be used for both width and height. If an object is passed, the screenshot size
  62240. * will be derived from the parameters. The precision property is a multiplier allowing
  62241. * rendering at a higher or lower resolution
  62242. * @param successCallback defines the callback receives a single parameter which contains the
  62243. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62244. * src parameter of an <img> to display it
  62245. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62246. * Check your browser for supported MIME types
  62247. */
  62248. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62249. /**
  62250. * Generates an image screenshot from the specified camera.
  62251. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62252. * @param engine The engine to use for rendering
  62253. * @param camera The camera to use for rendering
  62254. * @param size This parameter can be set to a single number or to an object with the
  62255. * following (optional) properties: precision, width, height. If a single number is passed,
  62256. * it will be used for both width and height. If an object is passed, the screenshot size
  62257. * will be derived from the parameters. The precision property is a multiplier allowing
  62258. * rendering at a higher or lower resolution
  62259. * @param successCallback The callback receives a single parameter which contains the
  62260. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62261. * src parameter of an <img> to display it
  62262. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62263. * Check your browser for supported MIME types
  62264. * @param samples Texture samples (default: 1)
  62265. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62266. * @param fileName A name for for the downloaded file.
  62267. */
  62268. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62269. }
  62270. }
  62271. declare module "babylonjs/Misc/index" {
  62272. export * from "babylonjs/Misc/andOrNotEvaluator";
  62273. export * from "babylonjs/Misc/assetsManager";
  62274. export * from "babylonjs/Misc/dds";
  62275. export * from "babylonjs/Misc/decorators";
  62276. export * from "babylonjs/Misc/deferred";
  62277. export * from "babylonjs/Misc/environmentTextureTools";
  62278. export * from "babylonjs/Misc/meshExploder";
  62279. export * from "babylonjs/Misc/filesInput";
  62280. export * from "babylonjs/Misc/HighDynamicRange/index";
  62281. export * from "babylonjs/Misc/khronosTextureContainer";
  62282. export * from "babylonjs/Misc/observable";
  62283. export * from "babylonjs/Misc/performanceMonitor";
  62284. export * from "babylonjs/Misc/promise";
  62285. export * from "babylonjs/Misc/sceneOptimizer";
  62286. export * from "babylonjs/Misc/sceneSerializer";
  62287. export * from "babylonjs/Misc/smartArray";
  62288. export * from "babylonjs/Misc/stringDictionary";
  62289. export * from "babylonjs/Misc/tags";
  62290. export * from "babylonjs/Misc/textureTools";
  62291. export * from "babylonjs/Misc/tga";
  62292. export * from "babylonjs/Misc/tools";
  62293. export * from "babylonjs/Misc/videoRecorder";
  62294. export * from "babylonjs/Misc/virtualJoystick";
  62295. export * from "babylonjs/Misc/workerPool";
  62296. export * from "babylonjs/Misc/logger";
  62297. export * from "babylonjs/Misc/typeStore";
  62298. export * from "babylonjs/Misc/filesInputStore";
  62299. export * from "babylonjs/Misc/deepCopier";
  62300. export * from "babylonjs/Misc/pivotTools";
  62301. export * from "babylonjs/Misc/precisionDate";
  62302. export * from "babylonjs/Misc/screenshotTools";
  62303. export * from "babylonjs/Misc/typeStore";
  62304. export * from "babylonjs/Misc/webRequest";
  62305. export * from "babylonjs/Misc/iInspectable";
  62306. export * from "babylonjs/Misc/brdfTextureTools";
  62307. }
  62308. declare module "babylonjs/index" {
  62309. export * from "babylonjs/abstractScene";
  62310. export * from "babylonjs/Actions/index";
  62311. export * from "babylonjs/Animations/index";
  62312. export * from "babylonjs/assetContainer";
  62313. export * from "babylonjs/Audio/index";
  62314. export * from "babylonjs/Behaviors/index";
  62315. export * from "babylonjs/Bones/index";
  62316. export * from "babylonjs/Cameras/index";
  62317. export * from "babylonjs/Collisions/index";
  62318. export * from "babylonjs/Culling/index";
  62319. export * from "babylonjs/Debug/index";
  62320. export * from "babylonjs/Engines/index";
  62321. export * from "babylonjs/Events/index";
  62322. export * from "babylonjs/Gamepads/index";
  62323. export * from "babylonjs/Gizmos/index";
  62324. export * from "babylonjs/Helpers/index";
  62325. export * from "babylonjs/Instrumentation/index";
  62326. export * from "babylonjs/Layers/index";
  62327. export * from "babylonjs/LensFlares/index";
  62328. export * from "babylonjs/Lights/index";
  62329. export * from "babylonjs/Loading/index";
  62330. export * from "babylonjs/Materials/index";
  62331. export * from "babylonjs/Maths/index";
  62332. export * from "babylonjs/Meshes/index";
  62333. export * from "babylonjs/Morph/index";
  62334. export * from "babylonjs/node";
  62335. export * from "babylonjs/Offline/index";
  62336. export * from "babylonjs/Particles/index";
  62337. export * from "babylonjs/Physics/index";
  62338. export * from "babylonjs/PostProcesses/index";
  62339. export * from "babylonjs/Probes/index";
  62340. export * from "babylonjs/Rendering/index";
  62341. export * from "babylonjs/scene";
  62342. export * from "babylonjs/sceneComponent";
  62343. export * from "babylonjs/Sprites/index";
  62344. export * from "babylonjs/States/index";
  62345. export * from "babylonjs/Misc/index";
  62346. export * from "babylonjs/types";
  62347. }
  62348. declare module "babylonjs/Animations/pathCursor" {
  62349. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62350. /**
  62351. * A cursor which tracks a point on a path
  62352. */
  62353. export class PathCursor {
  62354. private path;
  62355. /**
  62356. * Stores path cursor callbacks for when an onchange event is triggered
  62357. */
  62358. private _onchange;
  62359. /**
  62360. * The value of the path cursor
  62361. */
  62362. value: number;
  62363. /**
  62364. * The animation array of the path cursor
  62365. */
  62366. animations: Animation[];
  62367. /**
  62368. * Initializes the path cursor
  62369. * @param path The path to track
  62370. */
  62371. constructor(path: Path2);
  62372. /**
  62373. * Gets the cursor point on the path
  62374. * @returns A point on the path cursor at the cursor location
  62375. */
  62376. getPoint(): Vector3;
  62377. /**
  62378. * Moves the cursor ahead by the step amount
  62379. * @param step The amount to move the cursor forward
  62380. * @returns This path cursor
  62381. */
  62382. moveAhead(step?: number): PathCursor;
  62383. /**
  62384. * Moves the cursor behind by the step amount
  62385. * @param step The amount to move the cursor back
  62386. * @returns This path cursor
  62387. */
  62388. moveBack(step?: number): PathCursor;
  62389. /**
  62390. * Moves the cursor by the step amount
  62391. * If the step amount is greater than one, an exception is thrown
  62392. * @param step The amount to move the cursor
  62393. * @returns This path cursor
  62394. */
  62395. move(step: number): PathCursor;
  62396. /**
  62397. * Ensures that the value is limited between zero and one
  62398. * @returns This path cursor
  62399. */
  62400. private ensureLimits;
  62401. /**
  62402. * Runs onchange callbacks on change (used by the animation engine)
  62403. * @returns This path cursor
  62404. */
  62405. private raiseOnChange;
  62406. /**
  62407. * Executes a function on change
  62408. * @param f A path cursor onchange callback
  62409. * @returns This path cursor
  62410. */
  62411. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62412. }
  62413. }
  62414. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62415. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62416. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62417. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62418. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62419. }
  62420. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62421. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62422. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62423. }
  62424. declare module "babylonjs/Engines/Processors/index" {
  62425. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62426. export * from "babylonjs/Engines/Processors/Expressions/index";
  62427. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62428. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62429. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62430. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62431. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62432. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62433. }
  62434. declare module "babylonjs/Legacy/legacy" {
  62435. import * as Babylon from "babylonjs/index";
  62436. export * from "babylonjs/index";
  62437. }
  62438. declare module "babylonjs/Shaders/blur.fragment" {
  62439. /** @hidden */
  62440. export var blurPixelShader: {
  62441. name: string;
  62442. shader: string;
  62443. };
  62444. }
  62445. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62446. /** @hidden */
  62447. export var pointCloudVertexDeclaration: {
  62448. name: string;
  62449. shader: string;
  62450. };
  62451. }
  62452. // Mixins
  62453. interface Window {
  62454. mozIndexedDB: IDBFactory;
  62455. webkitIndexedDB: IDBFactory;
  62456. msIndexedDB: IDBFactory;
  62457. webkitURL: typeof URL;
  62458. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62459. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62460. WebGLRenderingContext: WebGLRenderingContext;
  62461. MSGesture: MSGesture;
  62462. CANNON: any;
  62463. AudioContext: AudioContext;
  62464. webkitAudioContext: AudioContext;
  62465. PointerEvent: any;
  62466. Math: Math;
  62467. Uint8Array: Uint8ArrayConstructor;
  62468. Float32Array: Float32ArrayConstructor;
  62469. mozURL: typeof URL;
  62470. msURL: typeof URL;
  62471. VRFrameData: any; // WebVR, from specs 1.1
  62472. DracoDecoderModule: any;
  62473. setImmediate(handler: (...args: any[]) => void): number;
  62474. }
  62475. interface HTMLCanvasElement {
  62476. requestPointerLock(): void;
  62477. msRequestPointerLock?(): void;
  62478. mozRequestPointerLock?(): void;
  62479. webkitRequestPointerLock?(): void;
  62480. /** Track wether a record is in progress */
  62481. isRecording: boolean;
  62482. /** Capture Stream method defined by some browsers */
  62483. captureStream(fps?: number): MediaStream;
  62484. }
  62485. interface CanvasRenderingContext2D {
  62486. msImageSmoothingEnabled: boolean;
  62487. }
  62488. interface MouseEvent {
  62489. mozMovementX: number;
  62490. mozMovementY: number;
  62491. webkitMovementX: number;
  62492. webkitMovementY: number;
  62493. msMovementX: number;
  62494. msMovementY: number;
  62495. }
  62496. interface Navigator {
  62497. mozGetVRDevices: (any: any) => any;
  62498. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62499. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62500. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62501. webkitGetGamepads(): Gamepad[];
  62502. msGetGamepads(): Gamepad[];
  62503. webkitGamepads(): Gamepad[];
  62504. }
  62505. interface HTMLVideoElement {
  62506. mozSrcObject: any;
  62507. }
  62508. interface Math {
  62509. fround(x: number): number;
  62510. imul(a: number, b: number): number;
  62511. }
  62512. interface WebGLRenderingContext {
  62513. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62514. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62515. vertexAttribDivisor(index: number, divisor: number): void;
  62516. createVertexArray(): any;
  62517. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62518. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62519. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62520. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62521. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62522. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62523. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62524. // Queries
  62525. createQuery(): WebGLQuery;
  62526. deleteQuery(query: WebGLQuery): void;
  62527. beginQuery(target: number, query: WebGLQuery): void;
  62528. endQuery(target: number): void;
  62529. getQueryParameter(query: WebGLQuery, pname: number): any;
  62530. getQuery(target: number, pname: number): any;
  62531. MAX_SAMPLES: number;
  62532. RGBA8: number;
  62533. READ_FRAMEBUFFER: number;
  62534. DRAW_FRAMEBUFFER: number;
  62535. UNIFORM_BUFFER: number;
  62536. HALF_FLOAT_OES: number;
  62537. RGBA16F: number;
  62538. RGBA32F: number;
  62539. R32F: number;
  62540. RG32F: number;
  62541. RGB32F: number;
  62542. R16F: number;
  62543. RG16F: number;
  62544. RGB16F: number;
  62545. RED: number;
  62546. RG: number;
  62547. R8: number;
  62548. RG8: number;
  62549. UNSIGNED_INT_24_8: number;
  62550. DEPTH24_STENCIL8: number;
  62551. /* Multiple Render Targets */
  62552. drawBuffers(buffers: number[]): void;
  62553. readBuffer(src: number): void;
  62554. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62555. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62556. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62557. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62558. // Occlusion Query
  62559. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62560. ANY_SAMPLES_PASSED: number;
  62561. QUERY_RESULT_AVAILABLE: number;
  62562. QUERY_RESULT: number;
  62563. }
  62564. interface WebGLProgram {
  62565. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62566. }
  62567. interface EXT_disjoint_timer_query {
  62568. QUERY_COUNTER_BITS_EXT: number;
  62569. TIME_ELAPSED_EXT: number;
  62570. TIMESTAMP_EXT: number;
  62571. GPU_DISJOINT_EXT: number;
  62572. QUERY_RESULT_EXT: number;
  62573. QUERY_RESULT_AVAILABLE_EXT: number;
  62574. queryCounterEXT(query: WebGLQuery, target: number): void;
  62575. createQueryEXT(): WebGLQuery;
  62576. beginQueryEXT(target: number, query: WebGLQuery): void;
  62577. endQueryEXT(target: number): void;
  62578. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62579. deleteQueryEXT(query: WebGLQuery): void;
  62580. }
  62581. interface WebGLUniformLocation {
  62582. _currentState: any;
  62583. }
  62584. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62585. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62586. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62587. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62588. interface WebGLRenderingContext {
  62589. readonly RASTERIZER_DISCARD: number;
  62590. readonly DEPTH_COMPONENT24: number;
  62591. readonly TEXTURE_3D: number;
  62592. readonly TEXTURE_2D_ARRAY: number;
  62593. readonly TEXTURE_COMPARE_FUNC: number;
  62594. readonly TEXTURE_COMPARE_MODE: number;
  62595. readonly COMPARE_REF_TO_TEXTURE: number;
  62596. readonly TEXTURE_WRAP_R: number;
  62597. readonly HALF_FLOAT: number;
  62598. readonly RGB8: number;
  62599. readonly RED_INTEGER: number;
  62600. readonly RG_INTEGER: number;
  62601. readonly RGB_INTEGER: number;
  62602. readonly RGBA_INTEGER: number;
  62603. readonly R8_SNORM: number;
  62604. readonly RG8_SNORM: number;
  62605. readonly RGB8_SNORM: number;
  62606. readonly RGBA8_SNORM: number;
  62607. readonly R8I: number;
  62608. readonly RG8I: number;
  62609. readonly RGB8I: number;
  62610. readonly RGBA8I: number;
  62611. readonly R8UI: number;
  62612. readonly RG8UI: number;
  62613. readonly RGB8UI: number;
  62614. readonly RGBA8UI: number;
  62615. readonly R16I: number;
  62616. readonly RG16I: number;
  62617. readonly RGB16I: number;
  62618. readonly RGBA16I: number;
  62619. readonly R16UI: number;
  62620. readonly RG16UI: number;
  62621. readonly RGB16UI: number;
  62622. readonly RGBA16UI: number;
  62623. readonly R32I: number;
  62624. readonly RG32I: number;
  62625. readonly RGB32I: number;
  62626. readonly RGBA32I: number;
  62627. readonly R32UI: number;
  62628. readonly RG32UI: number;
  62629. readonly RGB32UI: number;
  62630. readonly RGBA32UI: number;
  62631. readonly RGB10_A2UI: number;
  62632. readonly R11F_G11F_B10F: number;
  62633. readonly RGB9_E5: number;
  62634. readonly RGB10_A2: number;
  62635. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62636. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62637. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62638. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62639. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62640. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62641. 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;
  62642. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62643. readonly TRANSFORM_FEEDBACK: number;
  62644. readonly INTERLEAVED_ATTRIBS: number;
  62645. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62646. createTransformFeedback(): WebGLTransformFeedback;
  62647. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62648. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62649. beginTransformFeedback(primitiveMode: number): void;
  62650. endTransformFeedback(): void;
  62651. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62652. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62653. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62654. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62655. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62656. }
  62657. interface ImageBitmap {
  62658. readonly width: number;
  62659. readonly height: number;
  62660. close(): void;
  62661. }
  62662. interface WebGLQuery extends WebGLObject {
  62663. }
  62664. declare var WebGLQuery: {
  62665. prototype: WebGLQuery;
  62666. new(): WebGLQuery;
  62667. };
  62668. interface WebGLSampler extends WebGLObject {
  62669. }
  62670. declare var WebGLSampler: {
  62671. prototype: WebGLSampler;
  62672. new(): WebGLSampler;
  62673. };
  62674. interface WebGLSync extends WebGLObject {
  62675. }
  62676. declare var WebGLSync: {
  62677. prototype: WebGLSync;
  62678. new(): WebGLSync;
  62679. };
  62680. interface WebGLTransformFeedback extends WebGLObject {
  62681. }
  62682. declare var WebGLTransformFeedback: {
  62683. prototype: WebGLTransformFeedback;
  62684. new(): WebGLTransformFeedback;
  62685. };
  62686. interface WebGLVertexArrayObject extends WebGLObject {
  62687. }
  62688. declare var WebGLVertexArrayObject: {
  62689. prototype: WebGLVertexArrayObject;
  62690. new(): WebGLVertexArrayObject;
  62691. };
  62692. // Type definitions for WebVR API
  62693. // Project: https://w3c.github.io/webvr/
  62694. // Definitions by: six a <https://github.com/lostfictions>
  62695. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62696. interface VRDisplay extends EventTarget {
  62697. /**
  62698. * Dictionary of capabilities describing the VRDisplay.
  62699. */
  62700. readonly capabilities: VRDisplayCapabilities;
  62701. /**
  62702. * z-depth defining the far plane of the eye view frustum
  62703. * enables mapping of values in the render target depth
  62704. * attachment to scene coordinates. Initially set to 10000.0.
  62705. */
  62706. depthFar: number;
  62707. /**
  62708. * z-depth defining the near plane of the eye view frustum
  62709. * enables mapping of values in the render target depth
  62710. * attachment to scene coordinates. Initially set to 0.01.
  62711. */
  62712. depthNear: number;
  62713. /**
  62714. * An identifier for this distinct VRDisplay. Used as an
  62715. * association point in the Gamepad API.
  62716. */
  62717. readonly displayId: number;
  62718. /**
  62719. * A display name, a user-readable name identifying it.
  62720. */
  62721. readonly displayName: string;
  62722. readonly isConnected: boolean;
  62723. readonly isPresenting: boolean;
  62724. /**
  62725. * If this VRDisplay supports room-scale experiences, the optional
  62726. * stage attribute contains details on the room-scale parameters.
  62727. */
  62728. readonly stageParameters: VRStageParameters | null;
  62729. /**
  62730. * Passing the value returned by `requestAnimationFrame` to
  62731. * `cancelAnimationFrame` will unregister the callback.
  62732. * @param handle Define the hanle of the request to cancel
  62733. */
  62734. cancelAnimationFrame(handle: number): void;
  62735. /**
  62736. * Stops presenting to the VRDisplay.
  62737. * @returns a promise to know when it stopped
  62738. */
  62739. exitPresent(): Promise<void>;
  62740. /**
  62741. * Return the current VREyeParameters for the given eye.
  62742. * @param whichEye Define the eye we want the parameter for
  62743. * @returns the eye parameters
  62744. */
  62745. getEyeParameters(whichEye: string): VREyeParameters;
  62746. /**
  62747. * Populates the passed VRFrameData with the information required to render
  62748. * the current frame.
  62749. * @param frameData Define the data structure to populate
  62750. * @returns true if ok otherwise false
  62751. */
  62752. getFrameData(frameData: VRFrameData): boolean;
  62753. /**
  62754. * Get the layers currently being presented.
  62755. * @returns the list of VR layers
  62756. */
  62757. getLayers(): VRLayer[];
  62758. /**
  62759. * Return a VRPose containing the future predicted pose of the VRDisplay
  62760. * when the current frame will be presented. The value returned will not
  62761. * change until JavaScript has returned control to the browser.
  62762. *
  62763. * The VRPose will contain the position, orientation, velocity,
  62764. * and acceleration of each of these properties.
  62765. * @returns the pose object
  62766. */
  62767. getPose(): VRPose;
  62768. /**
  62769. * Return the current instantaneous pose of the VRDisplay, with no
  62770. * prediction applied.
  62771. * @returns the current instantaneous pose
  62772. */
  62773. getImmediatePose(): VRPose;
  62774. /**
  62775. * The callback passed to `requestAnimationFrame` will be called
  62776. * any time a new frame should be rendered. When the VRDisplay is
  62777. * presenting the callback will be called at the native refresh
  62778. * rate of the HMD. When not presenting this function acts
  62779. * identically to how window.requestAnimationFrame acts. Content should
  62780. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62781. * asynchronously from other displays and at differing refresh rates.
  62782. * @param callback Define the eaction to run next frame
  62783. * @returns the request handle it
  62784. */
  62785. requestAnimationFrame(callback: FrameRequestCallback): number;
  62786. /**
  62787. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62788. * Repeat calls while already presenting will update the VRLayers being displayed.
  62789. * @param layers Define the list of layer to present
  62790. * @returns a promise to know when the request has been fulfilled
  62791. */
  62792. requestPresent(layers: VRLayer[]): Promise<void>;
  62793. /**
  62794. * Reset the pose for this display, treating its current position and
  62795. * orientation as the "origin/zero" values. VRPose.position,
  62796. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62797. * updated when calling resetPose(). This should be called in only
  62798. * sitting-space experiences.
  62799. */
  62800. resetPose(): void;
  62801. /**
  62802. * The VRLayer provided to the VRDisplay will be captured and presented
  62803. * in the HMD. Calling this function has the same effect on the source
  62804. * canvas as any other operation that uses its source image, and canvases
  62805. * created without preserveDrawingBuffer set to true will be cleared.
  62806. * @param pose Define the pose to submit
  62807. */
  62808. submitFrame(pose?: VRPose): void;
  62809. }
  62810. declare var VRDisplay: {
  62811. prototype: VRDisplay;
  62812. new(): VRDisplay;
  62813. };
  62814. interface VRLayer {
  62815. leftBounds?: number[] | Float32Array | null;
  62816. rightBounds?: number[] | Float32Array | null;
  62817. source?: HTMLCanvasElement | null;
  62818. }
  62819. interface VRDisplayCapabilities {
  62820. readonly canPresent: boolean;
  62821. readonly hasExternalDisplay: boolean;
  62822. readonly hasOrientation: boolean;
  62823. readonly hasPosition: boolean;
  62824. readonly maxLayers: number;
  62825. }
  62826. interface VREyeParameters {
  62827. /** @deprecated */
  62828. readonly fieldOfView: VRFieldOfView;
  62829. readonly offset: Float32Array;
  62830. readonly renderHeight: number;
  62831. readonly renderWidth: number;
  62832. }
  62833. interface VRFieldOfView {
  62834. readonly downDegrees: number;
  62835. readonly leftDegrees: number;
  62836. readonly rightDegrees: number;
  62837. readonly upDegrees: number;
  62838. }
  62839. interface VRFrameData {
  62840. readonly leftProjectionMatrix: Float32Array;
  62841. readonly leftViewMatrix: Float32Array;
  62842. readonly pose: VRPose;
  62843. readonly rightProjectionMatrix: Float32Array;
  62844. readonly rightViewMatrix: Float32Array;
  62845. readonly timestamp: number;
  62846. }
  62847. interface VRPose {
  62848. readonly angularAcceleration: Float32Array | null;
  62849. readonly angularVelocity: Float32Array | null;
  62850. readonly linearAcceleration: Float32Array | null;
  62851. readonly linearVelocity: Float32Array | null;
  62852. readonly orientation: Float32Array | null;
  62853. readonly position: Float32Array | null;
  62854. readonly timestamp: number;
  62855. }
  62856. interface VRStageParameters {
  62857. sittingToStandingTransform?: Float32Array;
  62858. sizeX?: number;
  62859. sizeY?: number;
  62860. }
  62861. interface Navigator {
  62862. getVRDisplays(): Promise<VRDisplay[]>;
  62863. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62864. }
  62865. interface Window {
  62866. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62867. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62868. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62869. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62870. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62871. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62872. }
  62873. interface Gamepad {
  62874. readonly displayId: number;
  62875. }
  62876. interface XRDevice {
  62877. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62878. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62879. }
  62880. interface XRSession {
  62881. getInputSources(): Array<any>;
  62882. baseLayer: XRWebGLLayer;
  62883. requestFrameOfReference(type: string): Promise<void>;
  62884. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62885. end(): Promise<void>;
  62886. requestAnimationFrame: Function;
  62887. addEventListener: Function;
  62888. }
  62889. interface XRSessionCreationOptions {
  62890. outputContext?: WebGLRenderingContext | null;
  62891. immersive?: boolean;
  62892. environmentIntegration?: boolean;
  62893. }
  62894. interface XRLayer {
  62895. getViewport: Function;
  62896. framebufferWidth: number;
  62897. framebufferHeight: number;
  62898. }
  62899. interface XRView {
  62900. projectionMatrix: Float32Array;
  62901. }
  62902. interface XRFrame {
  62903. getDevicePose: Function;
  62904. getInputPose: Function;
  62905. views: Array<XRView>;
  62906. baseLayer: XRLayer;
  62907. }
  62908. interface XRFrameOfReference {
  62909. }
  62910. interface XRWebGLLayer extends XRLayer {
  62911. framebuffer: WebGLFramebuffer;
  62912. }
  62913. declare var XRWebGLLayer: {
  62914. prototype: XRWebGLLayer;
  62915. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62916. };
  62917. declare module "babylonjs" {
  62918. export * from "babylonjs/Legacy/legacy";
  62919. }
  62920. declare module BABYLON {
  62921. /** Alias type for value that can be null */
  62922. export type Nullable<T> = T | null;
  62923. /**
  62924. * Alias type for number that are floats
  62925. * @ignorenaming
  62926. */
  62927. export type float = number;
  62928. /**
  62929. * Alias type for number that are doubles.
  62930. * @ignorenaming
  62931. */
  62932. export type double = number;
  62933. /**
  62934. * Alias type for number that are integer
  62935. * @ignorenaming
  62936. */
  62937. export type int = number;
  62938. /** Alias type for number array or Float32Array */
  62939. export type FloatArray = number[] | Float32Array;
  62940. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62941. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62942. /**
  62943. * Alias for types that can be used by a Buffer or VertexBuffer.
  62944. */
  62945. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62946. /**
  62947. * Alias type for primitive types
  62948. * @ignorenaming
  62949. */
  62950. type Primitive = undefined | null | boolean | string | number | Function;
  62951. /**
  62952. * Type modifier to make all the properties of an object Readonly
  62953. */
  62954. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62955. /**
  62956. * Type modifier to make all the properties of an object Readonly recursively
  62957. */
  62958. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62959. /** @hidden */
  62960. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62961. }
  62962. /** @hidden */
  62963. /** @hidden */
  62964. type DeepImmutableObject<T> = {
  62965. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62966. };
  62967. }
  62968. declare module BABYLON {
  62969. /**
  62970. * Class containing a set of static utilities functions for arrays.
  62971. */
  62972. export class ArrayTools {
  62973. /**
  62974. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62975. * @param size the number of element to construct and put in the array
  62976. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62977. * @returns a new array filled with new objects
  62978. */
  62979. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62980. }
  62981. }
  62982. declare module BABYLON {
  62983. /**
  62984. * Scalar computation library
  62985. */
  62986. export class Scalar {
  62987. /**
  62988. * Two pi constants convenient for computation.
  62989. */
  62990. static TwoPi: number;
  62991. /**
  62992. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62993. * @param a number
  62994. * @param b number
  62995. * @param epsilon (default = 1.401298E-45)
  62996. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62997. */
  62998. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62999. /**
  63000. * Returns a string : the upper case translation of the number i to hexadecimal.
  63001. * @param i number
  63002. * @returns the upper case translation of the number i to hexadecimal.
  63003. */
  63004. static ToHex(i: number): string;
  63005. /**
  63006. * Returns -1 if value is negative and +1 is value is positive.
  63007. * @param value the value
  63008. * @returns the value itself if it's equal to zero.
  63009. */
  63010. static Sign(value: number): number;
  63011. /**
  63012. * Returns the value itself if it's between min and max.
  63013. * Returns min if the value is lower than min.
  63014. * Returns max if the value is greater than max.
  63015. * @param value the value to clmap
  63016. * @param min the min value to clamp to (default: 0)
  63017. * @param max the max value to clamp to (default: 1)
  63018. * @returns the clamped value
  63019. */
  63020. static Clamp(value: number, min?: number, max?: number): number;
  63021. /**
  63022. * the log2 of value.
  63023. * @param value the value to compute log2 of
  63024. * @returns the log2 of value.
  63025. */
  63026. static Log2(value: number): number;
  63027. /**
  63028. * Loops the value, so that it is never larger than length and never smaller than 0.
  63029. *
  63030. * This is similar to the modulo operator but it works with floating point numbers.
  63031. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  63032. * With t = 5 and length = 2.5, the result would be 0.0.
  63033. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  63034. * @param value the value
  63035. * @param length the length
  63036. * @returns the looped value
  63037. */
  63038. static Repeat(value: number, length: number): number;
  63039. /**
  63040. * Normalize the value between 0.0 and 1.0 using min and max values
  63041. * @param value value to normalize
  63042. * @param min max to normalize between
  63043. * @param max min to normalize between
  63044. * @returns the normalized value
  63045. */
  63046. static Normalize(value: number, min: number, max: number): number;
  63047. /**
  63048. * Denormalize the value from 0.0 and 1.0 using min and max values
  63049. * @param normalized value to denormalize
  63050. * @param min max to denormalize between
  63051. * @param max min to denormalize between
  63052. * @returns the denormalized value
  63053. */
  63054. static Denormalize(normalized: number, min: number, max: number): number;
  63055. /**
  63056. * Calculates the shortest difference between two given angles given in degrees.
  63057. * @param current current angle in degrees
  63058. * @param target target angle in degrees
  63059. * @returns the delta
  63060. */
  63061. static DeltaAngle(current: number, target: number): number;
  63062. /**
  63063. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  63064. * @param tx value
  63065. * @param length length
  63066. * @returns The returned value will move back and forth between 0 and length
  63067. */
  63068. static PingPong(tx: number, length: number): number;
  63069. /**
  63070. * Interpolates between min and max with smoothing at the limits.
  63071. *
  63072. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  63073. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  63074. * @param from from
  63075. * @param to to
  63076. * @param tx value
  63077. * @returns the smooth stepped value
  63078. */
  63079. static SmoothStep(from: number, to: number, tx: number): number;
  63080. /**
  63081. * Moves a value current towards target.
  63082. *
  63083. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  63084. * Negative values of maxDelta pushes the value away from target.
  63085. * @param current current value
  63086. * @param target target value
  63087. * @param maxDelta max distance to move
  63088. * @returns resulting value
  63089. */
  63090. static MoveTowards(current: number, target: number, maxDelta: number): number;
  63091. /**
  63092. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63093. *
  63094. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  63095. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  63096. * @param current current value
  63097. * @param target target value
  63098. * @param maxDelta max distance to move
  63099. * @returns resulting angle
  63100. */
  63101. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  63102. /**
  63103. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  63104. * @param start start value
  63105. * @param end target value
  63106. * @param amount amount to lerp between
  63107. * @returns the lerped value
  63108. */
  63109. static Lerp(start: number, end: number, amount: number): number;
  63110. /**
  63111. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63112. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  63113. * @param start start value
  63114. * @param end target value
  63115. * @param amount amount to lerp between
  63116. * @returns the lerped value
  63117. */
  63118. static LerpAngle(start: number, end: number, amount: number): number;
  63119. /**
  63120. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  63121. * @param a start value
  63122. * @param b target value
  63123. * @param value value between a and b
  63124. * @returns the inverseLerp value
  63125. */
  63126. static InverseLerp(a: number, b: number, value: number): number;
  63127. /**
  63128. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  63129. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  63130. * @param value1 spline value
  63131. * @param tangent1 spline value
  63132. * @param value2 spline value
  63133. * @param tangent2 spline value
  63134. * @param amount input value
  63135. * @returns hermite result
  63136. */
  63137. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  63138. /**
  63139. * Returns a random float number between and min and max values
  63140. * @param min min value of random
  63141. * @param max max value of random
  63142. * @returns random value
  63143. */
  63144. static RandomRange(min: number, max: number): number;
  63145. /**
  63146. * This function returns percentage of a number in a given range.
  63147. *
  63148. * RangeToPercent(40,20,60) will return 0.5 (50%)
  63149. * RangeToPercent(34,0,100) will return 0.34 (34%)
  63150. * @param number to convert to percentage
  63151. * @param min min range
  63152. * @param max max range
  63153. * @returns the percentage
  63154. */
  63155. static RangeToPercent(number: number, min: number, max: number): number;
  63156. /**
  63157. * This function returns number that corresponds to the percentage in a given range.
  63158. *
  63159. * PercentToRange(0.34,0,100) will return 34.
  63160. * @param percent to convert to number
  63161. * @param min min range
  63162. * @param max max range
  63163. * @returns the number
  63164. */
  63165. static PercentToRange(percent: number, min: number, max: number): number;
  63166. /**
  63167. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  63168. * @param angle The angle to normalize in radian.
  63169. * @return The converted angle.
  63170. */
  63171. static NormalizeRadians(angle: number): number;
  63172. }
  63173. }
  63174. declare module BABYLON {
  63175. /**
  63176. * Constant used to convert a value to gamma space
  63177. * @ignorenaming
  63178. */
  63179. export const ToGammaSpace: number;
  63180. /**
  63181. * Constant used to convert a value to linear space
  63182. * @ignorenaming
  63183. */
  63184. export const ToLinearSpace = 2.2;
  63185. /**
  63186. * Constant used to define the minimal number value in Babylon.js
  63187. * @ignorenaming
  63188. */
  63189. let Epsilon: number;
  63190. /**
  63191. * Class used to hold a RBG color
  63192. */
  63193. export class Color3 {
  63194. /**
  63195. * Defines the red component (between 0 and 1, default is 0)
  63196. */
  63197. r: number;
  63198. /**
  63199. * Defines the green component (between 0 and 1, default is 0)
  63200. */
  63201. g: number;
  63202. /**
  63203. * Defines the blue component (between 0 and 1, default is 0)
  63204. */
  63205. b: number;
  63206. /**
  63207. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  63208. * @param r defines the red component (between 0 and 1, default is 0)
  63209. * @param g defines the green component (between 0 and 1, default is 0)
  63210. * @param b defines the blue component (between 0 and 1, default is 0)
  63211. */
  63212. constructor(
  63213. /**
  63214. * Defines the red component (between 0 and 1, default is 0)
  63215. */
  63216. r?: number,
  63217. /**
  63218. * Defines the green component (between 0 and 1, default is 0)
  63219. */
  63220. g?: number,
  63221. /**
  63222. * Defines the blue component (between 0 and 1, default is 0)
  63223. */
  63224. b?: number);
  63225. /**
  63226. * Creates a string with the Color3 current values
  63227. * @returns the string representation of the Color3 object
  63228. */
  63229. toString(): string;
  63230. /**
  63231. * Returns the string "Color3"
  63232. * @returns "Color3"
  63233. */
  63234. getClassName(): string;
  63235. /**
  63236. * Compute the Color3 hash code
  63237. * @returns an unique number that can be used to hash Color3 objects
  63238. */
  63239. getHashCode(): number;
  63240. /**
  63241. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  63242. * @param array defines the array where to store the r,g,b components
  63243. * @param index defines an optional index in the target array to define where to start storing values
  63244. * @returns the current Color3 object
  63245. */
  63246. toArray(array: FloatArray, index?: number): Color3;
  63247. /**
  63248. * Returns a new Color4 object from the current Color3 and the given alpha
  63249. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  63250. * @returns a new Color4 object
  63251. */
  63252. toColor4(alpha?: number): Color4;
  63253. /**
  63254. * Returns a new array populated with 3 numeric elements : red, green and blue values
  63255. * @returns the new array
  63256. */
  63257. asArray(): number[];
  63258. /**
  63259. * Returns the luminance value
  63260. * @returns a float value
  63261. */
  63262. toLuminance(): number;
  63263. /**
  63264. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  63265. * @param otherColor defines the second operand
  63266. * @returns the new Color3 object
  63267. */
  63268. multiply(otherColor: DeepImmutable<Color3>): Color3;
  63269. /**
  63270. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  63271. * @param otherColor defines the second operand
  63272. * @param result defines the Color3 object where to store the result
  63273. * @returns the current Color3
  63274. */
  63275. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63276. /**
  63277. * Determines equality between Color3 objects
  63278. * @param otherColor defines the second operand
  63279. * @returns true if the rgb values are equal to the given ones
  63280. */
  63281. equals(otherColor: DeepImmutable<Color3>): boolean;
  63282. /**
  63283. * Determines equality between the current Color3 object and a set of r,b,g values
  63284. * @param r defines the red component to check
  63285. * @param g defines the green component to check
  63286. * @param b defines the blue component to check
  63287. * @returns true if the rgb values are equal to the given ones
  63288. */
  63289. equalsFloats(r: number, g: number, b: number): boolean;
  63290. /**
  63291. * Multiplies in place each rgb value by scale
  63292. * @param scale defines the scaling factor
  63293. * @returns the updated Color3
  63294. */
  63295. scale(scale: number): Color3;
  63296. /**
  63297. * Multiplies the rgb values by scale and stores the result into "result"
  63298. * @param scale defines the scaling factor
  63299. * @param result defines the Color3 object where to store the result
  63300. * @returns the unmodified current Color3
  63301. */
  63302. scaleToRef(scale: number, result: Color3): Color3;
  63303. /**
  63304. * Scale the current Color3 values by a factor and add the result to a given Color3
  63305. * @param scale defines the scale factor
  63306. * @param result defines color to store the result into
  63307. * @returns the unmodified current Color3
  63308. */
  63309. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63310. /**
  63311. * Clamps the rgb values by the min and max values and stores the result into "result"
  63312. * @param min defines minimum clamping value (default is 0)
  63313. * @param max defines maximum clamping value (default is 1)
  63314. * @param result defines color to store the result into
  63315. * @returns the original Color3
  63316. */
  63317. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63318. /**
  63319. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63320. * @param otherColor defines the second operand
  63321. * @returns the new Color3
  63322. */
  63323. add(otherColor: DeepImmutable<Color3>): Color3;
  63324. /**
  63325. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63326. * @param otherColor defines the second operand
  63327. * @param result defines Color3 object to store the result into
  63328. * @returns the unmodified current Color3
  63329. */
  63330. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63331. /**
  63332. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63333. * @param otherColor defines the second operand
  63334. * @returns the new Color3
  63335. */
  63336. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63337. /**
  63338. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63339. * @param otherColor defines the second operand
  63340. * @param result defines Color3 object to store the result into
  63341. * @returns the unmodified current Color3
  63342. */
  63343. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63344. /**
  63345. * Copy the current object
  63346. * @returns a new Color3 copied the current one
  63347. */
  63348. clone(): Color3;
  63349. /**
  63350. * Copies the rgb values from the source in the current Color3
  63351. * @param source defines the source Color3 object
  63352. * @returns the updated Color3 object
  63353. */
  63354. copyFrom(source: DeepImmutable<Color3>): Color3;
  63355. /**
  63356. * Updates the Color3 rgb values from the given floats
  63357. * @param r defines the red component to read from
  63358. * @param g defines the green component to read from
  63359. * @param b defines the blue component to read from
  63360. * @returns the current Color3 object
  63361. */
  63362. copyFromFloats(r: number, g: number, b: number): Color3;
  63363. /**
  63364. * Updates the Color3 rgb values from the given floats
  63365. * @param r defines the red component to read from
  63366. * @param g defines the green component to read from
  63367. * @param b defines the blue component to read from
  63368. * @returns the current Color3 object
  63369. */
  63370. set(r: number, g: number, b: number): Color3;
  63371. /**
  63372. * Compute the Color3 hexadecimal code as a string
  63373. * @returns a string containing the hexadecimal representation of the Color3 object
  63374. */
  63375. toHexString(): string;
  63376. /**
  63377. * Computes a new Color3 converted from the current one to linear space
  63378. * @returns a new Color3 object
  63379. */
  63380. toLinearSpace(): Color3;
  63381. /**
  63382. * Converts current color in rgb space to HSV values
  63383. * @returns a new color3 representing the HSV values
  63384. */
  63385. toHSV(): Color3;
  63386. /**
  63387. * Converts current color in rgb space to HSV values
  63388. * @param result defines the Color3 where to store the HSV values
  63389. */
  63390. toHSVToRef(result: Color3): void;
  63391. /**
  63392. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63393. * @param convertedColor defines the Color3 object where to store the linear space version
  63394. * @returns the unmodified Color3
  63395. */
  63396. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63397. /**
  63398. * Computes a new Color3 converted from the current one to gamma space
  63399. * @returns a new Color3 object
  63400. */
  63401. toGammaSpace(): Color3;
  63402. /**
  63403. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63404. * @param convertedColor defines the Color3 object where to store the gamma space version
  63405. * @returns the unmodified Color3
  63406. */
  63407. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63408. private static _BlackReadOnly;
  63409. /**
  63410. * Convert Hue, saturation and value to a Color3 (RGB)
  63411. * @param hue defines the hue
  63412. * @param saturation defines the saturation
  63413. * @param value defines the value
  63414. * @param result defines the Color3 where to store the RGB values
  63415. */
  63416. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63417. /**
  63418. * Creates a new Color3 from the string containing valid hexadecimal values
  63419. * @param hex defines a string containing valid hexadecimal values
  63420. * @returns a new Color3 object
  63421. */
  63422. static FromHexString(hex: string): Color3;
  63423. /**
  63424. * Creates a new Color3 from the starting index of the given array
  63425. * @param array defines the source array
  63426. * @param offset defines an offset in the source array
  63427. * @returns a new Color3 object
  63428. */
  63429. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63430. /**
  63431. * Creates a new Color3 from integer values (< 256)
  63432. * @param r defines the red component to read from (value between 0 and 255)
  63433. * @param g defines the green component to read from (value between 0 and 255)
  63434. * @param b defines the blue component to read from (value between 0 and 255)
  63435. * @returns a new Color3 object
  63436. */
  63437. static FromInts(r: number, g: number, b: number): Color3;
  63438. /**
  63439. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63440. * @param start defines the start Color3 value
  63441. * @param end defines the end Color3 value
  63442. * @param amount defines the gradient value between start and end
  63443. * @returns a new Color3 object
  63444. */
  63445. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63446. /**
  63447. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63448. * @param left defines the start value
  63449. * @param right defines the end value
  63450. * @param amount defines the gradient factor
  63451. * @param result defines the Color3 object where to store the result
  63452. */
  63453. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63454. /**
  63455. * Returns a Color3 value containing a red color
  63456. * @returns a new Color3 object
  63457. */
  63458. static Red(): Color3;
  63459. /**
  63460. * Returns a Color3 value containing a green color
  63461. * @returns a new Color3 object
  63462. */
  63463. static Green(): Color3;
  63464. /**
  63465. * Returns a Color3 value containing a blue color
  63466. * @returns a new Color3 object
  63467. */
  63468. static Blue(): Color3;
  63469. /**
  63470. * Returns a Color3 value containing a black color
  63471. * @returns a new Color3 object
  63472. */
  63473. static Black(): Color3;
  63474. /**
  63475. * Gets a Color3 value containing a black color that must not be updated
  63476. */
  63477. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63478. /**
  63479. * Returns a Color3 value containing a white color
  63480. * @returns a new Color3 object
  63481. */
  63482. static White(): Color3;
  63483. /**
  63484. * Returns a Color3 value containing a purple color
  63485. * @returns a new Color3 object
  63486. */
  63487. static Purple(): Color3;
  63488. /**
  63489. * Returns a Color3 value containing a magenta color
  63490. * @returns a new Color3 object
  63491. */
  63492. static Magenta(): Color3;
  63493. /**
  63494. * Returns a Color3 value containing a yellow color
  63495. * @returns a new Color3 object
  63496. */
  63497. static Yellow(): Color3;
  63498. /**
  63499. * Returns a Color3 value containing a gray color
  63500. * @returns a new Color3 object
  63501. */
  63502. static Gray(): Color3;
  63503. /**
  63504. * Returns a Color3 value containing a teal color
  63505. * @returns a new Color3 object
  63506. */
  63507. static Teal(): Color3;
  63508. /**
  63509. * Returns a Color3 value containing a random color
  63510. * @returns a new Color3 object
  63511. */
  63512. static Random(): Color3;
  63513. }
  63514. /**
  63515. * Class used to hold a RBGA color
  63516. */
  63517. export class Color4 {
  63518. /**
  63519. * Defines the red component (between 0 and 1, default is 0)
  63520. */
  63521. r: number;
  63522. /**
  63523. * Defines the green component (between 0 and 1, default is 0)
  63524. */
  63525. g: number;
  63526. /**
  63527. * Defines the blue component (between 0 and 1, default is 0)
  63528. */
  63529. b: number;
  63530. /**
  63531. * Defines the alpha component (between 0 and 1, default is 1)
  63532. */
  63533. a: number;
  63534. /**
  63535. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63536. * @param r defines the red component (between 0 and 1, default is 0)
  63537. * @param g defines the green component (between 0 and 1, default is 0)
  63538. * @param b defines the blue component (between 0 and 1, default is 0)
  63539. * @param a defines the alpha component (between 0 and 1, default is 1)
  63540. */
  63541. constructor(
  63542. /**
  63543. * Defines the red component (between 0 and 1, default is 0)
  63544. */
  63545. r?: number,
  63546. /**
  63547. * Defines the green component (between 0 and 1, default is 0)
  63548. */
  63549. g?: number,
  63550. /**
  63551. * Defines the blue component (between 0 and 1, default is 0)
  63552. */
  63553. b?: number,
  63554. /**
  63555. * Defines the alpha component (between 0 and 1, default is 1)
  63556. */
  63557. a?: number);
  63558. /**
  63559. * Adds in place the given Color4 values to the current Color4 object
  63560. * @param right defines the second operand
  63561. * @returns the current updated Color4 object
  63562. */
  63563. addInPlace(right: DeepImmutable<Color4>): Color4;
  63564. /**
  63565. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63566. * @returns the new array
  63567. */
  63568. asArray(): number[];
  63569. /**
  63570. * Stores from the starting index in the given array the Color4 successive values
  63571. * @param array defines the array where to store the r,g,b components
  63572. * @param index defines an optional index in the target array to define where to start storing values
  63573. * @returns the current Color4 object
  63574. */
  63575. toArray(array: number[], index?: number): Color4;
  63576. /**
  63577. * Determines equality between Color4 objects
  63578. * @param otherColor defines the second operand
  63579. * @returns true if the rgba values are equal to the given ones
  63580. */
  63581. equals(otherColor: DeepImmutable<Color4>): boolean;
  63582. /**
  63583. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63584. * @param right defines the second operand
  63585. * @returns a new Color4 object
  63586. */
  63587. add(right: DeepImmutable<Color4>): Color4;
  63588. /**
  63589. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63590. * @param right defines the second operand
  63591. * @returns a new Color4 object
  63592. */
  63593. subtract(right: DeepImmutable<Color4>): Color4;
  63594. /**
  63595. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63596. * @param right defines the second operand
  63597. * @param result defines the Color4 object where to store the result
  63598. * @returns the current Color4 object
  63599. */
  63600. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63601. /**
  63602. * Creates a new Color4 with the current Color4 values multiplied by scale
  63603. * @param scale defines the scaling factor to apply
  63604. * @returns a new Color4 object
  63605. */
  63606. scale(scale: number): Color4;
  63607. /**
  63608. * Multiplies the current Color4 values by scale and stores the result in "result"
  63609. * @param scale defines the scaling factor to apply
  63610. * @param result defines the Color4 object where to store the result
  63611. * @returns the current unmodified Color4
  63612. */
  63613. scaleToRef(scale: number, result: Color4): Color4;
  63614. /**
  63615. * Scale the current Color4 values by a factor and add the result to a given Color4
  63616. * @param scale defines the scale factor
  63617. * @param result defines the Color4 object where to store the result
  63618. * @returns the unmodified current Color4
  63619. */
  63620. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63621. /**
  63622. * Clamps the rgb values by the min and max values and stores the result into "result"
  63623. * @param min defines minimum clamping value (default is 0)
  63624. * @param max defines maximum clamping value (default is 1)
  63625. * @param result defines color to store the result into.
  63626. * @returns the cuurent Color4
  63627. */
  63628. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63629. /**
  63630. * Multipy an Color4 value by another and return a new Color4 object
  63631. * @param color defines the Color4 value to multiply by
  63632. * @returns a new Color4 object
  63633. */
  63634. multiply(color: Color4): Color4;
  63635. /**
  63636. * Multipy a Color4 value by another and push the result in a reference value
  63637. * @param color defines the Color4 value to multiply by
  63638. * @param result defines the Color4 to fill the result in
  63639. * @returns the result Color4
  63640. */
  63641. multiplyToRef(color: Color4, result: Color4): Color4;
  63642. /**
  63643. * Creates a string with the Color4 current values
  63644. * @returns the string representation of the Color4 object
  63645. */
  63646. toString(): string;
  63647. /**
  63648. * Returns the string "Color4"
  63649. * @returns "Color4"
  63650. */
  63651. getClassName(): string;
  63652. /**
  63653. * Compute the Color4 hash code
  63654. * @returns an unique number that can be used to hash Color4 objects
  63655. */
  63656. getHashCode(): number;
  63657. /**
  63658. * Creates a new Color4 copied from the current one
  63659. * @returns a new Color4 object
  63660. */
  63661. clone(): Color4;
  63662. /**
  63663. * Copies the given Color4 values into the current one
  63664. * @param source defines the source Color4 object
  63665. * @returns the current updated Color4 object
  63666. */
  63667. copyFrom(source: Color4): Color4;
  63668. /**
  63669. * Copies the given float values into the current one
  63670. * @param r defines the red component to read from
  63671. * @param g defines the green component to read from
  63672. * @param b defines the blue component to read from
  63673. * @param a defines the alpha component to read from
  63674. * @returns the current updated Color4 object
  63675. */
  63676. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63677. /**
  63678. * Copies the given float values into the current one
  63679. * @param r defines the red component to read from
  63680. * @param g defines the green component to read from
  63681. * @param b defines the blue component to read from
  63682. * @param a defines the alpha component to read from
  63683. * @returns the current updated Color4 object
  63684. */
  63685. set(r: number, g: number, b: number, a: number): Color4;
  63686. /**
  63687. * Compute the Color4 hexadecimal code as a string
  63688. * @returns a string containing the hexadecimal representation of the Color4 object
  63689. */
  63690. toHexString(): string;
  63691. /**
  63692. * Computes a new Color4 converted from the current one to linear space
  63693. * @returns a new Color4 object
  63694. */
  63695. toLinearSpace(): Color4;
  63696. /**
  63697. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63698. * @param convertedColor defines the Color4 object where to store the linear space version
  63699. * @returns the unmodified Color4
  63700. */
  63701. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63702. /**
  63703. * Computes a new Color4 converted from the current one to gamma space
  63704. * @returns a new Color4 object
  63705. */
  63706. toGammaSpace(): Color4;
  63707. /**
  63708. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63709. * @param convertedColor defines the Color4 object where to store the gamma space version
  63710. * @returns the unmodified Color4
  63711. */
  63712. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63713. /**
  63714. * Creates a new Color4 from the string containing valid hexadecimal values
  63715. * @param hex defines a string containing valid hexadecimal values
  63716. * @returns a new Color4 object
  63717. */
  63718. static FromHexString(hex: string): Color4;
  63719. /**
  63720. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63721. * @param left defines the start value
  63722. * @param right defines the end value
  63723. * @param amount defines the gradient factor
  63724. * @returns a new Color4 object
  63725. */
  63726. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63727. /**
  63728. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63729. * @param left defines the start value
  63730. * @param right defines the end value
  63731. * @param amount defines the gradient factor
  63732. * @param result defines the Color4 object where to store data
  63733. */
  63734. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63735. /**
  63736. * Creates a new Color4 from a Color3 and an alpha value
  63737. * @param color3 defines the source Color3 to read from
  63738. * @param alpha defines the alpha component (1.0 by default)
  63739. * @returns a new Color4 object
  63740. */
  63741. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63742. /**
  63743. * Creates a new Color4 from the starting index element of the given array
  63744. * @param array defines the source array to read from
  63745. * @param offset defines the offset in the source array
  63746. * @returns a new Color4 object
  63747. */
  63748. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63749. /**
  63750. * Creates a new Color3 from integer values (< 256)
  63751. * @param r defines the red component to read from (value between 0 and 255)
  63752. * @param g defines the green component to read from (value between 0 and 255)
  63753. * @param b defines the blue component to read from (value between 0 and 255)
  63754. * @param a defines the alpha component to read from (value between 0 and 255)
  63755. * @returns a new Color3 object
  63756. */
  63757. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63758. /**
  63759. * Check the content of a given array and convert it to an array containing RGBA data
  63760. * If the original array was already containing count * 4 values then it is returned directly
  63761. * @param colors defines the array to check
  63762. * @param count defines the number of RGBA data to expect
  63763. * @returns an array containing count * 4 values (RGBA)
  63764. */
  63765. static CheckColors4(colors: number[], count: number): number[];
  63766. }
  63767. /**
  63768. * Class representing a vector containing 2 coordinates
  63769. */
  63770. export class Vector2 {
  63771. /** defines the first coordinate */
  63772. x: number;
  63773. /** defines the second coordinate */
  63774. y: number;
  63775. /**
  63776. * Creates a new Vector2 from the given x and y coordinates
  63777. * @param x defines the first coordinate
  63778. * @param y defines the second coordinate
  63779. */
  63780. constructor(
  63781. /** defines the first coordinate */
  63782. x?: number,
  63783. /** defines the second coordinate */
  63784. y?: number);
  63785. /**
  63786. * Gets a string with the Vector2 coordinates
  63787. * @returns a string with the Vector2 coordinates
  63788. */
  63789. toString(): string;
  63790. /**
  63791. * Gets class name
  63792. * @returns the string "Vector2"
  63793. */
  63794. getClassName(): string;
  63795. /**
  63796. * Gets current vector hash code
  63797. * @returns the Vector2 hash code as a number
  63798. */
  63799. getHashCode(): number;
  63800. /**
  63801. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63802. * @param array defines the source array
  63803. * @param index defines the offset in source array
  63804. * @returns the current Vector2
  63805. */
  63806. toArray(array: FloatArray, index?: number): Vector2;
  63807. /**
  63808. * Copy the current vector to an array
  63809. * @returns a new array with 2 elements: the Vector2 coordinates.
  63810. */
  63811. asArray(): number[];
  63812. /**
  63813. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63814. * @param source defines the source Vector2
  63815. * @returns the current updated Vector2
  63816. */
  63817. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63818. /**
  63819. * Sets the Vector2 coordinates with the given floats
  63820. * @param x defines the first coordinate
  63821. * @param y defines the second coordinate
  63822. * @returns the current updated Vector2
  63823. */
  63824. copyFromFloats(x: number, y: number): Vector2;
  63825. /**
  63826. * Sets the Vector2 coordinates with the given floats
  63827. * @param x defines the first coordinate
  63828. * @param y defines the second coordinate
  63829. * @returns the current updated Vector2
  63830. */
  63831. set(x: number, y: number): Vector2;
  63832. /**
  63833. * Add another vector with the current one
  63834. * @param otherVector defines the other vector
  63835. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63836. */
  63837. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63838. /**
  63839. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63840. * @param otherVector defines the other vector
  63841. * @param result defines the target vector
  63842. * @returns the unmodified current Vector2
  63843. */
  63844. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63845. /**
  63846. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63847. * @param otherVector defines the other vector
  63848. * @returns the current updated Vector2
  63849. */
  63850. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63851. /**
  63852. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63853. * @param otherVector defines the other vector
  63854. * @returns a new Vector2
  63855. */
  63856. addVector3(otherVector: Vector3): Vector2;
  63857. /**
  63858. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63859. * @param otherVector defines the other vector
  63860. * @returns a new Vector2
  63861. */
  63862. subtract(otherVector: Vector2): Vector2;
  63863. /**
  63864. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63865. * @param otherVector defines the other vector
  63866. * @param result defines the target vector
  63867. * @returns the unmodified current Vector2
  63868. */
  63869. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63870. /**
  63871. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63872. * @param otherVector defines the other vector
  63873. * @returns the current updated Vector2
  63874. */
  63875. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63876. /**
  63877. * Multiplies in place the current Vector2 coordinates by the given ones
  63878. * @param otherVector defines the other vector
  63879. * @returns the current updated Vector2
  63880. */
  63881. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63882. /**
  63883. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63884. * @param otherVector defines the other vector
  63885. * @returns a new Vector2
  63886. */
  63887. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63888. /**
  63889. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63890. * @param otherVector defines the other vector
  63891. * @param result defines the target vector
  63892. * @returns the unmodified current Vector2
  63893. */
  63894. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63895. /**
  63896. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63897. * @param x defines the first coordinate
  63898. * @param y defines the second coordinate
  63899. * @returns a new Vector2
  63900. */
  63901. multiplyByFloats(x: number, y: number): Vector2;
  63902. /**
  63903. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63904. * @param otherVector defines the other vector
  63905. * @returns a new Vector2
  63906. */
  63907. divide(otherVector: Vector2): Vector2;
  63908. /**
  63909. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63910. * @param otherVector defines the other vector
  63911. * @param result defines the target vector
  63912. * @returns the unmodified current Vector2
  63913. */
  63914. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63915. /**
  63916. * Divides the current Vector2 coordinates by the given ones
  63917. * @param otherVector defines the other vector
  63918. * @returns the current updated Vector2
  63919. */
  63920. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63921. /**
  63922. * Gets a new Vector2 with current Vector2 negated coordinates
  63923. * @returns a new Vector2
  63924. */
  63925. negate(): Vector2;
  63926. /**
  63927. * Multiply the Vector2 coordinates by scale
  63928. * @param scale defines the scaling factor
  63929. * @returns the current updated Vector2
  63930. */
  63931. scaleInPlace(scale: number): Vector2;
  63932. /**
  63933. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63934. * @param scale defines the scaling factor
  63935. * @returns a new Vector2
  63936. */
  63937. scale(scale: number): Vector2;
  63938. /**
  63939. * Scale the current Vector2 values by a factor to a given Vector2
  63940. * @param scale defines the scale factor
  63941. * @param result defines the Vector2 object where to store the result
  63942. * @returns the unmodified current Vector2
  63943. */
  63944. scaleToRef(scale: number, result: Vector2): Vector2;
  63945. /**
  63946. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63947. * @param scale defines the scale factor
  63948. * @param result defines the Vector2 object where to store the result
  63949. * @returns the unmodified current Vector2
  63950. */
  63951. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63952. /**
  63953. * Gets a boolean if two vectors are equals
  63954. * @param otherVector defines the other vector
  63955. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63956. */
  63957. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63958. /**
  63959. * Gets a boolean if two vectors are equals (using an epsilon value)
  63960. * @param otherVector defines the other vector
  63961. * @param epsilon defines the minimal distance to consider equality
  63962. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63963. */
  63964. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63965. /**
  63966. * Gets a new Vector2 from current Vector2 floored values
  63967. * @returns a new Vector2
  63968. */
  63969. floor(): Vector2;
  63970. /**
  63971. * Gets a new Vector2 from current Vector2 floored values
  63972. * @returns a new Vector2
  63973. */
  63974. fract(): Vector2;
  63975. /**
  63976. * Gets the length of the vector
  63977. * @returns the vector length (float)
  63978. */
  63979. length(): number;
  63980. /**
  63981. * Gets the vector squared length
  63982. * @returns the vector squared length (float)
  63983. */
  63984. lengthSquared(): number;
  63985. /**
  63986. * Normalize the vector
  63987. * @returns the current updated Vector2
  63988. */
  63989. normalize(): Vector2;
  63990. /**
  63991. * Gets a new Vector2 copied from the Vector2
  63992. * @returns a new Vector2
  63993. */
  63994. clone(): Vector2;
  63995. /**
  63996. * Gets a new Vector2(0, 0)
  63997. * @returns a new Vector2
  63998. */
  63999. static Zero(): Vector2;
  64000. /**
  64001. * Gets a new Vector2(1, 1)
  64002. * @returns a new Vector2
  64003. */
  64004. static One(): Vector2;
  64005. /**
  64006. * Gets a new Vector2 set from the given index element of the given array
  64007. * @param array defines the data source
  64008. * @param offset defines the offset in the data source
  64009. * @returns a new Vector2
  64010. */
  64011. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  64012. /**
  64013. * Sets "result" from the given index element of the given array
  64014. * @param array defines the data source
  64015. * @param offset defines the offset in the data source
  64016. * @param result defines the target vector
  64017. */
  64018. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  64019. /**
  64020. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  64021. * @param value1 defines 1st point of control
  64022. * @param value2 defines 2nd point of control
  64023. * @param value3 defines 3rd point of control
  64024. * @param value4 defines 4th point of control
  64025. * @param amount defines the interpolation factor
  64026. * @returns a new Vector2
  64027. */
  64028. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  64029. /**
  64030. * 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".
  64031. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  64032. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  64033. * @param value defines the value to clamp
  64034. * @param min defines the lower limit
  64035. * @param max defines the upper limit
  64036. * @returns a new Vector2
  64037. */
  64038. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  64039. /**
  64040. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  64041. * @param value1 defines the 1st control point
  64042. * @param tangent1 defines the outgoing tangent
  64043. * @param value2 defines the 2nd control point
  64044. * @param tangent2 defines the incoming tangent
  64045. * @param amount defines the interpolation factor
  64046. * @returns a new Vector2
  64047. */
  64048. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  64049. /**
  64050. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  64051. * @param start defines the start vector
  64052. * @param end defines the end vector
  64053. * @param amount defines the interpolation factor
  64054. * @returns a new Vector2
  64055. */
  64056. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  64057. /**
  64058. * Gets the dot product of the vector "left" and the vector "right"
  64059. * @param left defines first vector
  64060. * @param right defines second vector
  64061. * @returns the dot product (float)
  64062. */
  64063. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  64064. /**
  64065. * Returns a new Vector2 equal to the normalized given vector
  64066. * @param vector defines the vector to normalize
  64067. * @returns a new Vector2
  64068. */
  64069. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  64070. /**
  64071. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  64072. * @param left defines 1st vector
  64073. * @param right defines 2nd vector
  64074. * @returns a new Vector2
  64075. */
  64076. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64077. /**
  64078. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  64079. * @param left defines 1st vector
  64080. * @param right defines 2nd vector
  64081. * @returns a new Vector2
  64082. */
  64083. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64084. /**
  64085. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  64086. * @param vector defines the vector to transform
  64087. * @param transformation defines the matrix to apply
  64088. * @returns a new Vector2
  64089. */
  64090. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  64091. /**
  64092. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  64093. * @param vector defines the vector to transform
  64094. * @param transformation defines the matrix to apply
  64095. * @param result defines the target vector
  64096. */
  64097. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  64098. /**
  64099. * Determines if a given vector is included in a triangle
  64100. * @param p defines the vector to test
  64101. * @param p0 defines 1st triangle point
  64102. * @param p1 defines 2nd triangle point
  64103. * @param p2 defines 3rd triangle point
  64104. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  64105. */
  64106. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  64107. /**
  64108. * Gets the distance between the vectors "value1" and "value2"
  64109. * @param value1 defines first vector
  64110. * @param value2 defines second vector
  64111. * @returns the distance between vectors
  64112. */
  64113. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64114. /**
  64115. * Returns the squared distance between the vectors "value1" and "value2"
  64116. * @param value1 defines first vector
  64117. * @param value2 defines second vector
  64118. * @returns the squared distance between vectors
  64119. */
  64120. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64121. /**
  64122. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  64123. * @param value1 defines first vector
  64124. * @param value2 defines second vector
  64125. * @returns a new Vector2
  64126. */
  64127. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  64128. /**
  64129. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  64130. * @param p defines the middle point
  64131. * @param segA defines one point of the segment
  64132. * @param segB defines the other point of the segment
  64133. * @returns the shortest distance
  64134. */
  64135. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  64136. }
  64137. /**
  64138. * Classed used to store (x,y,z) vector representation
  64139. * A Vector3 is the main object used in 3D geometry
  64140. * It can represent etiher the coordinates of a point the space, either a direction
  64141. * Reminder: js uses a left handed forward facing system
  64142. */
  64143. export class Vector3 {
  64144. /**
  64145. * Defines the first coordinates (on X axis)
  64146. */
  64147. x: number;
  64148. /**
  64149. * Defines the second coordinates (on Y axis)
  64150. */
  64151. y: number;
  64152. /**
  64153. * Defines the third coordinates (on Z axis)
  64154. */
  64155. z: number;
  64156. private static _UpReadOnly;
  64157. private static _ZeroReadOnly;
  64158. /**
  64159. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  64160. * @param x defines the first coordinates (on X axis)
  64161. * @param y defines the second coordinates (on Y axis)
  64162. * @param z defines the third coordinates (on Z axis)
  64163. */
  64164. constructor(
  64165. /**
  64166. * Defines the first coordinates (on X axis)
  64167. */
  64168. x?: number,
  64169. /**
  64170. * Defines the second coordinates (on Y axis)
  64171. */
  64172. y?: number,
  64173. /**
  64174. * Defines the third coordinates (on Z axis)
  64175. */
  64176. z?: number);
  64177. /**
  64178. * Creates a string representation of the Vector3
  64179. * @returns a string with the Vector3 coordinates.
  64180. */
  64181. toString(): string;
  64182. /**
  64183. * Gets the class name
  64184. * @returns the string "Vector3"
  64185. */
  64186. getClassName(): string;
  64187. /**
  64188. * Creates the Vector3 hash code
  64189. * @returns a number which tends to be unique between Vector3 instances
  64190. */
  64191. getHashCode(): number;
  64192. /**
  64193. * Creates an array containing three elements : the coordinates of the Vector3
  64194. * @returns a new array of numbers
  64195. */
  64196. asArray(): number[];
  64197. /**
  64198. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  64199. * @param array defines the destination array
  64200. * @param index defines the offset in the destination array
  64201. * @returns the current Vector3
  64202. */
  64203. toArray(array: FloatArray, index?: number): Vector3;
  64204. /**
  64205. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  64206. * @returns a new Quaternion object, computed from the Vector3 coordinates
  64207. */
  64208. toQuaternion(): Quaternion;
  64209. /**
  64210. * Adds the given vector to the current Vector3
  64211. * @param otherVector defines the second operand
  64212. * @returns the current updated Vector3
  64213. */
  64214. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64215. /**
  64216. * Adds the given coordinates to the current Vector3
  64217. * @param x defines the x coordinate of the operand
  64218. * @param y defines the y coordinate of the operand
  64219. * @param z defines the z coordinate of the operand
  64220. * @returns the current updated Vector3
  64221. */
  64222. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64223. /**
  64224. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  64225. * @param otherVector defines the second operand
  64226. * @returns the resulting Vector3
  64227. */
  64228. add(otherVector: DeepImmutable<Vector3>): Vector3;
  64229. /**
  64230. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  64231. * @param otherVector defines the second operand
  64232. * @param result defines the Vector3 object where to store the result
  64233. * @returns the current Vector3
  64234. */
  64235. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64236. /**
  64237. * Subtract the given vector from the current Vector3
  64238. * @param otherVector defines the second operand
  64239. * @returns the current updated Vector3
  64240. */
  64241. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64242. /**
  64243. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  64244. * @param otherVector defines the second operand
  64245. * @returns the resulting Vector3
  64246. */
  64247. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  64248. /**
  64249. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  64250. * @param otherVector defines the second operand
  64251. * @param result defines the Vector3 object where to store the result
  64252. * @returns the current Vector3
  64253. */
  64254. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64255. /**
  64256. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  64257. * @param x defines the x coordinate of the operand
  64258. * @param y defines the y coordinate of the operand
  64259. * @param z defines the z coordinate of the operand
  64260. * @returns the resulting Vector3
  64261. */
  64262. subtractFromFloats(x: number, y: number, z: number): Vector3;
  64263. /**
  64264. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  64265. * @param x defines the x coordinate of the operand
  64266. * @param y defines the y coordinate of the operand
  64267. * @param z defines the z coordinate of the operand
  64268. * @param result defines the Vector3 object where to store the result
  64269. * @returns the current Vector3
  64270. */
  64271. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  64272. /**
  64273. * Gets a new Vector3 set with the current Vector3 negated coordinates
  64274. * @returns a new Vector3
  64275. */
  64276. negate(): Vector3;
  64277. /**
  64278. * Multiplies the Vector3 coordinates by the float "scale"
  64279. * @param scale defines the multiplier factor
  64280. * @returns the current updated Vector3
  64281. */
  64282. scaleInPlace(scale: number): Vector3;
  64283. /**
  64284. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  64285. * @param scale defines the multiplier factor
  64286. * @returns a new Vector3
  64287. */
  64288. scale(scale: number): Vector3;
  64289. /**
  64290. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  64291. * @param scale defines the multiplier factor
  64292. * @param result defines the Vector3 object where to store the result
  64293. * @returns the current Vector3
  64294. */
  64295. scaleToRef(scale: number, result: Vector3): Vector3;
  64296. /**
  64297. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  64298. * @param scale defines the scale factor
  64299. * @param result defines the Vector3 object where to store the result
  64300. * @returns the unmodified current Vector3
  64301. */
  64302. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  64303. /**
  64304. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  64305. * @param otherVector defines the second operand
  64306. * @returns true if both vectors are equals
  64307. */
  64308. equals(otherVector: DeepImmutable<Vector3>): boolean;
  64309. /**
  64310. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64311. * @param otherVector defines the second operand
  64312. * @param epsilon defines the minimal distance to define values as equals
  64313. * @returns true if both vectors are distant less than epsilon
  64314. */
  64315. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64316. /**
  64317. * Returns true if the current Vector3 coordinates equals the given floats
  64318. * @param x defines the x coordinate of the operand
  64319. * @param y defines the y coordinate of the operand
  64320. * @param z defines the z coordinate of the operand
  64321. * @returns true if both vectors are equals
  64322. */
  64323. equalsToFloats(x: number, y: number, z: number): boolean;
  64324. /**
  64325. * Multiplies the current Vector3 coordinates by the given ones
  64326. * @param otherVector defines the second operand
  64327. * @returns the current updated Vector3
  64328. */
  64329. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64330. /**
  64331. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64332. * @param otherVector defines the second operand
  64333. * @returns the new Vector3
  64334. */
  64335. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64336. /**
  64337. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64338. * @param otherVector defines the second operand
  64339. * @param result defines the Vector3 object where to store the result
  64340. * @returns the current Vector3
  64341. */
  64342. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64343. /**
  64344. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64345. * @param x defines the x coordinate of the operand
  64346. * @param y defines the y coordinate of the operand
  64347. * @param z defines the z coordinate of the operand
  64348. * @returns the new Vector3
  64349. */
  64350. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64351. /**
  64352. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64353. * @param otherVector defines the second operand
  64354. * @returns the new Vector3
  64355. */
  64356. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64357. /**
  64358. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64359. * @param otherVector defines the second operand
  64360. * @param result defines the Vector3 object where to store the result
  64361. * @returns the current Vector3
  64362. */
  64363. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64364. /**
  64365. * Divides the current Vector3 coordinates by the given ones.
  64366. * @param otherVector defines the second operand
  64367. * @returns the current updated Vector3
  64368. */
  64369. divideInPlace(otherVector: Vector3): Vector3;
  64370. /**
  64371. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64372. * @param other defines the second operand
  64373. * @returns the current updated Vector3
  64374. */
  64375. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64376. /**
  64377. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64378. * @param other defines the second operand
  64379. * @returns the current updated Vector3
  64380. */
  64381. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64382. /**
  64383. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64384. * @param x defines the x coordinate of the operand
  64385. * @param y defines the y coordinate of the operand
  64386. * @param z defines the z coordinate of the operand
  64387. * @returns the current updated Vector3
  64388. */
  64389. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64390. /**
  64391. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64392. * @param x defines the x coordinate of the operand
  64393. * @param y defines the y coordinate of the operand
  64394. * @param z defines the z coordinate of the operand
  64395. * @returns the current updated Vector3
  64396. */
  64397. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64398. /**
  64399. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64400. * Check if is non uniform within a certain amount of decimal places to account for this
  64401. * @param epsilon the amount the values can differ
  64402. * @returns if the the vector is non uniform to a certain number of decimal places
  64403. */
  64404. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64405. /**
  64406. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64407. */
  64408. readonly isNonUniform: boolean;
  64409. /**
  64410. * Gets a new Vector3 from current Vector3 floored values
  64411. * @returns a new Vector3
  64412. */
  64413. floor(): Vector3;
  64414. /**
  64415. * Gets a new Vector3 from current Vector3 floored values
  64416. * @returns a new Vector3
  64417. */
  64418. fract(): Vector3;
  64419. /**
  64420. * Gets the length of the Vector3
  64421. * @returns the length of the Vector3
  64422. */
  64423. length(): number;
  64424. /**
  64425. * Gets the squared length of the Vector3
  64426. * @returns squared length of the Vector3
  64427. */
  64428. lengthSquared(): number;
  64429. /**
  64430. * Normalize the current Vector3.
  64431. * Please note that this is an in place operation.
  64432. * @returns the current updated Vector3
  64433. */
  64434. normalize(): Vector3;
  64435. /**
  64436. * Reorders the x y z properties of the vector in place
  64437. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64438. * @returns the current updated vector
  64439. */
  64440. reorderInPlace(order: string): this;
  64441. /**
  64442. * Rotates the vector around 0,0,0 by a quaternion
  64443. * @param quaternion the rotation quaternion
  64444. * @param result vector to store the result
  64445. * @returns the resulting vector
  64446. */
  64447. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64448. /**
  64449. * Rotates a vector around a given point
  64450. * @param quaternion the rotation quaternion
  64451. * @param point the point to rotate around
  64452. * @param result vector to store the result
  64453. * @returns the resulting vector
  64454. */
  64455. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64456. /**
  64457. * Normalize the current Vector3 with the given input length.
  64458. * Please note that this is an in place operation.
  64459. * @param len the length of the vector
  64460. * @returns the current updated Vector3
  64461. */
  64462. normalizeFromLength(len: number): Vector3;
  64463. /**
  64464. * Normalize the current Vector3 to a new vector
  64465. * @returns the new Vector3
  64466. */
  64467. normalizeToNew(): Vector3;
  64468. /**
  64469. * Normalize the current Vector3 to the reference
  64470. * @param reference define the Vector3 to update
  64471. * @returns the updated Vector3
  64472. */
  64473. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64474. /**
  64475. * Creates a new Vector3 copied from the current Vector3
  64476. * @returns the new Vector3
  64477. */
  64478. clone(): Vector3;
  64479. /**
  64480. * Copies the given vector coordinates to the current Vector3 ones
  64481. * @param source defines the source Vector3
  64482. * @returns the current updated Vector3
  64483. */
  64484. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64485. /**
  64486. * Copies the given floats to the current Vector3 coordinates
  64487. * @param x defines the x coordinate of the operand
  64488. * @param y defines the y coordinate of the operand
  64489. * @param z defines the z coordinate of the operand
  64490. * @returns the current updated Vector3
  64491. */
  64492. copyFromFloats(x: number, y: number, z: number): Vector3;
  64493. /**
  64494. * Copies the given floats to the current Vector3 coordinates
  64495. * @param x defines the x coordinate of the operand
  64496. * @param y defines the y coordinate of the operand
  64497. * @param z defines the z coordinate of the operand
  64498. * @returns the current updated Vector3
  64499. */
  64500. set(x: number, y: number, z: number): Vector3;
  64501. /**
  64502. * Copies the given float to the current Vector3 coordinates
  64503. * @param v defines the x, y and z coordinates of the operand
  64504. * @returns the current updated Vector3
  64505. */
  64506. setAll(v: number): Vector3;
  64507. /**
  64508. * Get the clip factor between two vectors
  64509. * @param vector0 defines the first operand
  64510. * @param vector1 defines the second operand
  64511. * @param axis defines the axis to use
  64512. * @param size defines the size along the axis
  64513. * @returns the clip factor
  64514. */
  64515. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64516. /**
  64517. * Get angle between two vectors
  64518. * @param vector0 angle between vector0 and vector1
  64519. * @param vector1 angle between vector0 and vector1
  64520. * @param normal direction of the normal
  64521. * @return the angle between vector0 and vector1
  64522. */
  64523. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64524. /**
  64525. * Returns a new Vector3 set from the index "offset" of the given array
  64526. * @param array defines the source array
  64527. * @param offset defines the offset in the source array
  64528. * @returns the new Vector3
  64529. */
  64530. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64531. /**
  64532. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64533. * This function is deprecated. Use FromArray instead
  64534. * @param array defines the source array
  64535. * @param offset defines the offset in the source array
  64536. * @returns the new Vector3
  64537. */
  64538. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64539. /**
  64540. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64541. * @param array defines the source array
  64542. * @param offset defines the offset in the source array
  64543. * @param result defines the Vector3 where to store the result
  64544. */
  64545. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64546. /**
  64547. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64548. * This function is deprecated. Use FromArrayToRef instead.
  64549. * @param array defines the source array
  64550. * @param offset defines the offset in the source array
  64551. * @param result defines the Vector3 where to store the result
  64552. */
  64553. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64554. /**
  64555. * Sets the given vector "result" with the given floats.
  64556. * @param x defines the x coordinate of the source
  64557. * @param y defines the y coordinate of the source
  64558. * @param z defines the z coordinate of the source
  64559. * @param result defines the Vector3 where to store the result
  64560. */
  64561. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64562. /**
  64563. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64564. * @returns a new empty Vector3
  64565. */
  64566. static Zero(): Vector3;
  64567. /**
  64568. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64569. * @returns a new unit Vector3
  64570. */
  64571. static One(): Vector3;
  64572. /**
  64573. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64574. * @returns a new up Vector3
  64575. */
  64576. static Up(): Vector3;
  64577. /**
  64578. * Gets a up Vector3 that must not be updated
  64579. */
  64580. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64581. /**
  64582. * Gets a zero Vector3 that must not be updated
  64583. */
  64584. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64585. /**
  64586. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64587. * @returns a new down Vector3
  64588. */
  64589. static Down(): Vector3;
  64590. /**
  64591. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64592. * @returns a new forward Vector3
  64593. */
  64594. static Forward(): Vector3;
  64595. /**
  64596. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64597. * @returns a new forward Vector3
  64598. */
  64599. static Backward(): Vector3;
  64600. /**
  64601. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64602. * @returns a new right Vector3
  64603. */
  64604. static Right(): Vector3;
  64605. /**
  64606. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64607. * @returns a new left Vector3
  64608. */
  64609. static Left(): Vector3;
  64610. /**
  64611. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64612. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64613. * @param vector defines the Vector3 to transform
  64614. * @param transformation defines the transformation matrix
  64615. * @returns the transformed Vector3
  64616. */
  64617. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64618. /**
  64619. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64620. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64621. * @param vector defines the Vector3 to transform
  64622. * @param transformation defines the transformation matrix
  64623. * @param result defines the Vector3 where to store the result
  64624. */
  64625. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64626. /**
  64627. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64628. * This method computes tranformed coordinates only, not transformed direction vectors
  64629. * @param x define the x coordinate of the source vector
  64630. * @param y define the y coordinate of the source vector
  64631. * @param z define the z coordinate of the source vector
  64632. * @param transformation defines the transformation matrix
  64633. * @param result defines the Vector3 where to store the result
  64634. */
  64635. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64636. /**
  64637. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64638. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64639. * @param vector defines the Vector3 to transform
  64640. * @param transformation defines the transformation matrix
  64641. * @returns the new Vector3
  64642. */
  64643. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64644. /**
  64645. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64646. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64647. * @param vector defines the Vector3 to transform
  64648. * @param transformation defines the transformation matrix
  64649. * @param result defines the Vector3 where to store the result
  64650. */
  64651. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64652. /**
  64653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64654. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64655. * @param x define the x coordinate of the source vector
  64656. * @param y define the y coordinate of the source vector
  64657. * @param z define the z coordinate of the source vector
  64658. * @param transformation defines the transformation matrix
  64659. * @param result defines the Vector3 where to store the result
  64660. */
  64661. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64662. /**
  64663. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64664. * @param value1 defines the first control point
  64665. * @param value2 defines the second control point
  64666. * @param value3 defines the third control point
  64667. * @param value4 defines the fourth control point
  64668. * @param amount defines the amount on the spline to use
  64669. * @returns the new Vector3
  64670. */
  64671. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64672. /**
  64673. * 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"
  64674. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64675. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64676. * @param value defines the current value
  64677. * @param min defines the lower range value
  64678. * @param max defines the upper range value
  64679. * @returns the new Vector3
  64680. */
  64681. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64682. /**
  64683. * 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"
  64684. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64685. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64686. * @param value defines the current value
  64687. * @param min defines the lower range value
  64688. * @param max defines the upper range value
  64689. * @param result defines the Vector3 where to store the result
  64690. */
  64691. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64692. /**
  64693. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64694. * @param value1 defines the first control point
  64695. * @param tangent1 defines the first tangent vector
  64696. * @param value2 defines the second control point
  64697. * @param tangent2 defines the second tangent vector
  64698. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64699. * @returns the new Vector3
  64700. */
  64701. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64702. /**
  64703. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64704. * @param start defines the start value
  64705. * @param end defines the end value
  64706. * @param amount max defines amount between both (between 0 and 1)
  64707. * @returns the new Vector3
  64708. */
  64709. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64710. /**
  64711. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64712. * @param start defines the start value
  64713. * @param end defines the end value
  64714. * @param amount max defines amount between both (between 0 and 1)
  64715. * @param result defines the Vector3 where to store the result
  64716. */
  64717. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64718. /**
  64719. * Returns the dot product (float) between the vectors "left" and "right"
  64720. * @param left defines the left operand
  64721. * @param right defines the right operand
  64722. * @returns the dot product
  64723. */
  64724. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64725. /**
  64726. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64727. * The cross product is then orthogonal to both "left" and "right"
  64728. * @param left defines the left operand
  64729. * @param right defines the right operand
  64730. * @returns the cross product
  64731. */
  64732. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64733. /**
  64734. * Sets the given vector "result" with the cross product of "left" and "right"
  64735. * The cross product is then orthogonal to both "left" and "right"
  64736. * @param left defines the left operand
  64737. * @param right defines the right operand
  64738. * @param result defines the Vector3 where to store the result
  64739. */
  64740. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64741. /**
  64742. * Returns a new Vector3 as the normalization of the given vector
  64743. * @param vector defines the Vector3 to normalize
  64744. * @returns the new Vector3
  64745. */
  64746. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64747. /**
  64748. * Sets the given vector "result" with the normalization of the given first vector
  64749. * @param vector defines the Vector3 to normalize
  64750. * @param result defines the Vector3 where to store the result
  64751. */
  64752. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64753. /**
  64754. * Project a Vector3 onto screen space
  64755. * @param vector defines the Vector3 to project
  64756. * @param world defines the world matrix to use
  64757. * @param transform defines the transform (view x projection) matrix to use
  64758. * @param viewport defines the screen viewport to use
  64759. * @returns the new Vector3
  64760. */
  64761. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64762. /** @hidden */
  64763. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64764. /**
  64765. * Unproject from screen space to object space
  64766. * @param source defines the screen space Vector3 to use
  64767. * @param viewportWidth defines the current width of the viewport
  64768. * @param viewportHeight defines the current height of the viewport
  64769. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64770. * @param transform defines the transform (view x projection) matrix to use
  64771. * @returns the new Vector3
  64772. */
  64773. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64774. /**
  64775. * Unproject from screen space to object space
  64776. * @param source defines the screen space Vector3 to use
  64777. * @param viewportWidth defines the current width of the viewport
  64778. * @param viewportHeight defines the current height of the viewport
  64779. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64780. * @param view defines the view matrix to use
  64781. * @param projection defines the projection matrix to use
  64782. * @returns the new Vector3
  64783. */
  64784. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64785. /**
  64786. * Unproject from screen space to object space
  64787. * @param source defines the screen space Vector3 to use
  64788. * @param viewportWidth defines the current width of the viewport
  64789. * @param viewportHeight defines the current height of the viewport
  64790. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64791. * @param view defines the view matrix to use
  64792. * @param projection defines the projection matrix to use
  64793. * @param result defines the Vector3 where to store the result
  64794. */
  64795. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64796. /**
  64797. * Unproject from screen space to object space
  64798. * @param sourceX defines the screen space x coordinate to use
  64799. * @param sourceY defines the screen space y coordinate to use
  64800. * @param sourceZ defines the screen space z coordinate to use
  64801. * @param viewportWidth defines the current width of the viewport
  64802. * @param viewportHeight defines the current height of the viewport
  64803. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64804. * @param view defines the view matrix to use
  64805. * @param projection defines the projection matrix to use
  64806. * @param result defines the Vector3 where to store the result
  64807. */
  64808. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64809. /**
  64810. * Gets the minimal coordinate values between two Vector3
  64811. * @param left defines the first operand
  64812. * @param right defines the second operand
  64813. * @returns the new Vector3
  64814. */
  64815. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64816. /**
  64817. * Gets the maximal coordinate values between two Vector3
  64818. * @param left defines the first operand
  64819. * @param right defines the second operand
  64820. * @returns the new Vector3
  64821. */
  64822. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64823. /**
  64824. * Returns the distance between the vectors "value1" and "value2"
  64825. * @param value1 defines the first operand
  64826. * @param value2 defines the second operand
  64827. * @returns the distance
  64828. */
  64829. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64830. /**
  64831. * Returns the squared distance between the vectors "value1" and "value2"
  64832. * @param value1 defines the first operand
  64833. * @param value2 defines the second operand
  64834. * @returns the squared distance
  64835. */
  64836. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64837. /**
  64838. * Returns a new Vector3 located at the center between "value1" and "value2"
  64839. * @param value1 defines the first operand
  64840. * @param value2 defines the second operand
  64841. * @returns the new Vector3
  64842. */
  64843. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64844. /**
  64845. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64846. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64847. * to something in order to rotate it from its local system to the given target system
  64848. * Note: axis1, axis2 and axis3 are normalized during this operation
  64849. * @param axis1 defines the first axis
  64850. * @param axis2 defines the second axis
  64851. * @param axis3 defines the third axis
  64852. * @returns a new Vector3
  64853. */
  64854. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64855. /**
  64856. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64857. * @param axis1 defines the first axis
  64858. * @param axis2 defines the second axis
  64859. * @param axis3 defines the third axis
  64860. * @param ref defines the Vector3 where to store the result
  64861. */
  64862. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64863. }
  64864. /**
  64865. * Vector4 class created for EulerAngle class conversion to Quaternion
  64866. */
  64867. export class Vector4 {
  64868. /** x value of the vector */
  64869. x: number;
  64870. /** y value of the vector */
  64871. y: number;
  64872. /** z value of the vector */
  64873. z: number;
  64874. /** w value of the vector */
  64875. w: number;
  64876. /**
  64877. * Creates a Vector4 object from the given floats.
  64878. * @param x x value of the vector
  64879. * @param y y value of the vector
  64880. * @param z z value of the vector
  64881. * @param w w value of the vector
  64882. */
  64883. constructor(
  64884. /** x value of the vector */
  64885. x: number,
  64886. /** y value of the vector */
  64887. y: number,
  64888. /** z value of the vector */
  64889. z: number,
  64890. /** w value of the vector */
  64891. w: number);
  64892. /**
  64893. * Returns the string with the Vector4 coordinates.
  64894. * @returns a string containing all the vector values
  64895. */
  64896. toString(): string;
  64897. /**
  64898. * Returns the string "Vector4".
  64899. * @returns "Vector4"
  64900. */
  64901. getClassName(): string;
  64902. /**
  64903. * Returns the Vector4 hash code.
  64904. * @returns a unique hash code
  64905. */
  64906. getHashCode(): number;
  64907. /**
  64908. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64909. * @returns the resulting array
  64910. */
  64911. asArray(): number[];
  64912. /**
  64913. * Populates the given array from the given index with the Vector4 coordinates.
  64914. * @param array array to populate
  64915. * @param index index of the array to start at (default: 0)
  64916. * @returns the Vector4.
  64917. */
  64918. toArray(array: FloatArray, index?: number): Vector4;
  64919. /**
  64920. * Adds the given vector to the current Vector4.
  64921. * @param otherVector the vector to add
  64922. * @returns the updated Vector4.
  64923. */
  64924. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64925. /**
  64926. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64927. * @param otherVector the vector to add
  64928. * @returns the resulting vector
  64929. */
  64930. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64931. /**
  64932. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64933. * @param otherVector the vector to add
  64934. * @param result the vector to store the result
  64935. * @returns the current Vector4.
  64936. */
  64937. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64938. /**
  64939. * Subtract in place the given vector from the current Vector4.
  64940. * @param otherVector the vector to subtract
  64941. * @returns the updated Vector4.
  64942. */
  64943. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64944. /**
  64945. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64946. * @param otherVector the vector to add
  64947. * @returns the new vector with the result
  64948. */
  64949. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64950. /**
  64951. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64952. * @param otherVector the vector to subtract
  64953. * @param result the vector to store the result
  64954. * @returns the current Vector4.
  64955. */
  64956. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64957. /**
  64958. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64959. */
  64960. /**
  64961. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64962. * @param x value to subtract
  64963. * @param y value to subtract
  64964. * @param z value to subtract
  64965. * @param w value to subtract
  64966. * @returns new vector containing the result
  64967. */
  64968. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64969. /**
  64970. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64971. * @param x value to subtract
  64972. * @param y value to subtract
  64973. * @param z value to subtract
  64974. * @param w value to subtract
  64975. * @param result the vector to store the result in
  64976. * @returns the current Vector4.
  64977. */
  64978. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64979. /**
  64980. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64981. * @returns a new vector with the negated values
  64982. */
  64983. negate(): Vector4;
  64984. /**
  64985. * Multiplies the current Vector4 coordinates by scale (float).
  64986. * @param scale the number to scale with
  64987. * @returns the updated Vector4.
  64988. */
  64989. scaleInPlace(scale: number): Vector4;
  64990. /**
  64991. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64992. * @param scale the number to scale with
  64993. * @returns a new vector with the result
  64994. */
  64995. scale(scale: number): Vector4;
  64996. /**
  64997. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64998. * @param scale the number to scale with
  64999. * @param result a vector to store the result in
  65000. * @returns the current Vector4.
  65001. */
  65002. scaleToRef(scale: number, result: Vector4): Vector4;
  65003. /**
  65004. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  65005. * @param scale defines the scale factor
  65006. * @param result defines the Vector4 object where to store the result
  65007. * @returns the unmodified current Vector4
  65008. */
  65009. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  65010. /**
  65011. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  65012. * @param otherVector the vector to compare against
  65013. * @returns true if they are equal
  65014. */
  65015. equals(otherVector: DeepImmutable<Vector4>): boolean;
  65016. /**
  65017. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  65018. * @param otherVector vector to compare against
  65019. * @param epsilon (Default: very small number)
  65020. * @returns true if they are equal
  65021. */
  65022. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  65023. /**
  65024. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  65025. * @param x x value to compare against
  65026. * @param y y value to compare against
  65027. * @param z z value to compare against
  65028. * @param w w value to compare against
  65029. * @returns true if equal
  65030. */
  65031. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  65032. /**
  65033. * Multiplies in place the current Vector4 by the given one.
  65034. * @param otherVector vector to multiple with
  65035. * @returns the updated Vector4.
  65036. */
  65037. multiplyInPlace(otherVector: Vector4): Vector4;
  65038. /**
  65039. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  65040. * @param otherVector vector to multiple with
  65041. * @returns resulting new vector
  65042. */
  65043. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  65044. /**
  65045. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  65046. * @param otherVector vector to multiple with
  65047. * @param result vector to store the result
  65048. * @returns the current Vector4.
  65049. */
  65050. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65051. /**
  65052. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  65053. * @param x x value multiply with
  65054. * @param y y value multiply with
  65055. * @param z z value multiply with
  65056. * @param w w value multiply with
  65057. * @returns resulting new vector
  65058. */
  65059. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  65060. /**
  65061. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  65062. * @param otherVector vector to devide with
  65063. * @returns resulting new vector
  65064. */
  65065. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  65066. /**
  65067. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  65068. * @param otherVector vector to devide with
  65069. * @param result vector to store the result
  65070. * @returns the current Vector4.
  65071. */
  65072. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65073. /**
  65074. * Divides the current Vector3 coordinates by the given ones.
  65075. * @param otherVector vector to devide with
  65076. * @returns the updated Vector3.
  65077. */
  65078. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65079. /**
  65080. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  65081. * @param other defines the second operand
  65082. * @returns the current updated Vector4
  65083. */
  65084. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65085. /**
  65086. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  65087. * @param other defines the second operand
  65088. * @returns the current updated Vector4
  65089. */
  65090. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65091. /**
  65092. * Gets a new Vector4 from current Vector4 floored values
  65093. * @returns a new Vector4
  65094. */
  65095. floor(): Vector4;
  65096. /**
  65097. * Gets a new Vector4 from current Vector3 floored values
  65098. * @returns a new Vector4
  65099. */
  65100. fract(): Vector4;
  65101. /**
  65102. * Returns the Vector4 length (float).
  65103. * @returns the length
  65104. */
  65105. length(): number;
  65106. /**
  65107. * Returns the Vector4 squared length (float).
  65108. * @returns the length squared
  65109. */
  65110. lengthSquared(): number;
  65111. /**
  65112. * Normalizes in place the Vector4.
  65113. * @returns the updated Vector4.
  65114. */
  65115. normalize(): Vector4;
  65116. /**
  65117. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  65118. * @returns this converted to a new vector3
  65119. */
  65120. toVector3(): Vector3;
  65121. /**
  65122. * Returns a new Vector4 copied from the current one.
  65123. * @returns the new cloned vector
  65124. */
  65125. clone(): Vector4;
  65126. /**
  65127. * Updates the current Vector4 with the given one coordinates.
  65128. * @param source the source vector to copy from
  65129. * @returns the updated Vector4.
  65130. */
  65131. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  65132. /**
  65133. * Updates the current Vector4 coordinates with the given floats.
  65134. * @param x float to copy from
  65135. * @param y float to copy from
  65136. * @param z float to copy from
  65137. * @param w float to copy from
  65138. * @returns the updated Vector4.
  65139. */
  65140. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65141. /**
  65142. * Updates the current Vector4 coordinates with the given floats.
  65143. * @param x float to set from
  65144. * @param y float to set from
  65145. * @param z float to set from
  65146. * @param w float to set from
  65147. * @returns the updated Vector4.
  65148. */
  65149. set(x: number, y: number, z: number, w: number): Vector4;
  65150. /**
  65151. * Copies the given float to the current Vector3 coordinates
  65152. * @param v defines the x, y, z and w coordinates of the operand
  65153. * @returns the current updated Vector3
  65154. */
  65155. setAll(v: number): Vector4;
  65156. /**
  65157. * Returns a new Vector4 set from the starting index of the given array.
  65158. * @param array the array to pull values from
  65159. * @param offset the offset into the array to start at
  65160. * @returns the new vector
  65161. */
  65162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  65163. /**
  65164. * Updates the given vector "result" from the starting index of the given array.
  65165. * @param array the array to pull values from
  65166. * @param offset the offset into the array to start at
  65167. * @param result the vector to store the result in
  65168. */
  65169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  65170. /**
  65171. * Updates the given vector "result" from the starting index of the given Float32Array.
  65172. * @param array the array to pull values from
  65173. * @param offset the offset into the array to start at
  65174. * @param result the vector to store the result in
  65175. */
  65176. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  65177. /**
  65178. * Updates the given vector "result" coordinates from the given floats.
  65179. * @param x float to set from
  65180. * @param y float to set from
  65181. * @param z float to set from
  65182. * @param w float to set from
  65183. * @param result the vector to the floats in
  65184. */
  65185. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  65186. /**
  65187. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  65188. * @returns the new vector
  65189. */
  65190. static Zero(): Vector4;
  65191. /**
  65192. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  65193. * @returns the new vector
  65194. */
  65195. static One(): Vector4;
  65196. /**
  65197. * Returns a new normalized Vector4 from the given one.
  65198. * @param vector the vector to normalize
  65199. * @returns the vector
  65200. */
  65201. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  65202. /**
  65203. * Updates the given vector "result" from the normalization of the given one.
  65204. * @param vector the vector to normalize
  65205. * @param result the vector to store the result in
  65206. */
  65207. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  65208. /**
  65209. * Returns a vector with the minimum values from the left and right vectors
  65210. * @param left left vector to minimize
  65211. * @param right right vector to minimize
  65212. * @returns a new vector with the minimum of the left and right vector values
  65213. */
  65214. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65215. /**
  65216. * Returns a vector with the maximum values from the left and right vectors
  65217. * @param left left vector to maximize
  65218. * @param right right vector to maximize
  65219. * @returns a new vector with the maximum of the left and right vector values
  65220. */
  65221. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65222. /**
  65223. * Returns the distance (float) between the vectors "value1" and "value2".
  65224. * @param value1 value to calulate the distance between
  65225. * @param value2 value to calulate the distance between
  65226. * @return the distance between the two vectors
  65227. */
  65228. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65229. /**
  65230. * Returns the squared distance (float) between the vectors "value1" and "value2".
  65231. * @param value1 value to calulate the distance between
  65232. * @param value2 value to calulate the distance between
  65233. * @return the distance between the two vectors squared
  65234. */
  65235. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65236. /**
  65237. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  65238. * @param value1 value to calulate the center between
  65239. * @param value2 value to calulate the center between
  65240. * @return the center between the two vectors
  65241. */
  65242. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  65243. /**
  65244. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  65245. * This methods computes transformed normalized direction vectors only.
  65246. * @param vector the vector to transform
  65247. * @param transformation the transformation matrix to apply
  65248. * @returns the new vector
  65249. */
  65250. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  65251. /**
  65252. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  65253. * This methods computes transformed normalized direction vectors only.
  65254. * @param vector the vector to transform
  65255. * @param transformation the transformation matrix to apply
  65256. * @param result the vector to store the result in
  65257. */
  65258. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65259. /**
  65260. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  65261. * This methods computes transformed normalized direction vectors only.
  65262. * @param x value to transform
  65263. * @param y value to transform
  65264. * @param z value to transform
  65265. * @param w value to transform
  65266. * @param transformation the transformation matrix to apply
  65267. * @param result the vector to store the results in
  65268. */
  65269. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65270. /**
  65271. * Creates a new Vector4 from a Vector3
  65272. * @param source defines the source data
  65273. * @param w defines the 4th component (default is 0)
  65274. * @returns a new Vector4
  65275. */
  65276. static FromVector3(source: Vector3, w?: number): Vector4;
  65277. }
  65278. /**
  65279. * Interface for the size containing width and height
  65280. */
  65281. export interface ISize {
  65282. /**
  65283. * Width
  65284. */
  65285. width: number;
  65286. /**
  65287. * Heighht
  65288. */
  65289. height: number;
  65290. }
  65291. /**
  65292. * Size containing widht and height
  65293. */
  65294. export class Size implements ISize {
  65295. /**
  65296. * Width
  65297. */
  65298. width: number;
  65299. /**
  65300. * Height
  65301. */
  65302. height: number;
  65303. /**
  65304. * Creates a Size object from the given width and height (floats).
  65305. * @param width width of the new size
  65306. * @param height height of the new size
  65307. */
  65308. constructor(width: number, height: number);
  65309. /**
  65310. * Returns a string with the Size width and height
  65311. * @returns a string with the Size width and height
  65312. */
  65313. toString(): string;
  65314. /**
  65315. * "Size"
  65316. * @returns the string "Size"
  65317. */
  65318. getClassName(): string;
  65319. /**
  65320. * Returns the Size hash code.
  65321. * @returns a hash code for a unique width and height
  65322. */
  65323. getHashCode(): number;
  65324. /**
  65325. * Updates the current size from the given one.
  65326. * @param src the given size
  65327. */
  65328. copyFrom(src: Size): void;
  65329. /**
  65330. * Updates in place the current Size from the given floats.
  65331. * @param width width of the new size
  65332. * @param height height of the new size
  65333. * @returns the updated Size.
  65334. */
  65335. copyFromFloats(width: number, height: number): Size;
  65336. /**
  65337. * Updates in place the current Size from the given floats.
  65338. * @param width width to set
  65339. * @param height height to set
  65340. * @returns the updated Size.
  65341. */
  65342. set(width: number, height: number): Size;
  65343. /**
  65344. * Multiplies the width and height by numbers
  65345. * @param w factor to multiple the width by
  65346. * @param h factor to multiple the height by
  65347. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65348. */
  65349. multiplyByFloats(w: number, h: number): Size;
  65350. /**
  65351. * Clones the size
  65352. * @returns a new Size copied from the given one.
  65353. */
  65354. clone(): Size;
  65355. /**
  65356. * True if the current Size and the given one width and height are strictly equal.
  65357. * @param other the other size to compare against
  65358. * @returns True if the current Size and the given one width and height are strictly equal.
  65359. */
  65360. equals(other: Size): boolean;
  65361. /**
  65362. * The surface of the Size : width * height (float).
  65363. */
  65364. readonly surface: number;
  65365. /**
  65366. * Create a new size of zero
  65367. * @returns a new Size set to (0.0, 0.0)
  65368. */
  65369. static Zero(): Size;
  65370. /**
  65371. * Sums the width and height of two sizes
  65372. * @param otherSize size to add to this size
  65373. * @returns a new Size set as the addition result of the current Size and the given one.
  65374. */
  65375. add(otherSize: Size): Size;
  65376. /**
  65377. * Subtracts the width and height of two
  65378. * @param otherSize size to subtract to this size
  65379. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65380. */
  65381. subtract(otherSize: Size): Size;
  65382. /**
  65383. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65384. * @param start starting size to lerp between
  65385. * @param end end size to lerp between
  65386. * @param amount amount to lerp between the start and end values
  65387. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65388. */
  65389. static Lerp(start: Size, end: Size, amount: number): Size;
  65390. }
  65391. /**
  65392. * Class used to store quaternion data
  65393. * @see https://en.wikipedia.org/wiki/Quaternion
  65394. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65395. */
  65396. export class Quaternion {
  65397. /** defines the first component (0 by default) */
  65398. x: number;
  65399. /** defines the second component (0 by default) */
  65400. y: number;
  65401. /** defines the third component (0 by default) */
  65402. z: number;
  65403. /** defines the fourth component (1.0 by default) */
  65404. w: number;
  65405. /**
  65406. * Creates a new Quaternion from the given floats
  65407. * @param x defines the first component (0 by default)
  65408. * @param y defines the second component (0 by default)
  65409. * @param z defines the third component (0 by default)
  65410. * @param w defines the fourth component (1.0 by default)
  65411. */
  65412. constructor(
  65413. /** defines the first component (0 by default) */
  65414. x?: number,
  65415. /** defines the second component (0 by default) */
  65416. y?: number,
  65417. /** defines the third component (0 by default) */
  65418. z?: number,
  65419. /** defines the fourth component (1.0 by default) */
  65420. w?: number);
  65421. /**
  65422. * Gets a string representation for the current quaternion
  65423. * @returns a string with the Quaternion coordinates
  65424. */
  65425. toString(): string;
  65426. /**
  65427. * Gets the class name of the quaternion
  65428. * @returns the string "Quaternion"
  65429. */
  65430. getClassName(): string;
  65431. /**
  65432. * Gets a hash code for this quaternion
  65433. * @returns the quaternion hash code
  65434. */
  65435. getHashCode(): number;
  65436. /**
  65437. * Copy the quaternion to an array
  65438. * @returns a new array populated with 4 elements from the quaternion coordinates
  65439. */
  65440. asArray(): number[];
  65441. /**
  65442. * Check if two quaternions are equals
  65443. * @param otherQuaternion defines the second operand
  65444. * @return true if the current quaternion and the given one coordinates are strictly equals
  65445. */
  65446. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65447. /**
  65448. * Clone the current quaternion
  65449. * @returns a new quaternion copied from the current one
  65450. */
  65451. clone(): Quaternion;
  65452. /**
  65453. * Copy a quaternion to the current one
  65454. * @param other defines the other quaternion
  65455. * @returns the updated current quaternion
  65456. */
  65457. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65458. /**
  65459. * Updates the current quaternion with the given float coordinates
  65460. * @param x defines the x coordinate
  65461. * @param y defines the y coordinate
  65462. * @param z defines the z coordinate
  65463. * @param w defines the w coordinate
  65464. * @returns the updated current quaternion
  65465. */
  65466. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65467. /**
  65468. * Updates the current quaternion from the given float coordinates
  65469. * @param x defines the x coordinate
  65470. * @param y defines the y coordinate
  65471. * @param z defines the z coordinate
  65472. * @param w defines the w coordinate
  65473. * @returns the updated current quaternion
  65474. */
  65475. set(x: number, y: number, z: number, w: number): Quaternion;
  65476. /**
  65477. * Adds two quaternions
  65478. * @param other defines the second operand
  65479. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65480. */
  65481. add(other: DeepImmutable<Quaternion>): Quaternion;
  65482. /**
  65483. * Add a quaternion to the current one
  65484. * @param other defines the quaternion to add
  65485. * @returns the current quaternion
  65486. */
  65487. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65488. /**
  65489. * Subtract two quaternions
  65490. * @param other defines the second operand
  65491. * @returns a new quaternion as the subtraction result of the given one from the current one
  65492. */
  65493. subtract(other: Quaternion): Quaternion;
  65494. /**
  65495. * Multiplies the current quaternion by a scale factor
  65496. * @param value defines the scale factor
  65497. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65498. */
  65499. scale(value: number): Quaternion;
  65500. /**
  65501. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65502. * @param scale defines the scale factor
  65503. * @param result defines the Quaternion object where to store the result
  65504. * @returns the unmodified current quaternion
  65505. */
  65506. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65507. /**
  65508. * Multiplies in place the current quaternion by a scale factor
  65509. * @param value defines the scale factor
  65510. * @returns the current modified quaternion
  65511. */
  65512. scaleInPlace(value: number): Quaternion;
  65513. /**
  65514. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65515. * @param scale defines the scale factor
  65516. * @param result defines the Quaternion object where to store the result
  65517. * @returns the unmodified current quaternion
  65518. */
  65519. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65520. /**
  65521. * Multiplies two quaternions
  65522. * @param q1 defines the second operand
  65523. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65524. */
  65525. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65526. /**
  65527. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65528. * @param q1 defines the second operand
  65529. * @param result defines the target quaternion
  65530. * @returns the current quaternion
  65531. */
  65532. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65533. /**
  65534. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65535. * @param q1 defines the second operand
  65536. * @returns the currentupdated quaternion
  65537. */
  65538. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65539. /**
  65540. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65541. * @param ref defines the target quaternion
  65542. * @returns the current quaternion
  65543. */
  65544. conjugateToRef(ref: Quaternion): Quaternion;
  65545. /**
  65546. * Conjugates in place (1-q) the current quaternion
  65547. * @returns the current updated quaternion
  65548. */
  65549. conjugateInPlace(): Quaternion;
  65550. /**
  65551. * Conjugates in place (1-q) the current quaternion
  65552. * @returns a new quaternion
  65553. */
  65554. conjugate(): Quaternion;
  65555. /**
  65556. * Gets length of current quaternion
  65557. * @returns the quaternion length (float)
  65558. */
  65559. length(): number;
  65560. /**
  65561. * Normalize in place the current quaternion
  65562. * @returns the current updated quaternion
  65563. */
  65564. normalize(): Quaternion;
  65565. /**
  65566. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65567. * @param order is a reserved parameter and is ignore for now
  65568. * @returns a new Vector3 containing the Euler angles
  65569. */
  65570. toEulerAngles(order?: string): Vector3;
  65571. /**
  65572. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65573. * @param result defines the vector which will be filled with the Euler angles
  65574. * @param order is a reserved parameter and is ignore for now
  65575. * @returns the current unchanged quaternion
  65576. */
  65577. toEulerAnglesToRef(result: Vector3): Quaternion;
  65578. /**
  65579. * Updates the given rotation matrix with the current quaternion values
  65580. * @param result defines the target matrix
  65581. * @returns the current unchanged quaternion
  65582. */
  65583. toRotationMatrix(result: Matrix): Quaternion;
  65584. /**
  65585. * Updates the current quaternion from the given rotation matrix values
  65586. * @param matrix defines the source matrix
  65587. * @returns the current updated quaternion
  65588. */
  65589. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65590. /**
  65591. * Creates a new quaternion from a rotation matrix
  65592. * @param matrix defines the source matrix
  65593. * @returns a new quaternion created from the given rotation matrix values
  65594. */
  65595. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65596. /**
  65597. * Updates the given quaternion with the given rotation matrix values
  65598. * @param matrix defines the source matrix
  65599. * @param result defines the target quaternion
  65600. */
  65601. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65602. /**
  65603. * Returns the dot product (float) between the quaternions "left" and "right"
  65604. * @param left defines the left operand
  65605. * @param right defines the right operand
  65606. * @returns the dot product
  65607. */
  65608. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65609. /**
  65610. * Checks if the two quaternions are close to each other
  65611. * @param quat0 defines the first quaternion to check
  65612. * @param quat1 defines the second quaternion to check
  65613. * @returns true if the two quaternions are close to each other
  65614. */
  65615. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65616. /**
  65617. * Creates an empty quaternion
  65618. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65619. */
  65620. static Zero(): Quaternion;
  65621. /**
  65622. * Inverse a given quaternion
  65623. * @param q defines the source quaternion
  65624. * @returns a new quaternion as the inverted current quaternion
  65625. */
  65626. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65627. /**
  65628. * Inverse a given quaternion
  65629. * @param q defines the source quaternion
  65630. * @param result the quaternion the result will be stored in
  65631. * @returns the result quaternion
  65632. */
  65633. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65634. /**
  65635. * Creates an identity quaternion
  65636. * @returns the identity quaternion
  65637. */
  65638. static Identity(): Quaternion;
  65639. /**
  65640. * Gets a boolean indicating if the given quaternion is identity
  65641. * @param quaternion defines the quaternion to check
  65642. * @returns true if the quaternion is identity
  65643. */
  65644. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65645. /**
  65646. * Creates a quaternion from a rotation around an axis
  65647. * @param axis defines the axis to use
  65648. * @param angle defines the angle to use
  65649. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65650. */
  65651. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65652. /**
  65653. * Creates a rotation around an axis and stores it into the given quaternion
  65654. * @param axis defines the axis to use
  65655. * @param angle defines the angle to use
  65656. * @param result defines the target quaternion
  65657. * @returns the target quaternion
  65658. */
  65659. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65660. /**
  65661. * Creates a new quaternion from data stored into an array
  65662. * @param array defines the data source
  65663. * @param offset defines the offset in the source array where the data starts
  65664. * @returns a new quaternion
  65665. */
  65666. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65667. /**
  65668. * Create a quaternion from Euler rotation angles
  65669. * @param x Pitch
  65670. * @param y Yaw
  65671. * @param z Roll
  65672. * @returns the new Quaternion
  65673. */
  65674. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65675. /**
  65676. * Updates a quaternion from Euler rotation angles
  65677. * @param x Pitch
  65678. * @param y Yaw
  65679. * @param z Roll
  65680. * @param result the quaternion to store the result
  65681. * @returns the updated quaternion
  65682. */
  65683. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65684. /**
  65685. * Create a quaternion from Euler rotation vector
  65686. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65687. * @returns the new Quaternion
  65688. */
  65689. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65690. /**
  65691. * Updates a quaternion from Euler rotation vector
  65692. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65693. * @param result the quaternion to store the result
  65694. * @returns the updated quaternion
  65695. */
  65696. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65697. /**
  65698. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65699. * @param yaw defines the rotation around Y axis
  65700. * @param pitch defines the rotation around X axis
  65701. * @param roll defines the rotation around Z axis
  65702. * @returns the new quaternion
  65703. */
  65704. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65705. /**
  65706. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65707. * @param yaw defines the rotation around Y axis
  65708. * @param pitch defines the rotation around X axis
  65709. * @param roll defines the rotation around Z axis
  65710. * @param result defines the target quaternion
  65711. */
  65712. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65713. /**
  65714. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65715. * @param alpha defines the rotation around first axis
  65716. * @param beta defines the rotation around second axis
  65717. * @param gamma defines the rotation around third axis
  65718. * @returns the new quaternion
  65719. */
  65720. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65721. /**
  65722. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65723. * @param alpha defines the rotation around first axis
  65724. * @param beta defines the rotation around second axis
  65725. * @param gamma defines the rotation around third axis
  65726. * @param result defines the target quaternion
  65727. */
  65728. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65729. /**
  65730. * 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)
  65731. * @param axis1 defines the first axis
  65732. * @param axis2 defines the second axis
  65733. * @param axis3 defines the third axis
  65734. * @returns the new quaternion
  65735. */
  65736. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65737. /**
  65738. * 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
  65739. * @param axis1 defines the first axis
  65740. * @param axis2 defines the second axis
  65741. * @param axis3 defines the third axis
  65742. * @param ref defines the target quaternion
  65743. */
  65744. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65745. /**
  65746. * Interpolates between two quaternions
  65747. * @param left defines first quaternion
  65748. * @param right defines second quaternion
  65749. * @param amount defines the gradient to use
  65750. * @returns the new interpolated quaternion
  65751. */
  65752. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65753. /**
  65754. * Interpolates between two quaternions and stores it into a target quaternion
  65755. * @param left defines first quaternion
  65756. * @param right defines second quaternion
  65757. * @param amount defines the gradient to use
  65758. * @param result defines the target quaternion
  65759. */
  65760. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65761. /**
  65762. * Interpolate between two quaternions using Hermite interpolation
  65763. * @param value1 defines first quaternion
  65764. * @param tangent1 defines the incoming tangent
  65765. * @param value2 defines second quaternion
  65766. * @param tangent2 defines the outgoing tangent
  65767. * @param amount defines the target quaternion
  65768. * @returns the new interpolated quaternion
  65769. */
  65770. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65771. }
  65772. /**
  65773. * Class used to store matrix data (4x4)
  65774. */
  65775. export class Matrix {
  65776. private static _updateFlagSeed;
  65777. private static _identityReadOnly;
  65778. private _isIdentity;
  65779. private _isIdentityDirty;
  65780. private _isIdentity3x2;
  65781. private _isIdentity3x2Dirty;
  65782. /**
  65783. * Gets the update flag of the matrix which is an unique number for the matrix.
  65784. * It will be incremented every time the matrix data change.
  65785. * You can use it to speed the comparison between two versions of the same matrix.
  65786. */
  65787. updateFlag: number;
  65788. private readonly _m;
  65789. /**
  65790. * Gets the internal data of the matrix
  65791. */
  65792. readonly m: DeepImmutable<Float32Array>;
  65793. /** @hidden */
  65794. _markAsUpdated(): void;
  65795. /** @hidden */
  65796. private _updateIdentityStatus;
  65797. /**
  65798. * Creates an empty matrix (filled with zeros)
  65799. */
  65800. constructor();
  65801. /**
  65802. * Check if the current matrix is identity
  65803. * @returns true is the matrix is the identity matrix
  65804. */
  65805. isIdentity(): boolean;
  65806. /**
  65807. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65808. * @returns true is the matrix is the identity matrix
  65809. */
  65810. isIdentityAs3x2(): boolean;
  65811. /**
  65812. * Gets the determinant of the matrix
  65813. * @returns the matrix determinant
  65814. */
  65815. determinant(): number;
  65816. /**
  65817. * Returns the matrix as a Float32Array
  65818. * @returns the matrix underlying array
  65819. */
  65820. toArray(): DeepImmutable<Float32Array>;
  65821. /**
  65822. * Returns the matrix as a Float32Array
  65823. * @returns the matrix underlying array.
  65824. */
  65825. asArray(): DeepImmutable<Float32Array>;
  65826. /**
  65827. * Inverts the current matrix in place
  65828. * @returns the current inverted matrix
  65829. */
  65830. invert(): Matrix;
  65831. /**
  65832. * Sets all the matrix elements to zero
  65833. * @returns the current matrix
  65834. */
  65835. reset(): Matrix;
  65836. /**
  65837. * Adds the current matrix with a second one
  65838. * @param other defines the matrix to add
  65839. * @returns a new matrix as the addition of the current matrix and the given one
  65840. */
  65841. add(other: DeepImmutable<Matrix>): Matrix;
  65842. /**
  65843. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65844. * @param other defines the matrix to add
  65845. * @param result defines the target matrix
  65846. * @returns the current matrix
  65847. */
  65848. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65849. /**
  65850. * Adds in place the given matrix to the current matrix
  65851. * @param other defines the second operand
  65852. * @returns the current updated matrix
  65853. */
  65854. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65855. /**
  65856. * Sets the given matrix to the current inverted Matrix
  65857. * @param other defines the target matrix
  65858. * @returns the unmodified current matrix
  65859. */
  65860. invertToRef(other: Matrix): Matrix;
  65861. /**
  65862. * add a value at the specified position in the current Matrix
  65863. * @param index the index of the value within the matrix. between 0 and 15.
  65864. * @param value the value to be added
  65865. * @returns the current updated matrix
  65866. */
  65867. addAtIndex(index: number, value: number): Matrix;
  65868. /**
  65869. * mutiply the specified position in the current Matrix by a value
  65870. * @param index the index of the value within the matrix. between 0 and 15.
  65871. * @param value the value to be added
  65872. * @returns the current updated matrix
  65873. */
  65874. multiplyAtIndex(index: number, value: number): Matrix;
  65875. /**
  65876. * Inserts the translation vector (using 3 floats) in the current matrix
  65877. * @param x defines the 1st component of the translation
  65878. * @param y defines the 2nd component of the translation
  65879. * @param z defines the 3rd component of the translation
  65880. * @returns the current updated matrix
  65881. */
  65882. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65883. /**
  65884. * Adds the translation vector (using 3 floats) in the current matrix
  65885. * @param x defines the 1st component of the translation
  65886. * @param y defines the 2nd component of the translation
  65887. * @param z defines the 3rd component of the translation
  65888. * @returns the current updated matrix
  65889. */
  65890. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65891. /**
  65892. * Inserts the translation vector in the current matrix
  65893. * @param vector3 defines the translation to insert
  65894. * @returns the current updated matrix
  65895. */
  65896. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65897. /**
  65898. * Gets the translation value of the current matrix
  65899. * @returns a new Vector3 as the extracted translation from the matrix
  65900. */
  65901. getTranslation(): Vector3;
  65902. /**
  65903. * Fill a Vector3 with the extracted translation from the matrix
  65904. * @param result defines the Vector3 where to store the translation
  65905. * @returns the current matrix
  65906. */
  65907. getTranslationToRef(result: Vector3): Matrix;
  65908. /**
  65909. * Remove rotation and scaling part from the matrix
  65910. * @returns the updated matrix
  65911. */
  65912. removeRotationAndScaling(): Matrix;
  65913. /**
  65914. * Multiply two matrices
  65915. * @param other defines the second operand
  65916. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65917. */
  65918. multiply(other: DeepImmutable<Matrix>): Matrix;
  65919. /**
  65920. * Copy the current matrix from the given one
  65921. * @param other defines the source matrix
  65922. * @returns the current updated matrix
  65923. */
  65924. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65925. /**
  65926. * Populates the given array from the starting index with the current matrix values
  65927. * @param array defines the target array
  65928. * @param offset defines the offset in the target array where to start storing values
  65929. * @returns the current matrix
  65930. */
  65931. copyToArray(array: Float32Array, offset?: number): Matrix;
  65932. /**
  65933. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65934. * @param other defines the second operand
  65935. * @param result defines the matrix where to store the multiplication
  65936. * @returns the current matrix
  65937. */
  65938. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65939. /**
  65940. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65941. * @param other defines the second operand
  65942. * @param result defines the array where to store the multiplication
  65943. * @param offset defines the offset in the target array where to start storing values
  65944. * @returns the current matrix
  65945. */
  65946. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65947. /**
  65948. * Check equality between this matrix and a second one
  65949. * @param value defines the second matrix to compare
  65950. * @returns true is the current matrix and the given one values are strictly equal
  65951. */
  65952. equals(value: DeepImmutable<Matrix>): boolean;
  65953. /**
  65954. * Clone the current matrix
  65955. * @returns a new matrix from the current matrix
  65956. */
  65957. clone(): Matrix;
  65958. /**
  65959. * Returns the name of the current matrix class
  65960. * @returns the string "Matrix"
  65961. */
  65962. getClassName(): string;
  65963. /**
  65964. * Gets the hash code of the current matrix
  65965. * @returns the hash code
  65966. */
  65967. getHashCode(): number;
  65968. /**
  65969. * Decomposes the current Matrix into a translation, rotation and scaling components
  65970. * @param scale defines the scale vector3 given as a reference to update
  65971. * @param rotation defines the rotation quaternion given as a reference to update
  65972. * @param translation defines the translation vector3 given as a reference to update
  65973. * @returns true if operation was successful
  65974. */
  65975. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65976. /**
  65977. * Gets specific row of the matrix
  65978. * @param index defines the number of the row to get
  65979. * @returns the index-th row of the current matrix as a new Vector4
  65980. */
  65981. getRow(index: number): Nullable<Vector4>;
  65982. /**
  65983. * Sets the index-th row of the current matrix to the vector4 values
  65984. * @param index defines the number of the row to set
  65985. * @param row defines the target vector4
  65986. * @returns the updated current matrix
  65987. */
  65988. setRow(index: number, row: Vector4): Matrix;
  65989. /**
  65990. * Compute the transpose of the matrix
  65991. * @returns the new transposed matrix
  65992. */
  65993. transpose(): Matrix;
  65994. /**
  65995. * Compute the transpose of the matrix and store it in a given matrix
  65996. * @param result defines the target matrix
  65997. * @returns the current matrix
  65998. */
  65999. transposeToRef(result: Matrix): Matrix;
  66000. /**
  66001. * Sets the index-th row of the current matrix with the given 4 x float values
  66002. * @param index defines the row index
  66003. * @param x defines the x component to set
  66004. * @param y defines the y component to set
  66005. * @param z defines the z component to set
  66006. * @param w defines the w component to set
  66007. * @returns the updated current matrix
  66008. */
  66009. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  66010. /**
  66011. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  66012. * @param scale defines the scale factor
  66013. * @returns a new matrix
  66014. */
  66015. scale(scale: number): Matrix;
  66016. /**
  66017. * Scale the current matrix values by a factor to a given result matrix
  66018. * @param scale defines the scale factor
  66019. * @param result defines the matrix to store the result
  66020. * @returns the current matrix
  66021. */
  66022. scaleToRef(scale: number, result: Matrix): Matrix;
  66023. /**
  66024. * Scale the current matrix values by a factor and add the result to a given matrix
  66025. * @param scale defines the scale factor
  66026. * @param result defines the Matrix to store the result
  66027. * @returns the current matrix
  66028. */
  66029. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  66030. /**
  66031. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  66032. * @param ref matrix to store the result
  66033. */
  66034. toNormalMatrix(ref: Matrix): void;
  66035. /**
  66036. * Gets only rotation part of the current matrix
  66037. * @returns a new matrix sets to the extracted rotation matrix from the current one
  66038. */
  66039. getRotationMatrix(): Matrix;
  66040. /**
  66041. * Extracts the rotation matrix from the current one and sets it as the given "result"
  66042. * @param result defines the target matrix to store data to
  66043. * @returns the current matrix
  66044. */
  66045. getRotationMatrixToRef(result: Matrix): Matrix;
  66046. /**
  66047. * Toggles model matrix from being right handed to left handed in place and vice versa
  66048. */
  66049. toggleModelMatrixHandInPlace(): void;
  66050. /**
  66051. * Toggles projection matrix from being right handed to left handed in place and vice versa
  66052. */
  66053. toggleProjectionMatrixHandInPlace(): void;
  66054. /**
  66055. * Creates a matrix from an array
  66056. * @param array defines the source array
  66057. * @param offset defines an offset in the source array
  66058. * @returns a new Matrix set from the starting index of the given array
  66059. */
  66060. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  66061. /**
  66062. * Copy the content of an array into a given matrix
  66063. * @param array defines the source array
  66064. * @param offset defines an offset in the source array
  66065. * @param result defines the target matrix
  66066. */
  66067. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  66068. /**
  66069. * Stores an array into a matrix after having multiplied each component by a given factor
  66070. * @param array defines the source array
  66071. * @param offset defines the offset in the source array
  66072. * @param scale defines the scaling factor
  66073. * @param result defines the target matrix
  66074. */
  66075. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  66076. /**
  66077. * Gets an identity matrix that must not be updated
  66078. */
  66079. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  66080. /**
  66081. * Stores a list of values (16) inside a given matrix
  66082. * @param initialM11 defines 1st value of 1st row
  66083. * @param initialM12 defines 2nd value of 1st row
  66084. * @param initialM13 defines 3rd value of 1st row
  66085. * @param initialM14 defines 4th value of 1st row
  66086. * @param initialM21 defines 1st value of 2nd row
  66087. * @param initialM22 defines 2nd value of 2nd row
  66088. * @param initialM23 defines 3rd value of 2nd row
  66089. * @param initialM24 defines 4th value of 2nd row
  66090. * @param initialM31 defines 1st value of 3rd row
  66091. * @param initialM32 defines 2nd value of 3rd row
  66092. * @param initialM33 defines 3rd value of 3rd row
  66093. * @param initialM34 defines 4th value of 3rd row
  66094. * @param initialM41 defines 1st value of 4th row
  66095. * @param initialM42 defines 2nd value of 4th row
  66096. * @param initialM43 defines 3rd value of 4th row
  66097. * @param initialM44 defines 4th value of 4th row
  66098. * @param result defines the target matrix
  66099. */
  66100. 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;
  66101. /**
  66102. * Creates new matrix from a list of values (16)
  66103. * @param initialM11 defines 1st value of 1st row
  66104. * @param initialM12 defines 2nd value of 1st row
  66105. * @param initialM13 defines 3rd value of 1st row
  66106. * @param initialM14 defines 4th value of 1st row
  66107. * @param initialM21 defines 1st value of 2nd row
  66108. * @param initialM22 defines 2nd value of 2nd row
  66109. * @param initialM23 defines 3rd value of 2nd row
  66110. * @param initialM24 defines 4th value of 2nd row
  66111. * @param initialM31 defines 1st value of 3rd row
  66112. * @param initialM32 defines 2nd value of 3rd row
  66113. * @param initialM33 defines 3rd value of 3rd row
  66114. * @param initialM34 defines 4th value of 3rd row
  66115. * @param initialM41 defines 1st value of 4th row
  66116. * @param initialM42 defines 2nd value of 4th row
  66117. * @param initialM43 defines 3rd value of 4th row
  66118. * @param initialM44 defines 4th value of 4th row
  66119. * @returns the new matrix
  66120. */
  66121. 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;
  66122. /**
  66123. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66124. * @param scale defines the scale vector3
  66125. * @param rotation defines the rotation quaternion
  66126. * @param translation defines the translation vector3
  66127. * @returns a new matrix
  66128. */
  66129. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  66130. /**
  66131. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66132. * @param scale defines the scale vector3
  66133. * @param rotation defines the rotation quaternion
  66134. * @param translation defines the translation vector3
  66135. * @param result defines the target matrix
  66136. */
  66137. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  66138. /**
  66139. * Creates a new identity matrix
  66140. * @returns a new identity matrix
  66141. */
  66142. static Identity(): Matrix;
  66143. /**
  66144. * Creates a new identity matrix and stores the result in a given matrix
  66145. * @param result defines the target matrix
  66146. */
  66147. static IdentityToRef(result: Matrix): void;
  66148. /**
  66149. * Creates a new zero matrix
  66150. * @returns a new zero matrix
  66151. */
  66152. static Zero(): Matrix;
  66153. /**
  66154. * Creates a new rotation matrix for "angle" radians around the X axis
  66155. * @param angle defines the angle (in radians) to use
  66156. * @return the new matrix
  66157. */
  66158. static RotationX(angle: number): Matrix;
  66159. /**
  66160. * Creates a new matrix as the invert of a given matrix
  66161. * @param source defines the source matrix
  66162. * @returns the new matrix
  66163. */
  66164. static Invert(source: DeepImmutable<Matrix>): Matrix;
  66165. /**
  66166. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  66167. * @param angle defines the angle (in radians) to use
  66168. * @param result defines the target matrix
  66169. */
  66170. static RotationXToRef(angle: number, result: Matrix): void;
  66171. /**
  66172. * Creates a new rotation matrix for "angle" radians around the Y axis
  66173. * @param angle defines the angle (in radians) to use
  66174. * @return the new matrix
  66175. */
  66176. static RotationY(angle: number): Matrix;
  66177. /**
  66178. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  66179. * @param angle defines the angle (in radians) to use
  66180. * @param result defines the target matrix
  66181. */
  66182. static RotationYToRef(angle: number, result: Matrix): void;
  66183. /**
  66184. * Creates a new rotation matrix for "angle" radians around the Z axis
  66185. * @param angle defines the angle (in radians) to use
  66186. * @return the new matrix
  66187. */
  66188. static RotationZ(angle: number): Matrix;
  66189. /**
  66190. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  66191. * @param angle defines the angle (in radians) to use
  66192. * @param result defines the target matrix
  66193. */
  66194. static RotationZToRef(angle: number, result: Matrix): void;
  66195. /**
  66196. * Creates a new rotation matrix for "angle" radians around the given axis
  66197. * @param axis defines the axis to use
  66198. * @param angle defines the angle (in radians) to use
  66199. * @return the new matrix
  66200. */
  66201. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  66202. /**
  66203. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  66204. * @param axis defines the axis to use
  66205. * @param angle defines the angle (in radians) to use
  66206. * @param result defines the target matrix
  66207. */
  66208. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  66209. /**
  66210. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  66211. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  66212. * @param from defines the vector to align
  66213. * @param to defines the vector to align to
  66214. * @param result defines the target matrix
  66215. */
  66216. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  66217. /**
  66218. * Creates a rotation matrix
  66219. * @param yaw defines the yaw angle in radians (Y axis)
  66220. * @param pitch defines the pitch angle in radians (X axis)
  66221. * @param roll defines the roll angle in radians (X axis)
  66222. * @returns the new rotation matrix
  66223. */
  66224. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  66225. /**
  66226. * Creates a rotation matrix and stores it in a given matrix
  66227. * @param yaw defines the yaw angle in radians (Y axis)
  66228. * @param pitch defines the pitch angle in radians (X axis)
  66229. * @param roll defines the roll angle in radians (X axis)
  66230. * @param result defines the target matrix
  66231. */
  66232. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  66233. /**
  66234. * Creates a scaling matrix
  66235. * @param x defines the scale factor on X axis
  66236. * @param y defines the scale factor on Y axis
  66237. * @param z defines the scale factor on Z axis
  66238. * @returns the new matrix
  66239. */
  66240. static Scaling(x: number, y: number, z: number): Matrix;
  66241. /**
  66242. * Creates a scaling matrix and stores it in a given matrix
  66243. * @param x defines the scale factor on X axis
  66244. * @param y defines the scale factor on Y axis
  66245. * @param z defines the scale factor on Z axis
  66246. * @param result defines the target matrix
  66247. */
  66248. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  66249. /**
  66250. * Creates a translation matrix
  66251. * @param x defines the translation on X axis
  66252. * @param y defines the translation on Y axis
  66253. * @param z defines the translationon Z axis
  66254. * @returns the new matrix
  66255. */
  66256. static Translation(x: number, y: number, z: number): Matrix;
  66257. /**
  66258. * Creates a translation matrix and stores it in a given matrix
  66259. * @param x defines the translation on X axis
  66260. * @param y defines the translation on Y axis
  66261. * @param z defines the translationon Z axis
  66262. * @param result defines the target matrix
  66263. */
  66264. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  66265. /**
  66266. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66267. * @param startValue defines the start value
  66268. * @param endValue defines the end value
  66269. * @param gradient defines the gradient factor
  66270. * @returns the new matrix
  66271. */
  66272. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66273. /**
  66274. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66275. * @param startValue defines the start value
  66276. * @param endValue defines the end value
  66277. * @param gradient defines the gradient factor
  66278. * @param result defines the Matrix object where to store data
  66279. */
  66280. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66281. /**
  66282. * Builds a new matrix whose values are computed by:
  66283. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66284. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66285. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66286. * @param startValue defines the first matrix
  66287. * @param endValue defines the second matrix
  66288. * @param gradient defines the gradient between the two matrices
  66289. * @returns the new matrix
  66290. */
  66291. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66292. /**
  66293. * Update a matrix to values which are computed by:
  66294. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66295. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66296. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66297. * @param startValue defines the first matrix
  66298. * @param endValue defines the second matrix
  66299. * @param gradient defines the gradient between the two matrices
  66300. * @param result defines the target matrix
  66301. */
  66302. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66303. /**
  66304. * 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"
  66305. * This function works in left handed mode
  66306. * @param eye defines the final position of the entity
  66307. * @param target defines where the entity should look at
  66308. * @param up defines the up vector for the entity
  66309. * @returns the new matrix
  66310. */
  66311. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66312. /**
  66313. * 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".
  66314. * This function works in left handed mode
  66315. * @param eye defines the final position of the entity
  66316. * @param target defines where the entity should look at
  66317. * @param up defines the up vector for the entity
  66318. * @param result defines the target matrix
  66319. */
  66320. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66321. /**
  66322. * 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"
  66323. * This function works in right handed mode
  66324. * @param eye defines the final position of the entity
  66325. * @param target defines where the entity should look at
  66326. * @param up defines the up vector for the entity
  66327. * @returns the new matrix
  66328. */
  66329. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66330. /**
  66331. * 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".
  66332. * This function works in right handed mode
  66333. * @param eye defines the final position of the entity
  66334. * @param target defines where the entity should look at
  66335. * @param up defines the up vector for the entity
  66336. * @param result defines the target matrix
  66337. */
  66338. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66339. /**
  66340. * Create a left-handed orthographic projection matrix
  66341. * @param width defines the viewport width
  66342. * @param height defines the viewport height
  66343. * @param znear defines the near clip plane
  66344. * @param zfar defines the far clip plane
  66345. * @returns a new matrix as a left-handed orthographic projection matrix
  66346. */
  66347. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66348. /**
  66349. * Store a left-handed orthographic projection to a given matrix
  66350. * @param width defines the viewport width
  66351. * @param height defines the viewport height
  66352. * @param znear defines the near clip plane
  66353. * @param zfar defines the far clip plane
  66354. * @param result defines the target matrix
  66355. */
  66356. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66357. /**
  66358. * Create a left-handed orthographic projection matrix
  66359. * @param left defines the viewport left coordinate
  66360. * @param right defines the viewport right coordinate
  66361. * @param bottom defines the viewport bottom coordinate
  66362. * @param top defines the viewport top coordinate
  66363. * @param znear defines the near clip plane
  66364. * @param zfar defines the far clip plane
  66365. * @returns a new matrix as a left-handed orthographic projection matrix
  66366. */
  66367. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66368. /**
  66369. * Stores a left-handed orthographic projection into a given matrix
  66370. * @param left defines the viewport left coordinate
  66371. * @param right defines the viewport right coordinate
  66372. * @param bottom defines the viewport bottom coordinate
  66373. * @param top defines the viewport top coordinate
  66374. * @param znear defines the near clip plane
  66375. * @param zfar defines the far clip plane
  66376. * @param result defines the target matrix
  66377. */
  66378. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66379. /**
  66380. * Creates a right-handed orthographic projection matrix
  66381. * @param left defines the viewport left coordinate
  66382. * @param right defines the viewport right coordinate
  66383. * @param bottom defines the viewport bottom coordinate
  66384. * @param top defines the viewport top coordinate
  66385. * @param znear defines the near clip plane
  66386. * @param zfar defines the far clip plane
  66387. * @returns a new matrix as a right-handed orthographic projection matrix
  66388. */
  66389. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66390. /**
  66391. * Stores a right-handed orthographic projection into a given matrix
  66392. * @param left defines the viewport left coordinate
  66393. * @param right defines the viewport right coordinate
  66394. * @param bottom defines the viewport bottom coordinate
  66395. * @param top defines the viewport top coordinate
  66396. * @param znear defines the near clip plane
  66397. * @param zfar defines the far clip plane
  66398. * @param result defines the target matrix
  66399. */
  66400. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66401. /**
  66402. * Creates a left-handed perspective projection matrix
  66403. * @param width defines the viewport width
  66404. * @param height defines the viewport height
  66405. * @param znear defines the near clip plane
  66406. * @param zfar defines the far clip plane
  66407. * @returns a new matrix as a left-handed perspective projection matrix
  66408. */
  66409. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66410. /**
  66411. * Creates a left-handed perspective projection matrix
  66412. * @param fov defines the horizontal field of view
  66413. * @param aspect defines the aspect ratio
  66414. * @param znear defines the near clip plane
  66415. * @param zfar defines the far clip plane
  66416. * @returns a new matrix as a left-handed perspective projection matrix
  66417. */
  66418. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66419. /**
  66420. * Stores a left-handed perspective projection into a given matrix
  66421. * @param fov defines the horizontal field of view
  66422. * @param aspect defines the aspect ratio
  66423. * @param znear defines the near clip plane
  66424. * @param zfar defines the far clip plane
  66425. * @param result defines the target matrix
  66426. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66427. */
  66428. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66429. /**
  66430. * Creates a right-handed perspective projection matrix
  66431. * @param fov defines the horizontal field of view
  66432. * @param aspect defines the aspect ratio
  66433. * @param znear defines the near clip plane
  66434. * @param zfar defines the far clip plane
  66435. * @returns a new matrix as a right-handed perspective projection matrix
  66436. */
  66437. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66438. /**
  66439. * Stores a right-handed perspective projection into a given matrix
  66440. * @param fov defines the horizontal field of view
  66441. * @param aspect defines the aspect ratio
  66442. * @param znear defines the near clip plane
  66443. * @param zfar defines the far clip plane
  66444. * @param result defines the target matrix
  66445. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66446. */
  66447. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66448. /**
  66449. * Stores a perspective projection for WebVR info a given matrix
  66450. * @param fov defines the field of view
  66451. * @param znear defines the near clip plane
  66452. * @param zfar defines the far clip plane
  66453. * @param result defines the target matrix
  66454. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66455. */
  66456. static PerspectiveFovWebVRToRef(fov: {
  66457. upDegrees: number;
  66458. downDegrees: number;
  66459. leftDegrees: number;
  66460. rightDegrees: number;
  66461. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66462. /**
  66463. * Computes a complete transformation matrix
  66464. * @param viewport defines the viewport to use
  66465. * @param world defines the world matrix
  66466. * @param view defines the view matrix
  66467. * @param projection defines the projection matrix
  66468. * @param zmin defines the near clip plane
  66469. * @param zmax defines the far clip plane
  66470. * @returns the transformation matrix
  66471. */
  66472. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66473. /**
  66474. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66475. * @param matrix defines the matrix to use
  66476. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66477. */
  66478. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66479. /**
  66480. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66481. * @param matrix defines the matrix to use
  66482. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66483. */
  66484. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66485. /**
  66486. * Compute the transpose of a given matrix
  66487. * @param matrix defines the matrix to transpose
  66488. * @returns the new matrix
  66489. */
  66490. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66491. /**
  66492. * Compute the transpose of a matrix and store it in a target matrix
  66493. * @param matrix defines the matrix to transpose
  66494. * @param result defines the target matrix
  66495. */
  66496. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66497. /**
  66498. * Computes a reflection matrix from a plane
  66499. * @param plane defines the reflection plane
  66500. * @returns a new matrix
  66501. */
  66502. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66503. /**
  66504. * Computes a reflection matrix from a plane
  66505. * @param plane defines the reflection plane
  66506. * @param result defines the target matrix
  66507. */
  66508. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66509. /**
  66510. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66511. * @param xaxis defines the value of the 1st axis
  66512. * @param yaxis defines the value of the 2nd axis
  66513. * @param zaxis defines the value of the 3rd axis
  66514. * @param result defines the target matrix
  66515. */
  66516. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66517. /**
  66518. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66519. * @param quat defines the quaternion to use
  66520. * @param result defines the target matrix
  66521. */
  66522. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66523. }
  66524. /**
  66525. * Represens a plane by the equation ax + by + cz + d = 0
  66526. */
  66527. export class Plane {
  66528. /**
  66529. * Normal of the plane (a,b,c)
  66530. */
  66531. normal: Vector3;
  66532. /**
  66533. * d component of the plane
  66534. */
  66535. d: number;
  66536. /**
  66537. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66538. * @param a a component of the plane
  66539. * @param b b component of the plane
  66540. * @param c c component of the plane
  66541. * @param d d component of the plane
  66542. */
  66543. constructor(a: number, b: number, c: number, d: number);
  66544. /**
  66545. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66546. */
  66547. asArray(): number[];
  66548. /**
  66549. * @returns a new plane copied from the current Plane.
  66550. */
  66551. clone(): Plane;
  66552. /**
  66553. * @returns the string "Plane".
  66554. */
  66555. getClassName(): string;
  66556. /**
  66557. * @returns the Plane hash code.
  66558. */
  66559. getHashCode(): number;
  66560. /**
  66561. * Normalize the current Plane in place.
  66562. * @returns the updated Plane.
  66563. */
  66564. normalize(): Plane;
  66565. /**
  66566. * Applies a transformation the plane and returns the result
  66567. * @param transformation the transformation matrix to be applied to the plane
  66568. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66569. */
  66570. transform(transformation: DeepImmutable<Matrix>): Plane;
  66571. /**
  66572. * Calcualtte the dot product between the point and the plane normal
  66573. * @param point point to calculate the dot product with
  66574. * @returns the dot product (float) of the point coordinates and the plane normal.
  66575. */
  66576. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66577. /**
  66578. * Updates the current Plane from the plane defined by the three given points.
  66579. * @param point1 one of the points used to contruct the plane
  66580. * @param point2 one of the points used to contruct the plane
  66581. * @param point3 one of the points used to contruct the plane
  66582. * @returns the updated Plane.
  66583. */
  66584. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66585. /**
  66586. * Checks if the plane is facing a given direction
  66587. * @param direction the direction to check if the plane is facing
  66588. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66589. * @returns True is the vector "direction" is the same side than the plane normal.
  66590. */
  66591. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66592. /**
  66593. * Calculates the distance to a point
  66594. * @param point point to calculate distance to
  66595. * @returns the signed distance (float) from the given point to the Plane.
  66596. */
  66597. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66598. /**
  66599. * Creates a plane from an array
  66600. * @param array the array to create a plane from
  66601. * @returns a new Plane from the given array.
  66602. */
  66603. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66604. /**
  66605. * Creates a plane from three points
  66606. * @param point1 point used to create the plane
  66607. * @param point2 point used to create the plane
  66608. * @param point3 point used to create the plane
  66609. * @returns a new Plane defined by the three given points.
  66610. */
  66611. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66612. /**
  66613. * Creates a plane from an origin point and a normal
  66614. * @param origin origin of the plane to be constructed
  66615. * @param normal normal of the plane to be constructed
  66616. * @returns a new Plane the normal vector to this plane at the given origin point.
  66617. * Note : the vector "normal" is updated because normalized.
  66618. */
  66619. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66620. /**
  66621. * Calculates the distance from a plane and a point
  66622. * @param origin origin of the plane to be constructed
  66623. * @param normal normal of the plane to be constructed
  66624. * @param point point to calculate distance to
  66625. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66626. */
  66627. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66628. }
  66629. /**
  66630. * Class used to represent a viewport on screen
  66631. */
  66632. export class Viewport {
  66633. /** viewport left coordinate */
  66634. x: number;
  66635. /** viewport top coordinate */
  66636. y: number;
  66637. /**viewport width */
  66638. width: number;
  66639. /** viewport height */
  66640. height: number;
  66641. /**
  66642. * Creates a Viewport object located at (x, y) and sized (width, height)
  66643. * @param x defines viewport left coordinate
  66644. * @param y defines viewport top coordinate
  66645. * @param width defines the viewport width
  66646. * @param height defines the viewport height
  66647. */
  66648. constructor(
  66649. /** viewport left coordinate */
  66650. x: number,
  66651. /** viewport top coordinate */
  66652. y: number,
  66653. /**viewport width */
  66654. width: number,
  66655. /** viewport height */
  66656. height: number);
  66657. /**
  66658. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66659. * @param renderWidth defines the rendering width
  66660. * @param renderHeight defines the rendering height
  66661. * @returns a new Viewport
  66662. */
  66663. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66664. /**
  66665. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66666. * @param renderWidth defines the rendering width
  66667. * @param renderHeight defines the rendering height
  66668. * @param ref defines the target viewport
  66669. * @returns the current viewport
  66670. */
  66671. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66672. /**
  66673. * Returns a new Viewport copied from the current one
  66674. * @returns a new Viewport
  66675. */
  66676. clone(): Viewport;
  66677. }
  66678. /**
  66679. * Reprasents a camera frustum
  66680. */
  66681. export class Frustum {
  66682. /**
  66683. * Gets the planes representing the frustum
  66684. * @param transform matrix to be applied to the returned planes
  66685. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66686. */
  66687. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66688. /**
  66689. * Gets the near frustum plane transformed by the transform matrix
  66690. * @param transform transformation matrix to be applied to the resulting frustum plane
  66691. * @param frustumPlane the resuling frustum plane
  66692. */
  66693. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66694. /**
  66695. * Gets the far frustum plane transformed by the transform matrix
  66696. * @param transform transformation matrix to be applied to the resulting frustum plane
  66697. * @param frustumPlane the resuling frustum plane
  66698. */
  66699. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66700. /**
  66701. * Gets the left frustum plane transformed by the transform matrix
  66702. * @param transform transformation matrix to be applied to the resulting frustum plane
  66703. * @param frustumPlane the resuling frustum plane
  66704. */
  66705. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66706. /**
  66707. * Gets the right frustum plane transformed by the transform matrix
  66708. * @param transform transformation matrix to be applied to the resulting frustum plane
  66709. * @param frustumPlane the resuling frustum plane
  66710. */
  66711. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66712. /**
  66713. * Gets the top frustum plane transformed by the transform matrix
  66714. * @param transform transformation matrix to be applied to the resulting frustum plane
  66715. * @param frustumPlane the resuling frustum plane
  66716. */
  66717. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66718. /**
  66719. * Gets the bottom frustum plane transformed by the transform matrix
  66720. * @param transform transformation matrix to be applied to the resulting frustum plane
  66721. * @param frustumPlane the resuling frustum plane
  66722. */
  66723. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66724. /**
  66725. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66726. * @param transform transformation matrix to be applied to the resulting frustum planes
  66727. * @param frustumPlanes the resuling frustum planes
  66728. */
  66729. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66730. }
  66731. /** Defines supported spaces */
  66732. export enum Space {
  66733. /** Local (object) space */
  66734. LOCAL = 0,
  66735. /** World space */
  66736. WORLD = 1,
  66737. /** Bone space */
  66738. BONE = 2
  66739. }
  66740. /** Defines the 3 main axes */
  66741. export class Axis {
  66742. /** X axis */
  66743. static X: Vector3;
  66744. /** Y axis */
  66745. static Y: Vector3;
  66746. /** Z axis */
  66747. static Z: Vector3;
  66748. }
  66749. /** Class used to represent a Bezier curve */
  66750. export class BezierCurve {
  66751. /**
  66752. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66753. * @param t defines the time
  66754. * @param x1 defines the left coordinate on X axis
  66755. * @param y1 defines the left coordinate on Y axis
  66756. * @param x2 defines the right coordinate on X axis
  66757. * @param y2 defines the right coordinate on Y axis
  66758. * @returns the interpolated value
  66759. */
  66760. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66761. }
  66762. /**
  66763. * Defines potential orientation for back face culling
  66764. */
  66765. export enum Orientation {
  66766. /**
  66767. * Clockwise
  66768. */
  66769. CW = 0,
  66770. /** Counter clockwise */
  66771. CCW = 1
  66772. }
  66773. /**
  66774. * Defines angle representation
  66775. */
  66776. export class Angle {
  66777. private _radians;
  66778. /**
  66779. * Creates an Angle object of "radians" radians (float).
  66780. * @param radians the angle in radians
  66781. */
  66782. constructor(radians: number);
  66783. /**
  66784. * Get value in degrees
  66785. * @returns the Angle value in degrees (float)
  66786. */
  66787. degrees(): number;
  66788. /**
  66789. * Get value in radians
  66790. * @returns the Angle value in radians (float)
  66791. */
  66792. radians(): number;
  66793. /**
  66794. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66795. * @param a defines first vector
  66796. * @param b defines second vector
  66797. * @returns a new Angle
  66798. */
  66799. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66800. /**
  66801. * Gets a new Angle object from the given float in radians
  66802. * @param radians defines the angle value in radians
  66803. * @returns a new Angle
  66804. */
  66805. static FromRadians(radians: number): Angle;
  66806. /**
  66807. * Gets a new Angle object from the given float in degrees
  66808. * @param degrees defines the angle value in degrees
  66809. * @returns a new Angle
  66810. */
  66811. static FromDegrees(degrees: number): Angle;
  66812. }
  66813. /**
  66814. * This represents an arc in a 2d space.
  66815. */
  66816. export class Arc2 {
  66817. /** Defines the start point of the arc */
  66818. startPoint: Vector2;
  66819. /** Defines the mid point of the arc */
  66820. midPoint: Vector2;
  66821. /** Defines the end point of the arc */
  66822. endPoint: Vector2;
  66823. /**
  66824. * Defines the center point of the arc.
  66825. */
  66826. centerPoint: Vector2;
  66827. /**
  66828. * Defines the radius of the arc.
  66829. */
  66830. radius: number;
  66831. /**
  66832. * Defines the angle of the arc (from mid point to end point).
  66833. */
  66834. angle: Angle;
  66835. /**
  66836. * Defines the start angle of the arc (from start point to middle point).
  66837. */
  66838. startAngle: Angle;
  66839. /**
  66840. * Defines the orientation of the arc (clock wise/counter clock wise).
  66841. */
  66842. orientation: Orientation;
  66843. /**
  66844. * Creates an Arc object from the three given points : start, middle and end.
  66845. * @param startPoint Defines the start point of the arc
  66846. * @param midPoint Defines the midlle point of the arc
  66847. * @param endPoint Defines the end point of the arc
  66848. */
  66849. constructor(
  66850. /** Defines the start point of the arc */
  66851. startPoint: Vector2,
  66852. /** Defines the mid point of the arc */
  66853. midPoint: Vector2,
  66854. /** Defines the end point of the arc */
  66855. endPoint: Vector2);
  66856. }
  66857. /**
  66858. * Represents a 2D path made up of multiple 2D points
  66859. */
  66860. export class Path2 {
  66861. private _points;
  66862. private _length;
  66863. /**
  66864. * If the path start and end point are the same
  66865. */
  66866. closed: boolean;
  66867. /**
  66868. * Creates a Path2 object from the starting 2D coordinates x and y.
  66869. * @param x the starting points x value
  66870. * @param y the starting points y value
  66871. */
  66872. constructor(x: number, y: number);
  66873. /**
  66874. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66875. * @param x the added points x value
  66876. * @param y the added points y value
  66877. * @returns the updated Path2.
  66878. */
  66879. addLineTo(x: number, y: number): Path2;
  66880. /**
  66881. * 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.
  66882. * @param midX middle point x value
  66883. * @param midY middle point y value
  66884. * @param endX end point x value
  66885. * @param endY end point y value
  66886. * @param numberOfSegments (default: 36)
  66887. * @returns the updated Path2.
  66888. */
  66889. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66890. /**
  66891. * Closes the Path2.
  66892. * @returns the Path2.
  66893. */
  66894. close(): Path2;
  66895. /**
  66896. * Gets the sum of the distance between each sequential point in the path
  66897. * @returns the Path2 total length (float).
  66898. */
  66899. length(): number;
  66900. /**
  66901. * Gets the points which construct the path
  66902. * @returns the Path2 internal array of points.
  66903. */
  66904. getPoints(): Vector2[];
  66905. /**
  66906. * Retreives the point at the distance aways from the starting point
  66907. * @param normalizedLengthPosition the length along the path to retreive the point from
  66908. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66909. */
  66910. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66911. /**
  66912. * Creates a new path starting from an x and y position
  66913. * @param x starting x value
  66914. * @param y starting y value
  66915. * @returns a new Path2 starting at the coordinates (x, y).
  66916. */
  66917. static StartingAt(x: number, y: number): Path2;
  66918. }
  66919. /**
  66920. * Represents a 3D path made up of multiple 3D points
  66921. */
  66922. export class Path3D {
  66923. /**
  66924. * an array of Vector3, the curve axis of the Path3D
  66925. */
  66926. path: Vector3[];
  66927. private _curve;
  66928. private _distances;
  66929. private _tangents;
  66930. private _normals;
  66931. private _binormals;
  66932. private _raw;
  66933. /**
  66934. * new Path3D(path, normal, raw)
  66935. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66936. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66937. * @param path an array of Vector3, the curve axis of the Path3D
  66938. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66939. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66940. */
  66941. constructor(
  66942. /**
  66943. * an array of Vector3, the curve axis of the Path3D
  66944. */
  66945. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66946. /**
  66947. * Returns the Path3D array of successive Vector3 designing its curve.
  66948. * @returns the Path3D array of successive Vector3 designing its curve.
  66949. */
  66950. getCurve(): Vector3[];
  66951. /**
  66952. * Returns an array populated with tangent vectors on each Path3D curve point.
  66953. * @returns an array populated with tangent vectors on each Path3D curve point.
  66954. */
  66955. getTangents(): Vector3[];
  66956. /**
  66957. * Returns an array populated with normal vectors on each Path3D curve point.
  66958. * @returns an array populated with normal vectors on each Path3D curve point.
  66959. */
  66960. getNormals(): Vector3[];
  66961. /**
  66962. * Returns an array populated with binormal vectors on each Path3D curve point.
  66963. * @returns an array populated with binormal vectors on each Path3D curve point.
  66964. */
  66965. getBinormals(): Vector3[];
  66966. /**
  66967. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66968. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66969. */
  66970. getDistances(): number[];
  66971. /**
  66972. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66973. * @param path path which all values are copied into the curves points
  66974. * @param firstNormal which should be projected onto the curve
  66975. * @returns the same object updated.
  66976. */
  66977. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66978. private _compute;
  66979. private _getFirstNonNullVector;
  66980. private _getLastNonNullVector;
  66981. private _normalVector;
  66982. }
  66983. /**
  66984. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66985. * A Curve3 is designed from a series of successive Vector3.
  66986. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66987. */
  66988. export class Curve3 {
  66989. private _points;
  66990. private _length;
  66991. /**
  66992. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66993. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66994. * @param v1 (Vector3) the control point
  66995. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66996. * @param nbPoints (integer) the wanted number of points in the curve
  66997. * @returns the created Curve3
  66998. */
  66999. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67000. /**
  67001. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  67002. * @param v0 (Vector3) the origin point of the Cubic Bezier
  67003. * @param v1 (Vector3) the first control point
  67004. * @param v2 (Vector3) the second control point
  67005. * @param v3 (Vector3) the end point of the Cubic Bezier
  67006. * @param nbPoints (integer) the wanted number of points in the curve
  67007. * @returns the created Curve3
  67008. */
  67009. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67010. /**
  67011. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  67012. * @param p1 (Vector3) the origin point of the Hermite Spline
  67013. * @param t1 (Vector3) the tangent vector at the origin point
  67014. * @param p2 (Vector3) the end point of the Hermite Spline
  67015. * @param t2 (Vector3) the tangent vector at the end point
  67016. * @param nbPoints (integer) the wanted number of points in the curve
  67017. * @returns the created Curve3
  67018. */
  67019. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  67020. /**
  67021. * Returns a Curve3 object along a CatmullRom Spline curve :
  67022. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  67023. * @param nbPoints (integer) the wanted number of points between each curve control points
  67024. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  67025. * @returns the created Curve3
  67026. */
  67027. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  67028. /**
  67029. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  67030. * A Curve3 is designed from a series of successive Vector3.
  67031. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  67032. * @param points points which make up the curve
  67033. */
  67034. constructor(points: Vector3[]);
  67035. /**
  67036. * @returns the Curve3 stored array of successive Vector3
  67037. */
  67038. getPoints(): Vector3[];
  67039. /**
  67040. * @returns the computed length (float) of the curve.
  67041. */
  67042. length(): number;
  67043. /**
  67044. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  67045. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  67046. * curveA and curveB keep unchanged.
  67047. * @param curve the curve to continue from this curve
  67048. * @returns the newly constructed curve
  67049. */
  67050. continue(curve: DeepImmutable<Curve3>): Curve3;
  67051. private _computeLength;
  67052. }
  67053. /**
  67054. * Contains position and normal vectors for a vertex
  67055. */
  67056. export class PositionNormalVertex {
  67057. /** the position of the vertex (defaut: 0,0,0) */
  67058. position: Vector3;
  67059. /** the normal of the vertex (defaut: 0,1,0) */
  67060. normal: Vector3;
  67061. /**
  67062. * Creates a PositionNormalVertex
  67063. * @param position the position of the vertex (defaut: 0,0,0)
  67064. * @param normal the normal of the vertex (defaut: 0,1,0)
  67065. */
  67066. constructor(
  67067. /** the position of the vertex (defaut: 0,0,0) */
  67068. position?: Vector3,
  67069. /** the normal of the vertex (defaut: 0,1,0) */
  67070. normal?: Vector3);
  67071. /**
  67072. * Clones the PositionNormalVertex
  67073. * @returns the cloned PositionNormalVertex
  67074. */
  67075. clone(): PositionNormalVertex;
  67076. }
  67077. /**
  67078. * Contains position, normal and uv vectors for a vertex
  67079. */
  67080. export class PositionNormalTextureVertex {
  67081. /** the position of the vertex (defaut: 0,0,0) */
  67082. position: Vector3;
  67083. /** the normal of the vertex (defaut: 0,1,0) */
  67084. normal: Vector3;
  67085. /** the uv of the vertex (default: 0,0) */
  67086. uv: Vector2;
  67087. /**
  67088. * Creates a PositionNormalTextureVertex
  67089. * @param position the position of the vertex (defaut: 0,0,0)
  67090. * @param normal the normal of the vertex (defaut: 0,1,0)
  67091. * @param uv the uv of the vertex (default: 0,0)
  67092. */
  67093. constructor(
  67094. /** the position of the vertex (defaut: 0,0,0) */
  67095. position?: Vector3,
  67096. /** the normal of the vertex (defaut: 0,1,0) */
  67097. normal?: Vector3,
  67098. /** the uv of the vertex (default: 0,0) */
  67099. uv?: Vector2);
  67100. /**
  67101. * Clones the PositionNormalTextureVertex
  67102. * @returns the cloned PositionNormalTextureVertex
  67103. */
  67104. clone(): PositionNormalTextureVertex;
  67105. }
  67106. /**
  67107. * @hidden
  67108. */
  67109. export class Tmp {
  67110. static Color3: Color3[];
  67111. static Color4: Color4[];
  67112. static Vector2: Vector2[];
  67113. static Vector3: Vector3[];
  67114. static Vector4: Vector4[];
  67115. static Quaternion: Quaternion[];
  67116. static Matrix: Matrix[];
  67117. }
  67118. }
  67119. declare module BABYLON {
  67120. /**
  67121. * Class used to enable access to offline support
  67122. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67123. */
  67124. export interface IOfflineProvider {
  67125. /**
  67126. * Gets a boolean indicating if scene must be saved in the database
  67127. */
  67128. enableSceneOffline: boolean;
  67129. /**
  67130. * Gets a boolean indicating if textures must be saved in the database
  67131. */
  67132. enableTexturesOffline: boolean;
  67133. /**
  67134. * Open the offline support and make it available
  67135. * @param successCallback defines the callback to call on success
  67136. * @param errorCallback defines the callback to call on error
  67137. */
  67138. open(successCallback: () => void, errorCallback: () => void): void;
  67139. /**
  67140. * Loads an image from the offline support
  67141. * @param url defines the url to load from
  67142. * @param image defines the target DOM image
  67143. */
  67144. loadImage(url: string, image: HTMLImageElement): void;
  67145. /**
  67146. * Loads a file from offline support
  67147. * @param url defines the URL to load from
  67148. * @param sceneLoaded defines a callback to call on success
  67149. * @param progressCallBack defines a callback to call when progress changed
  67150. * @param errorCallback defines a callback to call on error
  67151. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67152. */
  67153. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67154. }
  67155. }
  67156. declare module BABYLON {
  67157. /**
  67158. * A class serves as a medium between the observable and its observers
  67159. */
  67160. export class EventState {
  67161. /**
  67162. * Create a new EventState
  67163. * @param mask defines the mask associated with this state
  67164. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67165. * @param target defines the original target of the state
  67166. * @param currentTarget defines the current target of the state
  67167. */
  67168. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67169. /**
  67170. * Initialize the current event state
  67171. * @param mask defines the mask associated with this state
  67172. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67173. * @param target defines the original target of the state
  67174. * @param currentTarget defines the current target of the state
  67175. * @returns the current event state
  67176. */
  67177. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67178. /**
  67179. * An Observer can set this property to true to prevent subsequent observers of being notified
  67180. */
  67181. skipNextObservers: boolean;
  67182. /**
  67183. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67184. */
  67185. mask: number;
  67186. /**
  67187. * The object that originally notified the event
  67188. */
  67189. target?: any;
  67190. /**
  67191. * The current object in the bubbling phase
  67192. */
  67193. currentTarget?: any;
  67194. /**
  67195. * This will be populated with the return value of the last function that was executed.
  67196. * If it is the first function in the callback chain it will be the event data.
  67197. */
  67198. lastReturnValue?: any;
  67199. }
  67200. /**
  67201. * Represent an Observer registered to a given Observable object.
  67202. */
  67203. export class Observer<T> {
  67204. /**
  67205. * Defines the callback to call when the observer is notified
  67206. */
  67207. callback: (eventData: T, eventState: EventState) => void;
  67208. /**
  67209. * Defines the mask of the observer (used to filter notifications)
  67210. */
  67211. mask: number;
  67212. /**
  67213. * Defines the current scope used to restore the JS context
  67214. */
  67215. scope: any;
  67216. /** @hidden */
  67217. _willBeUnregistered: boolean;
  67218. /**
  67219. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67220. */
  67221. unregisterOnNextCall: boolean;
  67222. /**
  67223. * Creates a new observer
  67224. * @param callback defines the callback to call when the observer is notified
  67225. * @param mask defines the mask of the observer (used to filter notifications)
  67226. * @param scope defines the current scope used to restore the JS context
  67227. */
  67228. constructor(
  67229. /**
  67230. * Defines the callback to call when the observer is notified
  67231. */
  67232. callback: (eventData: T, eventState: EventState) => void,
  67233. /**
  67234. * Defines the mask of the observer (used to filter notifications)
  67235. */
  67236. mask: number,
  67237. /**
  67238. * Defines the current scope used to restore the JS context
  67239. */
  67240. scope?: any);
  67241. }
  67242. /**
  67243. * Represent a list of observers registered to multiple Observables object.
  67244. */
  67245. export class MultiObserver<T> {
  67246. private _observers;
  67247. private _observables;
  67248. /**
  67249. * Release associated resources
  67250. */
  67251. dispose(): void;
  67252. /**
  67253. * Raise a callback when one of the observable will notify
  67254. * @param observables defines a list of observables to watch
  67255. * @param callback defines the callback to call on notification
  67256. * @param mask defines the mask used to filter notifications
  67257. * @param scope defines the current scope used to restore the JS context
  67258. * @returns the new MultiObserver
  67259. */
  67260. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67261. }
  67262. /**
  67263. * The Observable class is a simple implementation of the Observable pattern.
  67264. *
  67265. * 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.
  67266. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67267. * 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).
  67268. * 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.
  67269. */
  67270. export class Observable<T> {
  67271. private _observers;
  67272. private _eventState;
  67273. private _onObserverAdded;
  67274. /**
  67275. * Creates a new observable
  67276. * @param onObserverAdded defines a callback to call when a new observer is added
  67277. */
  67278. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67279. /**
  67280. * Create a new Observer with the specified callback
  67281. * @param callback the callback that will be executed for that Observer
  67282. * @param mask the mask used to filter observers
  67283. * @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.
  67284. * @param scope optional scope for the callback to be called from
  67285. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67286. * @returns the new observer created for the callback
  67287. */
  67288. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67289. /**
  67290. * Create a new Observer with the specified callback and unregisters after the next notification
  67291. * @param callback the callback that will be executed for that Observer
  67292. * @returns the new observer created for the callback
  67293. */
  67294. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67295. /**
  67296. * Remove an Observer from the Observable object
  67297. * @param observer the instance of the Observer to remove
  67298. * @returns false if it doesn't belong to this Observable
  67299. */
  67300. remove(observer: Nullable<Observer<T>>): boolean;
  67301. /**
  67302. * Remove a callback from the Observable object
  67303. * @param callback the callback to remove
  67304. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67305. * @returns false if it doesn't belong to this Observable
  67306. */
  67307. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67308. private _deferUnregister;
  67309. private _remove;
  67310. /**
  67311. * Moves the observable to the top of the observer list making it get called first when notified
  67312. * @param observer the observer to move
  67313. */
  67314. makeObserverTopPriority(observer: Observer<T>): void;
  67315. /**
  67316. * Moves the observable to the bottom of the observer list making it get called last when notified
  67317. * @param observer the observer to move
  67318. */
  67319. makeObserverBottomPriority(observer: Observer<T>): void;
  67320. /**
  67321. * Notify all Observers by calling their respective callback with the given data
  67322. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67323. * @param eventData defines the data to send to all observers
  67324. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67325. * @param target defines the original target of the state
  67326. * @param currentTarget defines the current target of the state
  67327. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67328. */
  67329. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67330. /**
  67331. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67332. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67333. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67334. * and it is crucial that all callbacks will be executed.
  67335. * The order of the callbacks is kept, callbacks are not executed parallel.
  67336. *
  67337. * @param eventData The data to be sent to each callback
  67338. * @param mask is used to filter observers defaults to -1
  67339. * @param target defines the callback target (see EventState)
  67340. * @param currentTarget defines he current object in the bubbling phase
  67341. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67342. */
  67343. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67344. /**
  67345. * Notify a specific observer
  67346. * @param observer defines the observer to notify
  67347. * @param eventData defines the data to be sent to each callback
  67348. * @param mask is used to filter observers defaults to -1
  67349. */
  67350. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67351. /**
  67352. * Gets a boolean indicating if the observable has at least one observer
  67353. * @returns true is the Observable has at least one Observer registered
  67354. */
  67355. hasObservers(): boolean;
  67356. /**
  67357. * Clear the list of observers
  67358. */
  67359. clear(): void;
  67360. /**
  67361. * Clone the current observable
  67362. * @returns a new observable
  67363. */
  67364. clone(): Observable<T>;
  67365. /**
  67366. * Does this observable handles observer registered with a given mask
  67367. * @param mask defines the mask to be tested
  67368. * @return whether or not one observer registered with the given mask is handeled
  67369. **/
  67370. hasSpecificMask(mask?: number): boolean;
  67371. }
  67372. }
  67373. declare module BABYLON {
  67374. /**
  67375. * Class used to help managing file picking and drag'n'drop
  67376. * File Storage
  67377. */
  67378. export class FilesInputStore {
  67379. /**
  67380. * List of files ready to be loaded
  67381. */
  67382. static FilesToLoad: {
  67383. [key: string]: File;
  67384. };
  67385. }
  67386. }
  67387. declare module BABYLON {
  67388. /** Defines the cross module used constants to avoid circular dependncies */
  67389. export class Constants {
  67390. /** Defines that alpha blending is disabled */
  67391. static readonly ALPHA_DISABLE: number;
  67392. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67393. static readonly ALPHA_ADD: number;
  67394. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67395. static readonly ALPHA_COMBINE: number;
  67396. /** Defines that alpha blending to DEST - SRC * DEST */
  67397. static readonly ALPHA_SUBTRACT: number;
  67398. /** Defines that alpha blending to SRC * DEST */
  67399. static readonly ALPHA_MULTIPLY: number;
  67400. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67401. static readonly ALPHA_MAXIMIZED: number;
  67402. /** Defines that alpha blending to SRC + DEST */
  67403. static readonly ALPHA_ONEONE: number;
  67404. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67405. static readonly ALPHA_PREMULTIPLIED: number;
  67406. /**
  67407. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67408. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67409. */
  67410. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67411. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67412. static readonly ALPHA_INTERPOLATE: number;
  67413. /**
  67414. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67415. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67416. */
  67417. static readonly ALPHA_SCREENMODE: number;
  67418. /** Defines that the ressource is not delayed*/
  67419. static readonly DELAYLOADSTATE_NONE: number;
  67420. /** Defines that the ressource was successfully delay loaded */
  67421. static readonly DELAYLOADSTATE_LOADED: number;
  67422. /** Defines that the ressource is currently delay loading */
  67423. static readonly DELAYLOADSTATE_LOADING: number;
  67424. /** Defines that the ressource is delayed and has not started loading */
  67425. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67426. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67427. static readonly NEVER: number;
  67428. /** 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 */
  67429. static readonly ALWAYS: number;
  67430. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67431. static readonly LESS: number;
  67432. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67433. static readonly EQUAL: number;
  67434. /** 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 */
  67435. static readonly LEQUAL: number;
  67436. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67437. static readonly GREATER: number;
  67438. /** 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 */
  67439. static readonly GEQUAL: number;
  67440. /** 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 */
  67441. static readonly NOTEQUAL: number;
  67442. /** Passed to stencilOperation to specify that stencil value must be kept */
  67443. static readonly KEEP: number;
  67444. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67445. static readonly REPLACE: number;
  67446. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67447. static readonly INCR: number;
  67448. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67449. static readonly DECR: number;
  67450. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67451. static readonly INVERT: number;
  67452. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67453. static readonly INCR_WRAP: number;
  67454. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67455. static readonly DECR_WRAP: number;
  67456. /** Texture is not repeating outside of 0..1 UVs */
  67457. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67458. /** Texture is repeating outside of 0..1 UVs */
  67459. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67460. /** Texture is repeating and mirrored */
  67461. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67462. /** ALPHA */
  67463. static readonly TEXTUREFORMAT_ALPHA: number;
  67464. /** LUMINANCE */
  67465. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67466. /** LUMINANCE_ALPHA */
  67467. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67468. /** RGB */
  67469. static readonly TEXTUREFORMAT_RGB: number;
  67470. /** RGBA */
  67471. static readonly TEXTUREFORMAT_RGBA: number;
  67472. /** RED */
  67473. static readonly TEXTUREFORMAT_RED: number;
  67474. /** RED (2nd reference) */
  67475. static readonly TEXTUREFORMAT_R: number;
  67476. /** RG */
  67477. static readonly TEXTUREFORMAT_RG: number;
  67478. /** RED_INTEGER */
  67479. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67480. /** RED_INTEGER (2nd reference) */
  67481. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67482. /** RG_INTEGER */
  67483. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67484. /** RGB_INTEGER */
  67485. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67486. /** RGBA_INTEGER */
  67487. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67488. /** UNSIGNED_BYTE */
  67489. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67490. /** UNSIGNED_BYTE (2nd reference) */
  67491. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67492. /** FLOAT */
  67493. static readonly TEXTURETYPE_FLOAT: number;
  67494. /** HALF_FLOAT */
  67495. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67496. /** BYTE */
  67497. static readonly TEXTURETYPE_BYTE: number;
  67498. /** SHORT */
  67499. static readonly TEXTURETYPE_SHORT: number;
  67500. /** UNSIGNED_SHORT */
  67501. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67502. /** INT */
  67503. static readonly TEXTURETYPE_INT: number;
  67504. /** UNSIGNED_INT */
  67505. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67506. /** UNSIGNED_SHORT_4_4_4_4 */
  67507. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67508. /** UNSIGNED_SHORT_5_5_5_1 */
  67509. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67510. /** UNSIGNED_SHORT_5_6_5 */
  67511. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67512. /** UNSIGNED_INT_2_10_10_10_REV */
  67513. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67514. /** UNSIGNED_INT_24_8 */
  67515. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67516. /** UNSIGNED_INT_10F_11F_11F_REV */
  67517. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67518. /** UNSIGNED_INT_5_9_9_9_REV */
  67519. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67520. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67521. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67522. /** nearest is mag = nearest and min = nearest and mip = linear */
  67523. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67524. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67525. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67526. /** Trilinear is mag = linear and min = linear and mip = linear */
  67527. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67528. /** nearest is mag = nearest and min = nearest and mip = linear */
  67529. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67530. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67531. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67532. /** Trilinear is mag = linear and min = linear and mip = linear */
  67533. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67534. /** mag = nearest and min = nearest and mip = nearest */
  67535. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67536. /** mag = nearest and min = linear and mip = nearest */
  67537. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67538. /** mag = nearest and min = linear and mip = linear */
  67539. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67540. /** mag = nearest and min = linear and mip = none */
  67541. static readonly TEXTURE_NEAREST_LINEAR: number;
  67542. /** mag = nearest and min = nearest and mip = none */
  67543. static readonly TEXTURE_NEAREST_NEAREST: number;
  67544. /** mag = linear and min = nearest and mip = nearest */
  67545. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67546. /** mag = linear and min = nearest and mip = linear */
  67547. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67548. /** mag = linear and min = linear and mip = none */
  67549. static readonly TEXTURE_LINEAR_LINEAR: number;
  67550. /** mag = linear and min = nearest and mip = none */
  67551. static readonly TEXTURE_LINEAR_NEAREST: number;
  67552. /** Explicit coordinates mode */
  67553. static readonly TEXTURE_EXPLICIT_MODE: number;
  67554. /** Spherical coordinates mode */
  67555. static readonly TEXTURE_SPHERICAL_MODE: number;
  67556. /** Planar coordinates mode */
  67557. static readonly TEXTURE_PLANAR_MODE: number;
  67558. /** Cubic coordinates mode */
  67559. static readonly TEXTURE_CUBIC_MODE: number;
  67560. /** Projection coordinates mode */
  67561. static readonly TEXTURE_PROJECTION_MODE: number;
  67562. /** Skybox coordinates mode */
  67563. static readonly TEXTURE_SKYBOX_MODE: number;
  67564. /** Inverse Cubic coordinates mode */
  67565. static readonly TEXTURE_INVCUBIC_MODE: number;
  67566. /** Equirectangular coordinates mode */
  67567. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67568. /** Equirectangular Fixed coordinates mode */
  67569. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67570. /** Equirectangular Fixed Mirrored coordinates mode */
  67571. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67572. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67573. static readonly SCALEMODE_FLOOR: number;
  67574. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67575. static readonly SCALEMODE_NEAREST: number;
  67576. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67577. static readonly SCALEMODE_CEILING: number;
  67578. /**
  67579. * The dirty texture flag value
  67580. */
  67581. static readonly MATERIAL_TextureDirtyFlag: number;
  67582. /**
  67583. * The dirty light flag value
  67584. */
  67585. static readonly MATERIAL_LightDirtyFlag: number;
  67586. /**
  67587. * The dirty fresnel flag value
  67588. */
  67589. static readonly MATERIAL_FresnelDirtyFlag: number;
  67590. /**
  67591. * The dirty attribute flag value
  67592. */
  67593. static readonly MATERIAL_AttributesDirtyFlag: number;
  67594. /**
  67595. * The dirty misc flag value
  67596. */
  67597. static readonly MATERIAL_MiscDirtyFlag: number;
  67598. /**
  67599. * The all dirty flag value
  67600. */
  67601. static readonly MATERIAL_AllDirtyFlag: number;
  67602. /**
  67603. * Returns the triangle fill mode
  67604. */
  67605. static readonly MATERIAL_TriangleFillMode: number;
  67606. /**
  67607. * Returns the wireframe mode
  67608. */
  67609. static readonly MATERIAL_WireFrameFillMode: number;
  67610. /**
  67611. * Returns the point fill mode
  67612. */
  67613. static readonly MATERIAL_PointFillMode: number;
  67614. /**
  67615. * Returns the point list draw mode
  67616. */
  67617. static readonly MATERIAL_PointListDrawMode: number;
  67618. /**
  67619. * Returns the line list draw mode
  67620. */
  67621. static readonly MATERIAL_LineListDrawMode: number;
  67622. /**
  67623. * Returns the line loop draw mode
  67624. */
  67625. static readonly MATERIAL_LineLoopDrawMode: number;
  67626. /**
  67627. * Returns the line strip draw mode
  67628. */
  67629. static readonly MATERIAL_LineStripDrawMode: number;
  67630. /**
  67631. * Returns the triangle strip draw mode
  67632. */
  67633. static readonly MATERIAL_TriangleStripDrawMode: number;
  67634. /**
  67635. * Returns the triangle fan draw mode
  67636. */
  67637. static readonly MATERIAL_TriangleFanDrawMode: number;
  67638. /**
  67639. * Stores the clock-wise side orientation
  67640. */
  67641. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67642. /**
  67643. * Stores the counter clock-wise side orientation
  67644. */
  67645. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67646. /**
  67647. * Nothing
  67648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67649. */
  67650. static readonly ACTION_NothingTrigger: number;
  67651. /**
  67652. * On pick
  67653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67654. */
  67655. static readonly ACTION_OnPickTrigger: number;
  67656. /**
  67657. * On left pick
  67658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67659. */
  67660. static readonly ACTION_OnLeftPickTrigger: number;
  67661. /**
  67662. * On right pick
  67663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67664. */
  67665. static readonly ACTION_OnRightPickTrigger: number;
  67666. /**
  67667. * On center pick
  67668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67669. */
  67670. static readonly ACTION_OnCenterPickTrigger: number;
  67671. /**
  67672. * On pick down
  67673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67674. */
  67675. static readonly ACTION_OnPickDownTrigger: number;
  67676. /**
  67677. * On double pick
  67678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67679. */
  67680. static readonly ACTION_OnDoublePickTrigger: number;
  67681. /**
  67682. * On pick up
  67683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67684. */
  67685. static readonly ACTION_OnPickUpTrigger: number;
  67686. /**
  67687. * On pick out.
  67688. * This trigger will only be raised if you also declared a OnPickDown
  67689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67690. */
  67691. static readonly ACTION_OnPickOutTrigger: number;
  67692. /**
  67693. * On long press
  67694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67695. */
  67696. static readonly ACTION_OnLongPressTrigger: number;
  67697. /**
  67698. * On pointer over
  67699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67700. */
  67701. static readonly ACTION_OnPointerOverTrigger: number;
  67702. /**
  67703. * On pointer out
  67704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67705. */
  67706. static readonly ACTION_OnPointerOutTrigger: number;
  67707. /**
  67708. * On every frame
  67709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67710. */
  67711. static readonly ACTION_OnEveryFrameTrigger: number;
  67712. /**
  67713. * On intersection enter
  67714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67715. */
  67716. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67717. /**
  67718. * On intersection exit
  67719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67720. */
  67721. static readonly ACTION_OnIntersectionExitTrigger: number;
  67722. /**
  67723. * On key down
  67724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67725. */
  67726. static readonly ACTION_OnKeyDownTrigger: number;
  67727. /**
  67728. * On key up
  67729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67730. */
  67731. static readonly ACTION_OnKeyUpTrigger: number;
  67732. /**
  67733. * Billboard mode will only apply to Y axis
  67734. */
  67735. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67736. /**
  67737. * Billboard mode will apply to all axes
  67738. */
  67739. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67740. /**
  67741. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67742. */
  67743. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67744. /**
  67745. * Gets or sets base Assets URL
  67746. */
  67747. static PARTICLES_BaseAssetsUrl: string;
  67748. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67749. * Test order :
  67750. * Is the bounding sphere outside the frustum ?
  67751. * If not, are the bounding box vertices outside the frustum ?
  67752. * It not, then the cullable object is in the frustum.
  67753. */
  67754. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67755. /** Culling strategy : Bounding Sphere Only.
  67756. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67757. * It's also less accurate than the standard because some not visible objects can still be selected.
  67758. * Test : is the bounding sphere outside the frustum ?
  67759. * If not, then the cullable object is in the frustum.
  67760. */
  67761. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67762. /** Culling strategy : Optimistic Inclusion.
  67763. * This in an inclusion test first, then the standard exclusion test.
  67764. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67765. * 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.
  67766. * Anyway, it's as accurate as the standard strategy.
  67767. * Test :
  67768. * Is the cullable object bounding sphere center in the frustum ?
  67769. * If not, apply the default culling strategy.
  67770. */
  67771. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67772. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67773. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67774. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67775. * 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.
  67776. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67777. * Test :
  67778. * Is the cullable object bounding sphere center in the frustum ?
  67779. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67780. */
  67781. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67782. /**
  67783. * No logging while loading
  67784. */
  67785. static readonly SCENELOADER_NO_LOGGING: number;
  67786. /**
  67787. * Minimal logging while loading
  67788. */
  67789. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67790. /**
  67791. * Summary logging while loading
  67792. */
  67793. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67794. /**
  67795. * Detailled logging while loading
  67796. */
  67797. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67798. }
  67799. }
  67800. declare module BABYLON {
  67801. /**
  67802. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67803. * Babylon.js
  67804. */
  67805. export class DomManagement {
  67806. /**
  67807. * Checks if the window object exists
  67808. * @returns true if the window object exists
  67809. */
  67810. static IsWindowObjectExist(): boolean;
  67811. /**
  67812. * Extracts text content from a DOM element hierarchy
  67813. * @param element defines the root element
  67814. * @returns a string
  67815. */
  67816. static GetDOMTextContent(element: HTMLElement): string;
  67817. }
  67818. }
  67819. declare module BABYLON {
  67820. /**
  67821. * Logger used througouht the application to allow configuration of
  67822. * the log level required for the messages.
  67823. */
  67824. export class Logger {
  67825. /**
  67826. * No log
  67827. */
  67828. static readonly NoneLogLevel: number;
  67829. /**
  67830. * Only message logs
  67831. */
  67832. static readonly MessageLogLevel: number;
  67833. /**
  67834. * Only warning logs
  67835. */
  67836. static readonly WarningLogLevel: number;
  67837. /**
  67838. * Only error logs
  67839. */
  67840. static readonly ErrorLogLevel: number;
  67841. /**
  67842. * All logs
  67843. */
  67844. static readonly AllLogLevel: number;
  67845. private static _LogCache;
  67846. /**
  67847. * Gets a value indicating the number of loading errors
  67848. * @ignorenaming
  67849. */
  67850. static errorsCount: number;
  67851. /**
  67852. * Callback called when a new log is added
  67853. */
  67854. static OnNewCacheEntry: (entry: string) => void;
  67855. private static _AddLogEntry;
  67856. private static _FormatMessage;
  67857. private static _LogDisabled;
  67858. private static _LogEnabled;
  67859. private static _WarnDisabled;
  67860. private static _WarnEnabled;
  67861. private static _ErrorDisabled;
  67862. private static _ErrorEnabled;
  67863. /**
  67864. * Log a message to the console
  67865. */
  67866. static Log: (message: string) => void;
  67867. /**
  67868. * Write a warning message to the console
  67869. */
  67870. static Warn: (message: string) => void;
  67871. /**
  67872. * Write an error message to the console
  67873. */
  67874. static Error: (message: string) => void;
  67875. /**
  67876. * Gets current log cache (list of logs)
  67877. */
  67878. static readonly LogCache: string;
  67879. /**
  67880. * Clears the log cache
  67881. */
  67882. static ClearLogCache(): void;
  67883. /**
  67884. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67885. */
  67886. static LogLevels: number;
  67887. }
  67888. }
  67889. declare module BABYLON {
  67890. /** @hidden */
  67891. export class _TypeStore {
  67892. /** @hidden */
  67893. static RegisteredTypes: {
  67894. [key: string]: Object;
  67895. };
  67896. /** @hidden */
  67897. static GetClass(fqdn: string): any;
  67898. }
  67899. }
  67900. declare module BABYLON {
  67901. /**
  67902. * Class containing a set of static utilities functions for deep copy.
  67903. */
  67904. export class DeepCopier {
  67905. /**
  67906. * Tries to copy an object by duplicating every property
  67907. * @param source defines the source object
  67908. * @param destination defines the target object
  67909. * @param doNotCopyList defines a list of properties to avoid
  67910. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67911. */
  67912. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67913. }
  67914. }
  67915. declare module BABYLON {
  67916. /**
  67917. * Class containing a set of static utilities functions for precision date
  67918. */
  67919. export class PrecisionDate {
  67920. /**
  67921. * Gets either window.performance.now() if supported or Date.now() else
  67922. */
  67923. static readonly Now: number;
  67924. }
  67925. }
  67926. declare module BABYLON {
  67927. /** @hidden */
  67928. export class _DevTools {
  67929. static WarnImport(name: string): string;
  67930. }
  67931. }
  67932. declare module BABYLON {
  67933. /**
  67934. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67935. */
  67936. export class WebRequest {
  67937. private _xhr;
  67938. /**
  67939. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67940. * i.e. when loading files, where the server/service expects an Authorization header
  67941. */
  67942. static CustomRequestHeaders: {
  67943. [key: string]: string;
  67944. };
  67945. /**
  67946. * Add callback functions in this array to update all the requests before they get sent to the network
  67947. */
  67948. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67949. private _injectCustomRequestHeaders;
  67950. /**
  67951. * Gets or sets a function to be called when loading progress changes
  67952. */
  67953. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67954. /**
  67955. * Returns client's state
  67956. */
  67957. readonly readyState: number;
  67958. /**
  67959. * Returns client's status
  67960. */
  67961. readonly status: number;
  67962. /**
  67963. * Returns client's status as a text
  67964. */
  67965. readonly statusText: string;
  67966. /**
  67967. * Returns client's response
  67968. */
  67969. readonly response: any;
  67970. /**
  67971. * Returns client's response url
  67972. */
  67973. readonly responseURL: string;
  67974. /**
  67975. * Returns client's response as text
  67976. */
  67977. readonly responseText: string;
  67978. /**
  67979. * Gets or sets the expected response type
  67980. */
  67981. responseType: XMLHttpRequestResponseType;
  67982. /** @hidden */
  67983. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67984. /** @hidden */
  67985. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67986. /**
  67987. * Cancels any network activity
  67988. */
  67989. abort(): void;
  67990. /**
  67991. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67992. * @param body defines an optional request body
  67993. */
  67994. send(body?: Document | BodyInit | null): void;
  67995. /**
  67996. * Sets the request method, request URL
  67997. * @param method defines the method to use (GET, POST, etc..)
  67998. * @param url defines the url to connect with
  67999. */
  68000. open(method: string, url: string): void;
  68001. }
  68002. }
  68003. declare module BABYLON {
  68004. /**
  68005. * Class used to evalaute queries containing `and` and `or` operators
  68006. */
  68007. export class AndOrNotEvaluator {
  68008. /**
  68009. * Evaluate a query
  68010. * @param query defines the query to evaluate
  68011. * @param evaluateCallback defines the callback used to filter result
  68012. * @returns true if the query matches
  68013. */
  68014. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68015. private static _HandleParenthesisContent;
  68016. private static _SimplifyNegation;
  68017. }
  68018. }
  68019. declare module BABYLON {
  68020. /**
  68021. * Class used to store custom tags
  68022. */
  68023. export class Tags {
  68024. /**
  68025. * Adds support for tags on the given object
  68026. * @param obj defines the object to use
  68027. */
  68028. static EnableFor(obj: any): void;
  68029. /**
  68030. * Removes tags support
  68031. * @param obj defines the object to use
  68032. */
  68033. static DisableFor(obj: any): void;
  68034. /**
  68035. * Gets a boolean indicating if the given object has tags
  68036. * @param obj defines the object to use
  68037. * @returns a boolean
  68038. */
  68039. static HasTags(obj: any): boolean;
  68040. /**
  68041. * Gets the tags available on a given object
  68042. * @param obj defines the object to use
  68043. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68044. * @returns the tags
  68045. */
  68046. static GetTags(obj: any, asString?: boolean): any;
  68047. /**
  68048. * Adds tags to an object
  68049. * @param obj defines the object to use
  68050. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68051. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68052. */
  68053. static AddTagsTo(obj: any, tagsString: string): void;
  68054. /**
  68055. * @hidden
  68056. */
  68057. static _AddTagTo(obj: any, tag: string): void;
  68058. /**
  68059. * Removes specific tags from a specific object
  68060. * @param obj defines the object to use
  68061. * @param tagsString defines the tags to remove
  68062. */
  68063. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68064. /**
  68065. * @hidden
  68066. */
  68067. static _RemoveTagFrom(obj: any, tag: string): void;
  68068. /**
  68069. * Defines if tags hosted on an object match a given query
  68070. * @param obj defines the object to use
  68071. * @param tagsQuery defines the tag query
  68072. * @returns a boolean
  68073. */
  68074. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68075. }
  68076. }
  68077. declare module BABYLON {
  68078. /**
  68079. * Manages the defines for the Material
  68080. */
  68081. export class MaterialDefines {
  68082. /** @hidden */
  68083. protected _keys: string[];
  68084. private _isDirty;
  68085. /** @hidden */
  68086. _renderId: number;
  68087. /** @hidden */
  68088. _areLightsDirty: boolean;
  68089. /** @hidden */
  68090. _areAttributesDirty: boolean;
  68091. /** @hidden */
  68092. _areTexturesDirty: boolean;
  68093. /** @hidden */
  68094. _areFresnelDirty: boolean;
  68095. /** @hidden */
  68096. _areMiscDirty: boolean;
  68097. /** @hidden */
  68098. _areImageProcessingDirty: boolean;
  68099. /** @hidden */
  68100. _normals: boolean;
  68101. /** @hidden */
  68102. _uvs: boolean;
  68103. /** @hidden */
  68104. _needNormals: boolean;
  68105. /** @hidden */
  68106. _needUVs: boolean;
  68107. [id: string]: any;
  68108. /**
  68109. * Specifies if the material needs to be re-calculated
  68110. */
  68111. readonly isDirty: boolean;
  68112. /**
  68113. * Marks the material to indicate that it has been re-calculated
  68114. */
  68115. markAsProcessed(): void;
  68116. /**
  68117. * Marks the material to indicate that it needs to be re-calculated
  68118. */
  68119. markAsUnprocessed(): void;
  68120. /**
  68121. * Marks the material to indicate all of its defines need to be re-calculated
  68122. */
  68123. markAllAsDirty(): void;
  68124. /**
  68125. * Marks the material to indicate that image processing needs to be re-calculated
  68126. */
  68127. markAsImageProcessingDirty(): void;
  68128. /**
  68129. * Marks the material to indicate the lights need to be re-calculated
  68130. */
  68131. markAsLightDirty(): void;
  68132. /**
  68133. * Marks the attribute state as changed
  68134. */
  68135. markAsAttributesDirty(): void;
  68136. /**
  68137. * Marks the texture state as changed
  68138. */
  68139. markAsTexturesDirty(): void;
  68140. /**
  68141. * Marks the fresnel state as changed
  68142. */
  68143. markAsFresnelDirty(): void;
  68144. /**
  68145. * Marks the misc state as changed
  68146. */
  68147. markAsMiscDirty(): void;
  68148. /**
  68149. * Rebuilds the material defines
  68150. */
  68151. rebuild(): void;
  68152. /**
  68153. * Specifies if two material defines are equal
  68154. * @param other - A material define instance to compare to
  68155. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  68156. */
  68157. isEqual(other: MaterialDefines): boolean;
  68158. /**
  68159. * Clones this instance's defines to another instance
  68160. * @param other - material defines to clone values to
  68161. */
  68162. cloneTo(other: MaterialDefines): void;
  68163. /**
  68164. * Resets the material define values
  68165. */
  68166. reset(): void;
  68167. /**
  68168. * Converts the material define values to a string
  68169. * @returns - String of material define information
  68170. */
  68171. toString(): string;
  68172. }
  68173. }
  68174. declare module BABYLON {
  68175. /**
  68176. * Class used to store and describe the pipeline context associated with an effect
  68177. */
  68178. export interface IPipelineContext {
  68179. /**
  68180. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68181. */
  68182. isAsync: boolean;
  68183. /**
  68184. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68185. */
  68186. isReady: boolean;
  68187. /** @hidden */
  68188. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68189. }
  68190. }
  68191. declare module BABYLON {
  68192. /**
  68193. * Class used to store gfx data (like WebGLBuffer)
  68194. */
  68195. export class DataBuffer {
  68196. /**
  68197. * Gets or sets the number of objects referencing this buffer
  68198. */
  68199. references: number;
  68200. /** Gets or sets the size of the underlying buffer */
  68201. capacity: number;
  68202. /**
  68203. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68204. */
  68205. is32Bits: boolean;
  68206. /**
  68207. * Gets the underlying buffer
  68208. */
  68209. readonly underlyingResource: any;
  68210. }
  68211. }
  68212. declare module BABYLON {
  68213. /** @hidden */
  68214. export interface IShaderProcessor {
  68215. attributeProcessor?: (attribute: string) => string;
  68216. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68217. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68218. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68219. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68220. lineProcessor?: (line: string, isFragment: boolean) => string;
  68221. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68222. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68223. }
  68224. }
  68225. declare module BABYLON {
  68226. /** @hidden */
  68227. export interface ProcessingOptions {
  68228. defines: string[];
  68229. indexParameters: any;
  68230. isFragment: boolean;
  68231. shouldUseHighPrecisionShader: boolean;
  68232. supportsUniformBuffers: boolean;
  68233. shadersRepository: string;
  68234. includesShadersStore: {
  68235. [key: string]: string;
  68236. };
  68237. processor?: IShaderProcessor;
  68238. version: string;
  68239. platformName: string;
  68240. lookForClosingBracketForUniformBuffer?: boolean;
  68241. }
  68242. }
  68243. declare module BABYLON {
  68244. /** @hidden */
  68245. export class ShaderCodeNode {
  68246. line: string;
  68247. children: ShaderCodeNode[];
  68248. additionalDefineKey?: string;
  68249. additionalDefineValue?: string;
  68250. isValid(preprocessors: {
  68251. [key: string]: string;
  68252. }): boolean;
  68253. process(preprocessors: {
  68254. [key: string]: string;
  68255. }, options: ProcessingOptions): string;
  68256. }
  68257. }
  68258. declare module BABYLON {
  68259. /** @hidden */
  68260. export class ShaderCodeCursor {
  68261. private _lines;
  68262. lineIndex: number;
  68263. readonly currentLine: string;
  68264. readonly canRead: boolean;
  68265. lines: string[];
  68266. }
  68267. }
  68268. declare module BABYLON {
  68269. /** @hidden */
  68270. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68271. process(preprocessors: {
  68272. [key: string]: string;
  68273. }, options: ProcessingOptions): string;
  68274. }
  68275. }
  68276. declare module BABYLON {
  68277. /** @hidden */
  68278. export class ShaderDefineExpression {
  68279. isTrue(preprocessors: {
  68280. [key: string]: string;
  68281. }): boolean;
  68282. }
  68283. }
  68284. declare module BABYLON {
  68285. /** @hidden */
  68286. export class ShaderCodeTestNode extends ShaderCodeNode {
  68287. testExpression: ShaderDefineExpression;
  68288. isValid(preprocessors: {
  68289. [key: string]: string;
  68290. }): boolean;
  68291. }
  68292. }
  68293. declare module BABYLON {
  68294. /** @hidden */
  68295. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68296. define: string;
  68297. not: boolean;
  68298. constructor(define: string, not?: boolean);
  68299. isTrue(preprocessors: {
  68300. [key: string]: string;
  68301. }): boolean;
  68302. }
  68303. }
  68304. declare module BABYLON {
  68305. /** @hidden */
  68306. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68307. leftOperand: ShaderDefineExpression;
  68308. rightOperand: ShaderDefineExpression;
  68309. isTrue(preprocessors: {
  68310. [key: string]: string;
  68311. }): boolean;
  68312. }
  68313. }
  68314. declare module BABYLON {
  68315. /** @hidden */
  68316. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68317. leftOperand: ShaderDefineExpression;
  68318. rightOperand: ShaderDefineExpression;
  68319. isTrue(preprocessors: {
  68320. [key: string]: string;
  68321. }): boolean;
  68322. }
  68323. }
  68324. declare module BABYLON {
  68325. /** @hidden */
  68326. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68327. define: string;
  68328. operand: string;
  68329. testValue: string;
  68330. constructor(define: string, operand: string, testValue: string);
  68331. isTrue(preprocessors: {
  68332. [key: string]: string;
  68333. }): boolean;
  68334. }
  68335. }
  68336. declare module BABYLON {
  68337. /** @hidden */
  68338. export class ShaderProcessor {
  68339. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68340. private static _ProcessPrecision;
  68341. private static _ExtractOperation;
  68342. private static _BuildSubExpression;
  68343. private static _BuildExpression;
  68344. private static _MoveCursorWithinIf;
  68345. private static _MoveCursor;
  68346. private static _EvaluatePreProcessors;
  68347. private static _PreparePreProcessors;
  68348. private static _ProcessShaderConversion;
  68349. private static _ProcessIncludes;
  68350. }
  68351. }
  68352. declare module BABYLON {
  68353. /**
  68354. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68355. */
  68356. export class PerformanceMonitor {
  68357. private _enabled;
  68358. private _rollingFrameTime;
  68359. private _lastFrameTimeMs;
  68360. /**
  68361. * constructor
  68362. * @param frameSampleSize The number of samples required to saturate the sliding window
  68363. */
  68364. constructor(frameSampleSize?: number);
  68365. /**
  68366. * Samples current frame
  68367. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68368. */
  68369. sampleFrame(timeMs?: number): void;
  68370. /**
  68371. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68372. */
  68373. readonly averageFrameTime: number;
  68374. /**
  68375. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68376. */
  68377. readonly averageFrameTimeVariance: number;
  68378. /**
  68379. * Returns the frame time of the most recent frame
  68380. */
  68381. readonly instantaneousFrameTime: number;
  68382. /**
  68383. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68384. */
  68385. readonly averageFPS: number;
  68386. /**
  68387. * Returns the average framerate in frames per second using the most recent frame time
  68388. */
  68389. readonly instantaneousFPS: number;
  68390. /**
  68391. * Returns true if enough samples have been taken to completely fill the sliding window
  68392. */
  68393. readonly isSaturated: boolean;
  68394. /**
  68395. * Enables contributions to the sliding window sample set
  68396. */
  68397. enable(): void;
  68398. /**
  68399. * Disables contributions to the sliding window sample set
  68400. * Samples will not be interpolated over the disabled period
  68401. */
  68402. disable(): void;
  68403. /**
  68404. * Returns true if sampling is enabled
  68405. */
  68406. readonly isEnabled: boolean;
  68407. /**
  68408. * Resets performance monitor
  68409. */
  68410. reset(): void;
  68411. }
  68412. /**
  68413. * RollingAverage
  68414. *
  68415. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68416. */
  68417. export class RollingAverage {
  68418. /**
  68419. * Current average
  68420. */
  68421. average: number;
  68422. /**
  68423. * Current variance
  68424. */
  68425. variance: number;
  68426. protected _samples: Array<number>;
  68427. protected _sampleCount: number;
  68428. protected _pos: number;
  68429. protected _m2: number;
  68430. /**
  68431. * constructor
  68432. * @param length The number of samples required to saturate the sliding window
  68433. */
  68434. constructor(length: number);
  68435. /**
  68436. * Adds a sample to the sample set
  68437. * @param v The sample value
  68438. */
  68439. add(v: number): void;
  68440. /**
  68441. * Returns previously added values or null if outside of history or outside the sliding window domain
  68442. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68443. * @return Value previously recorded with add() or null if outside of range
  68444. */
  68445. history(i: number): number;
  68446. /**
  68447. * Returns true if enough samples have been taken to completely fill the sliding window
  68448. * @return true if sample-set saturated
  68449. */
  68450. isSaturated(): boolean;
  68451. /**
  68452. * Resets the rolling average (equivalent to 0 samples taken so far)
  68453. */
  68454. reset(): void;
  68455. /**
  68456. * Wraps a value around the sample range boundaries
  68457. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68458. * @return Wrapped position in sample range
  68459. */
  68460. protected _wrapPosition(i: number): number;
  68461. }
  68462. }
  68463. declare module BABYLON {
  68464. /**
  68465. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68466. * The underlying implementation relies on an associative array to ensure the best performances.
  68467. * The value can be anything including 'null' but except 'undefined'
  68468. */
  68469. export class StringDictionary<T> {
  68470. /**
  68471. * This will clear this dictionary and copy the content from the 'source' one.
  68472. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68473. * @param source the dictionary to take the content from and copy to this dictionary
  68474. */
  68475. copyFrom(source: StringDictionary<T>): void;
  68476. /**
  68477. * Get a value based from its key
  68478. * @param key the given key to get the matching value from
  68479. * @return the value if found, otherwise undefined is returned
  68480. */
  68481. get(key: string): T | undefined;
  68482. /**
  68483. * Get a value from its key or add it if it doesn't exist.
  68484. * This method will ensure you that a given key/data will be present in the dictionary.
  68485. * @param key the given key to get the matching value from
  68486. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68487. * The factory will only be invoked if there's no data for the given key.
  68488. * @return the value corresponding to the key.
  68489. */
  68490. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68491. /**
  68492. * Get a value from its key if present in the dictionary otherwise add it
  68493. * @param key the key to get the value from
  68494. * @param val if there's no such key/value pair in the dictionary add it with this value
  68495. * @return the value corresponding to the key
  68496. */
  68497. getOrAdd(key: string, val: T): T;
  68498. /**
  68499. * Check if there's a given key in the dictionary
  68500. * @param key the key to check for
  68501. * @return true if the key is present, false otherwise
  68502. */
  68503. contains(key: string): boolean;
  68504. /**
  68505. * Add a new key and its corresponding value
  68506. * @param key the key to add
  68507. * @param value the value corresponding to the key
  68508. * @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
  68509. */
  68510. add(key: string, value: T): boolean;
  68511. /**
  68512. * Update a specific value associated to a key
  68513. * @param key defines the key to use
  68514. * @param value defines the value to store
  68515. * @returns true if the value was updated (or false if the key was not found)
  68516. */
  68517. set(key: string, value: T): boolean;
  68518. /**
  68519. * Get the element of the given key and remove it from the dictionary
  68520. * @param key defines the key to search
  68521. * @returns the value associated with the key or null if not found
  68522. */
  68523. getAndRemove(key: string): Nullable<T>;
  68524. /**
  68525. * Remove a key/value from the dictionary.
  68526. * @param key the key to remove
  68527. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68528. */
  68529. remove(key: string): boolean;
  68530. /**
  68531. * Clear the whole content of the dictionary
  68532. */
  68533. clear(): void;
  68534. /**
  68535. * Gets the current count
  68536. */
  68537. readonly count: number;
  68538. /**
  68539. * Execute a callback on each key/val of the dictionary.
  68540. * Note that you can remove any element in this dictionary in the callback implementation
  68541. * @param callback the callback to execute on a given key/value pair
  68542. */
  68543. forEach(callback: (key: string, val: T) => void): void;
  68544. /**
  68545. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68546. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68547. * Note that you can remove any element in this dictionary in the callback implementation
  68548. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68549. * @returns the first item
  68550. */
  68551. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68552. private _count;
  68553. private _data;
  68554. }
  68555. }
  68556. declare module BABYLON {
  68557. /**
  68558. * Helper class that provides a small promise polyfill
  68559. */
  68560. export class PromisePolyfill {
  68561. /**
  68562. * Static function used to check if the polyfill is required
  68563. * If this is the case then the function will inject the polyfill to window.Promise
  68564. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68565. */
  68566. static Apply(force?: boolean): void;
  68567. }
  68568. }
  68569. declare module BABYLON {
  68570. /**
  68571. * Class used to store data that will be store in GPU memory
  68572. */
  68573. export class Buffer {
  68574. private _engine;
  68575. private _buffer;
  68576. /** @hidden */
  68577. _data: Nullable<DataArray>;
  68578. private _updatable;
  68579. private _instanced;
  68580. /**
  68581. * Gets the byte stride.
  68582. */
  68583. readonly byteStride: number;
  68584. /**
  68585. * Constructor
  68586. * @param engine the engine
  68587. * @param data the data to use for this buffer
  68588. * @param updatable whether the data is updatable
  68589. * @param stride the stride (optional)
  68590. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68591. * @param instanced whether the buffer is instanced (optional)
  68592. * @param useBytes set to true if the stride in in bytes (optional)
  68593. */
  68594. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68595. /**
  68596. * Create a new VertexBuffer based on the current buffer
  68597. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68598. * @param offset defines offset in the buffer (0 by default)
  68599. * @param size defines the size in floats of attributes (position is 3 for instance)
  68600. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68601. * @param instanced defines if the vertex buffer contains indexed data
  68602. * @param useBytes defines if the offset and stride are in bytes
  68603. * @returns the new vertex buffer
  68604. */
  68605. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68606. /**
  68607. * Gets a boolean indicating if the Buffer is updatable?
  68608. * @returns true if the buffer is updatable
  68609. */
  68610. isUpdatable(): boolean;
  68611. /**
  68612. * Gets current buffer's data
  68613. * @returns a DataArray or null
  68614. */
  68615. getData(): Nullable<DataArray>;
  68616. /**
  68617. * Gets underlying native buffer
  68618. * @returns underlying native buffer
  68619. */
  68620. getBuffer(): Nullable<DataBuffer>;
  68621. /**
  68622. * Gets the stride in float32 units (i.e. byte stride / 4).
  68623. * May not be an integer if the byte stride is not divisible by 4.
  68624. * DEPRECATED. Use byteStride instead.
  68625. * @returns the stride in float32 units
  68626. */
  68627. getStrideSize(): number;
  68628. /**
  68629. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68630. * @param data defines the data to store
  68631. */
  68632. create(data?: Nullable<DataArray>): void;
  68633. /** @hidden */
  68634. _rebuild(): void;
  68635. /**
  68636. * Update current buffer data
  68637. * @param data defines the data to store
  68638. */
  68639. update(data: DataArray): void;
  68640. /**
  68641. * Updates the data directly.
  68642. * @param data the new data
  68643. * @param offset the new offset
  68644. * @param vertexCount the vertex count (optional)
  68645. * @param useBytes set to true if the offset is in bytes
  68646. */
  68647. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68648. /**
  68649. * Release all resources
  68650. */
  68651. dispose(): void;
  68652. }
  68653. /**
  68654. * Specialized buffer used to store vertex data
  68655. */
  68656. export class VertexBuffer {
  68657. /** @hidden */
  68658. _buffer: Buffer;
  68659. private _kind;
  68660. private _size;
  68661. private _ownsBuffer;
  68662. private _instanced;
  68663. private _instanceDivisor;
  68664. /**
  68665. * The byte type.
  68666. */
  68667. static readonly BYTE: number;
  68668. /**
  68669. * The unsigned byte type.
  68670. */
  68671. static readonly UNSIGNED_BYTE: number;
  68672. /**
  68673. * The short type.
  68674. */
  68675. static readonly SHORT: number;
  68676. /**
  68677. * The unsigned short type.
  68678. */
  68679. static readonly UNSIGNED_SHORT: number;
  68680. /**
  68681. * The integer type.
  68682. */
  68683. static readonly INT: number;
  68684. /**
  68685. * The unsigned integer type.
  68686. */
  68687. static readonly UNSIGNED_INT: number;
  68688. /**
  68689. * The float type.
  68690. */
  68691. static readonly FLOAT: number;
  68692. /**
  68693. * Gets or sets the instance divisor when in instanced mode
  68694. */
  68695. instanceDivisor: number;
  68696. /**
  68697. * Gets the byte stride.
  68698. */
  68699. readonly byteStride: number;
  68700. /**
  68701. * Gets the byte offset.
  68702. */
  68703. readonly byteOffset: number;
  68704. /**
  68705. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68706. */
  68707. readonly normalized: boolean;
  68708. /**
  68709. * Gets the data type of each component in the array.
  68710. */
  68711. readonly type: number;
  68712. /**
  68713. * Constructor
  68714. * @param engine the engine
  68715. * @param data the data to use for this vertex buffer
  68716. * @param kind the vertex buffer kind
  68717. * @param updatable whether the data is updatable
  68718. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68719. * @param stride the stride (optional)
  68720. * @param instanced whether the buffer is instanced (optional)
  68721. * @param offset the offset of the data (optional)
  68722. * @param size the number of components (optional)
  68723. * @param type the type of the component (optional)
  68724. * @param normalized whether the data contains normalized data (optional)
  68725. * @param useBytes set to true if stride and offset are in bytes (optional)
  68726. */
  68727. 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);
  68728. /** @hidden */
  68729. _rebuild(): void;
  68730. /**
  68731. * Returns the kind of the VertexBuffer (string)
  68732. * @returns a string
  68733. */
  68734. getKind(): string;
  68735. /**
  68736. * Gets a boolean indicating if the VertexBuffer is updatable?
  68737. * @returns true if the buffer is updatable
  68738. */
  68739. isUpdatable(): boolean;
  68740. /**
  68741. * Gets current buffer's data
  68742. * @returns a DataArray or null
  68743. */
  68744. getData(): Nullable<DataArray>;
  68745. /**
  68746. * Gets underlying native buffer
  68747. * @returns underlying native buffer
  68748. */
  68749. getBuffer(): Nullable<DataBuffer>;
  68750. /**
  68751. * Gets the stride in float32 units (i.e. byte stride / 4).
  68752. * May not be an integer if the byte stride is not divisible by 4.
  68753. * DEPRECATED. Use byteStride instead.
  68754. * @returns the stride in float32 units
  68755. */
  68756. getStrideSize(): number;
  68757. /**
  68758. * Returns the offset as a multiple of the type byte length.
  68759. * DEPRECATED. Use byteOffset instead.
  68760. * @returns the offset in bytes
  68761. */
  68762. getOffset(): number;
  68763. /**
  68764. * Returns the number of components per vertex attribute (integer)
  68765. * @returns the size in float
  68766. */
  68767. getSize(): number;
  68768. /**
  68769. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68770. * @returns true if this buffer is instanced
  68771. */
  68772. getIsInstanced(): boolean;
  68773. /**
  68774. * Returns the instancing divisor, zero for non-instanced (integer).
  68775. * @returns a number
  68776. */
  68777. getInstanceDivisor(): number;
  68778. /**
  68779. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68780. * @param data defines the data to store
  68781. */
  68782. create(data?: DataArray): void;
  68783. /**
  68784. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68785. * This function will create a new buffer if the current one is not updatable
  68786. * @param data defines the data to store
  68787. */
  68788. update(data: DataArray): void;
  68789. /**
  68790. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68791. * Returns the directly updated WebGLBuffer.
  68792. * @param data the new data
  68793. * @param offset the new offset
  68794. * @param useBytes set to true if the offset is in bytes
  68795. */
  68796. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68797. /**
  68798. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68799. */
  68800. dispose(): void;
  68801. /**
  68802. * Enumerates each value of this vertex buffer as numbers.
  68803. * @param count the number of values to enumerate
  68804. * @param callback the callback function called for each value
  68805. */
  68806. forEach(count: number, callback: (value: number, index: number) => void): void;
  68807. /**
  68808. * Positions
  68809. */
  68810. static readonly PositionKind: string;
  68811. /**
  68812. * Normals
  68813. */
  68814. static readonly NormalKind: string;
  68815. /**
  68816. * Tangents
  68817. */
  68818. static readonly TangentKind: string;
  68819. /**
  68820. * Texture coordinates
  68821. */
  68822. static readonly UVKind: string;
  68823. /**
  68824. * Texture coordinates 2
  68825. */
  68826. static readonly UV2Kind: string;
  68827. /**
  68828. * Texture coordinates 3
  68829. */
  68830. static readonly UV3Kind: string;
  68831. /**
  68832. * Texture coordinates 4
  68833. */
  68834. static readonly UV4Kind: string;
  68835. /**
  68836. * Texture coordinates 5
  68837. */
  68838. static readonly UV5Kind: string;
  68839. /**
  68840. * Texture coordinates 6
  68841. */
  68842. static readonly UV6Kind: string;
  68843. /**
  68844. * Colors
  68845. */
  68846. static readonly ColorKind: string;
  68847. /**
  68848. * Matrix indices (for bones)
  68849. */
  68850. static readonly MatricesIndicesKind: string;
  68851. /**
  68852. * Matrix weights (for bones)
  68853. */
  68854. static readonly MatricesWeightsKind: string;
  68855. /**
  68856. * Additional matrix indices (for bones)
  68857. */
  68858. static readonly MatricesIndicesExtraKind: string;
  68859. /**
  68860. * Additional matrix weights (for bones)
  68861. */
  68862. static readonly MatricesWeightsExtraKind: string;
  68863. /**
  68864. * Deduces the stride given a kind.
  68865. * @param kind The kind string to deduce
  68866. * @returns The deduced stride
  68867. */
  68868. static DeduceStride(kind: string): number;
  68869. /**
  68870. * Gets the byte length of the given type.
  68871. * @param type the type
  68872. * @returns the number of bytes
  68873. */
  68874. static GetTypeByteLength(type: number): number;
  68875. /**
  68876. * Enumerates each value of the given parameters as numbers.
  68877. * @param data the data to enumerate
  68878. * @param byteOffset the byte offset of the data
  68879. * @param byteStride the byte stride of the data
  68880. * @param componentCount the number of components per element
  68881. * @param componentType the type of the component
  68882. * @param count the number of values to enumerate
  68883. * @param normalized whether the data is normalized
  68884. * @param callback the callback function called for each value
  68885. */
  68886. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68887. private static _GetFloatValue;
  68888. }
  68889. }
  68890. declare module BABYLON {
  68891. /**
  68892. * Class representing spherical harmonics coefficients to the 3rd degree
  68893. */
  68894. export class SphericalHarmonics {
  68895. /**
  68896. * Defines whether or not the harmonics have been prescaled for rendering.
  68897. */
  68898. preScaled: boolean;
  68899. /**
  68900. * The l0,0 coefficients of the spherical harmonics
  68901. */
  68902. l00: Vector3;
  68903. /**
  68904. * The l1,-1 coefficients of the spherical harmonics
  68905. */
  68906. l1_1: Vector3;
  68907. /**
  68908. * The l1,0 coefficients of the spherical harmonics
  68909. */
  68910. l10: Vector3;
  68911. /**
  68912. * The l1,1 coefficients of the spherical harmonics
  68913. */
  68914. l11: Vector3;
  68915. /**
  68916. * The l2,-2 coefficients of the spherical harmonics
  68917. */
  68918. l2_2: Vector3;
  68919. /**
  68920. * The l2,-1 coefficients of the spherical harmonics
  68921. */
  68922. l2_1: Vector3;
  68923. /**
  68924. * The l2,0 coefficients of the spherical harmonics
  68925. */
  68926. l20: Vector3;
  68927. /**
  68928. * The l2,1 coefficients of the spherical harmonics
  68929. */
  68930. l21: Vector3;
  68931. /**
  68932. * The l2,2 coefficients of the spherical harmonics
  68933. */
  68934. l22: Vector3;
  68935. /**
  68936. * Adds a light to the spherical harmonics
  68937. * @param direction the direction of the light
  68938. * @param color the color of the light
  68939. * @param deltaSolidAngle the delta solid angle of the light
  68940. */
  68941. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68942. /**
  68943. * Scales the spherical harmonics by the given amount
  68944. * @param scale the amount to scale
  68945. */
  68946. scaleInPlace(scale: number): void;
  68947. /**
  68948. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68949. *
  68950. * ```
  68951. * E_lm = A_l * L_lm
  68952. * ```
  68953. *
  68954. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68955. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68956. * the scaling factors are given in equation 9.
  68957. */
  68958. convertIncidentRadianceToIrradiance(): void;
  68959. /**
  68960. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68961. *
  68962. * ```
  68963. * L = (1/pi) * E * rho
  68964. * ```
  68965. *
  68966. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68967. */
  68968. convertIrradianceToLambertianRadiance(): void;
  68969. /**
  68970. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68971. * required operations at run time.
  68972. *
  68973. * This is simply done by scaling back the SH with Ylm constants parameter.
  68974. * The trigonometric part being applied by the shader at run time.
  68975. */
  68976. preScaleForRendering(): void;
  68977. /**
  68978. * Constructs a spherical harmonics from an array.
  68979. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68980. * @returns the spherical harmonics
  68981. */
  68982. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68983. /**
  68984. * Gets the spherical harmonics from polynomial
  68985. * @param polynomial the spherical polynomial
  68986. * @returns the spherical harmonics
  68987. */
  68988. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68989. }
  68990. /**
  68991. * Class representing spherical polynomial coefficients to the 3rd degree
  68992. */
  68993. export class SphericalPolynomial {
  68994. private _harmonics;
  68995. /**
  68996. * The spherical harmonics used to create the polynomials.
  68997. */
  68998. readonly preScaledHarmonics: SphericalHarmonics;
  68999. /**
  69000. * The x coefficients of the spherical polynomial
  69001. */
  69002. x: Vector3;
  69003. /**
  69004. * The y coefficients of the spherical polynomial
  69005. */
  69006. y: Vector3;
  69007. /**
  69008. * The z coefficients of the spherical polynomial
  69009. */
  69010. z: Vector3;
  69011. /**
  69012. * The xx coefficients of the spherical polynomial
  69013. */
  69014. xx: Vector3;
  69015. /**
  69016. * The yy coefficients of the spherical polynomial
  69017. */
  69018. yy: Vector3;
  69019. /**
  69020. * The zz coefficients of the spherical polynomial
  69021. */
  69022. zz: Vector3;
  69023. /**
  69024. * The xy coefficients of the spherical polynomial
  69025. */
  69026. xy: Vector3;
  69027. /**
  69028. * The yz coefficients of the spherical polynomial
  69029. */
  69030. yz: Vector3;
  69031. /**
  69032. * The zx coefficients of the spherical polynomial
  69033. */
  69034. zx: Vector3;
  69035. /**
  69036. * Adds an ambient color to the spherical polynomial
  69037. * @param color the color to add
  69038. */
  69039. addAmbient(color: Color3): void;
  69040. /**
  69041. * Scales the spherical polynomial by the given amount
  69042. * @param scale the amount to scale
  69043. */
  69044. scaleInPlace(scale: number): void;
  69045. /**
  69046. * Gets the spherical polynomial from harmonics
  69047. * @param harmonics the spherical harmonics
  69048. * @returns the spherical polynomial
  69049. */
  69050. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69051. /**
  69052. * Constructs a spherical polynomial from an array.
  69053. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69054. * @returns the spherical polynomial
  69055. */
  69056. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69057. }
  69058. }
  69059. declare module BABYLON {
  69060. /**
  69061. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  69062. */
  69063. export interface CubeMapInfo {
  69064. /**
  69065. * The pixel array for the front face.
  69066. * This is stored in format, left to right, up to down format.
  69067. */
  69068. front: Nullable<ArrayBufferView>;
  69069. /**
  69070. * The pixel array for the back face.
  69071. * This is stored in format, left to right, up to down format.
  69072. */
  69073. back: Nullable<ArrayBufferView>;
  69074. /**
  69075. * The pixel array for the left face.
  69076. * This is stored in format, left to right, up to down format.
  69077. */
  69078. left: Nullable<ArrayBufferView>;
  69079. /**
  69080. * The pixel array for the right face.
  69081. * This is stored in format, left to right, up to down format.
  69082. */
  69083. right: Nullable<ArrayBufferView>;
  69084. /**
  69085. * The pixel array for the up face.
  69086. * This is stored in format, left to right, up to down format.
  69087. */
  69088. up: Nullable<ArrayBufferView>;
  69089. /**
  69090. * The pixel array for the down face.
  69091. * This is stored in format, left to right, up to down format.
  69092. */
  69093. down: Nullable<ArrayBufferView>;
  69094. /**
  69095. * The size of the cubemap stored.
  69096. *
  69097. * Each faces will be size * size pixels.
  69098. */
  69099. size: number;
  69100. /**
  69101. * The format of the texture.
  69102. *
  69103. * RGBA, RGB.
  69104. */
  69105. format: number;
  69106. /**
  69107. * The type of the texture data.
  69108. *
  69109. * UNSIGNED_INT, FLOAT.
  69110. */
  69111. type: number;
  69112. /**
  69113. * Specifies whether the texture is in gamma space.
  69114. */
  69115. gammaSpace: boolean;
  69116. }
  69117. /**
  69118. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  69119. */
  69120. export class PanoramaToCubeMapTools {
  69121. private static FACE_FRONT;
  69122. private static FACE_BACK;
  69123. private static FACE_RIGHT;
  69124. private static FACE_LEFT;
  69125. private static FACE_DOWN;
  69126. private static FACE_UP;
  69127. /**
  69128. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  69129. *
  69130. * @param float32Array The source data.
  69131. * @param inputWidth The width of the input panorama.
  69132. * @param inputHeight The height of the input panorama.
  69133. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  69134. * @return The cubemap data
  69135. */
  69136. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  69137. private static CreateCubemapTexture;
  69138. private static CalcProjectionSpherical;
  69139. }
  69140. }
  69141. declare module BABYLON {
  69142. /**
  69143. * Helper class dealing with the extraction of spherical polynomial dataArray
  69144. * from a cube map.
  69145. */
  69146. export class CubeMapToSphericalPolynomialTools {
  69147. private static FileFaces;
  69148. /**
  69149. * Converts a texture to the according Spherical Polynomial data.
  69150. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69151. *
  69152. * @param texture The texture to extract the information from.
  69153. * @return The Spherical Polynomial data.
  69154. */
  69155. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  69156. /**
  69157. * Converts a cubemap to the according Spherical Polynomial data.
  69158. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69159. *
  69160. * @param cubeInfo The Cube map to extract the information from.
  69161. * @return The Spherical Polynomial data.
  69162. */
  69163. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  69164. }
  69165. }
  69166. declare module BABYLON {
  69167. /**
  69168. * The engine store class is responsible to hold all the instances of Engine and Scene created
  69169. * during the life time of the application.
  69170. */
  69171. export class EngineStore {
  69172. /** Gets the list of created engines */
  69173. static Instances: Engine[];
  69174. /** @hidden */
  69175. static _LastCreatedScene: Nullable<Scene>;
  69176. /**
  69177. * Gets the latest created engine
  69178. */
  69179. static readonly LastCreatedEngine: Nullable<Engine>;
  69180. /**
  69181. * Gets the latest created scene
  69182. */
  69183. static readonly LastCreatedScene: Nullable<Scene>;
  69184. }
  69185. }
  69186. declare module BABYLON {
  69187. /**
  69188. * Define options used to create a render target texture
  69189. */
  69190. export class RenderTargetCreationOptions {
  69191. /**
  69192. * Specifies is mipmaps must be generated
  69193. */
  69194. generateMipMaps?: boolean;
  69195. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69196. generateDepthBuffer?: boolean;
  69197. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69198. generateStencilBuffer?: boolean;
  69199. /** Defines texture type (int by default) */
  69200. type?: number;
  69201. /** Defines sampling mode (trilinear by default) */
  69202. samplingMode?: number;
  69203. /** Defines format (RGBA by default) */
  69204. format?: number;
  69205. }
  69206. }
  69207. declare module BABYLON {
  69208. /**
  69209. * @hidden
  69210. **/
  69211. export class _AlphaState {
  69212. private _isAlphaBlendDirty;
  69213. private _isBlendFunctionParametersDirty;
  69214. private _isBlendEquationParametersDirty;
  69215. private _isBlendConstantsDirty;
  69216. private _alphaBlend;
  69217. private _blendFunctionParameters;
  69218. private _blendEquationParameters;
  69219. private _blendConstants;
  69220. /**
  69221. * Initializes the state.
  69222. */
  69223. constructor();
  69224. readonly isDirty: boolean;
  69225. alphaBlend: boolean;
  69226. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69227. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69228. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69229. reset(): void;
  69230. apply(gl: WebGLRenderingContext): void;
  69231. }
  69232. }
  69233. declare module BABYLON {
  69234. /**
  69235. * @hidden
  69236. **/
  69237. export class _DepthCullingState {
  69238. private _isDepthTestDirty;
  69239. private _isDepthMaskDirty;
  69240. private _isDepthFuncDirty;
  69241. private _isCullFaceDirty;
  69242. private _isCullDirty;
  69243. private _isZOffsetDirty;
  69244. private _isFrontFaceDirty;
  69245. private _depthTest;
  69246. private _depthMask;
  69247. private _depthFunc;
  69248. private _cull;
  69249. private _cullFace;
  69250. private _zOffset;
  69251. private _frontFace;
  69252. /**
  69253. * Initializes the state.
  69254. */
  69255. constructor();
  69256. readonly isDirty: boolean;
  69257. zOffset: number;
  69258. cullFace: Nullable<number>;
  69259. cull: Nullable<boolean>;
  69260. depthFunc: Nullable<number>;
  69261. depthMask: boolean;
  69262. depthTest: boolean;
  69263. frontFace: Nullable<number>;
  69264. reset(): void;
  69265. apply(gl: WebGLRenderingContext): void;
  69266. }
  69267. }
  69268. declare module BABYLON {
  69269. /**
  69270. * @hidden
  69271. **/
  69272. export class _StencilState {
  69273. /** 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 */
  69274. static readonly ALWAYS: number;
  69275. /** Passed to stencilOperation to specify that stencil value must be kept */
  69276. static readonly KEEP: number;
  69277. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69278. static readonly REPLACE: number;
  69279. private _isStencilTestDirty;
  69280. private _isStencilMaskDirty;
  69281. private _isStencilFuncDirty;
  69282. private _isStencilOpDirty;
  69283. private _stencilTest;
  69284. private _stencilMask;
  69285. private _stencilFunc;
  69286. private _stencilFuncRef;
  69287. private _stencilFuncMask;
  69288. private _stencilOpStencilFail;
  69289. private _stencilOpDepthFail;
  69290. private _stencilOpStencilDepthPass;
  69291. readonly isDirty: boolean;
  69292. stencilFunc: number;
  69293. stencilFuncRef: number;
  69294. stencilFuncMask: number;
  69295. stencilOpStencilFail: number;
  69296. stencilOpDepthFail: number;
  69297. stencilOpStencilDepthPass: number;
  69298. stencilMask: number;
  69299. stencilTest: boolean;
  69300. constructor();
  69301. reset(): void;
  69302. apply(gl: WebGLRenderingContext): void;
  69303. }
  69304. }
  69305. declare module BABYLON {
  69306. /**
  69307. * @hidden
  69308. **/
  69309. export class _TimeToken {
  69310. _startTimeQuery: Nullable<WebGLQuery>;
  69311. _endTimeQuery: Nullable<WebGLQuery>;
  69312. _timeElapsedQuery: Nullable<WebGLQuery>;
  69313. _timeElapsedQueryEnded: boolean;
  69314. }
  69315. }
  69316. declare module BABYLON {
  69317. /**
  69318. * Class used to store data associated with WebGL texture data for the engine
  69319. * This class should not be used directly
  69320. */
  69321. export class InternalTexture {
  69322. /** @hidden */
  69323. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69324. /**
  69325. * The source of the texture data is unknown
  69326. */
  69327. static DATASOURCE_UNKNOWN: number;
  69328. /**
  69329. * Texture data comes from an URL
  69330. */
  69331. static DATASOURCE_URL: number;
  69332. /**
  69333. * Texture data is only used for temporary storage
  69334. */
  69335. static DATASOURCE_TEMP: number;
  69336. /**
  69337. * Texture data comes from raw data (ArrayBuffer)
  69338. */
  69339. static DATASOURCE_RAW: number;
  69340. /**
  69341. * Texture content is dynamic (video or dynamic texture)
  69342. */
  69343. static DATASOURCE_DYNAMIC: number;
  69344. /**
  69345. * Texture content is generated by rendering to it
  69346. */
  69347. static DATASOURCE_RENDERTARGET: number;
  69348. /**
  69349. * Texture content is part of a multi render target process
  69350. */
  69351. static DATASOURCE_MULTIRENDERTARGET: number;
  69352. /**
  69353. * Texture data comes from a cube data file
  69354. */
  69355. static DATASOURCE_CUBE: number;
  69356. /**
  69357. * Texture data comes from a raw cube data
  69358. */
  69359. static DATASOURCE_CUBERAW: number;
  69360. /**
  69361. * Texture data come from a prefiltered cube data file
  69362. */
  69363. static DATASOURCE_CUBEPREFILTERED: number;
  69364. /**
  69365. * Texture content is raw 3D data
  69366. */
  69367. static DATASOURCE_RAW3D: number;
  69368. /**
  69369. * Texture content is a depth texture
  69370. */
  69371. static DATASOURCE_DEPTHTEXTURE: number;
  69372. /**
  69373. * Texture data comes from a raw cube data encoded with RGBD
  69374. */
  69375. static DATASOURCE_CUBERAW_RGBD: number;
  69376. /**
  69377. * Defines if the texture is ready
  69378. */
  69379. isReady: boolean;
  69380. /**
  69381. * Defines if the texture is a cube texture
  69382. */
  69383. isCube: boolean;
  69384. /**
  69385. * Defines if the texture contains 3D data
  69386. */
  69387. is3D: boolean;
  69388. /**
  69389. * Defines if the texture contains multiview data
  69390. */
  69391. isMultiview: boolean;
  69392. /**
  69393. * Gets the URL used to load this texture
  69394. */
  69395. url: string;
  69396. /**
  69397. * Gets the sampling mode of the texture
  69398. */
  69399. samplingMode: number;
  69400. /**
  69401. * Gets a boolean indicating if the texture needs mipmaps generation
  69402. */
  69403. generateMipMaps: boolean;
  69404. /**
  69405. * Gets the number of samples used by the texture (WebGL2+ only)
  69406. */
  69407. samples: number;
  69408. /**
  69409. * Gets the type of the texture (int, float...)
  69410. */
  69411. type: number;
  69412. /**
  69413. * Gets the format of the texture (RGB, RGBA...)
  69414. */
  69415. format: number;
  69416. /**
  69417. * Observable called when the texture is loaded
  69418. */
  69419. onLoadedObservable: Observable<InternalTexture>;
  69420. /**
  69421. * Gets the width of the texture
  69422. */
  69423. width: number;
  69424. /**
  69425. * Gets the height of the texture
  69426. */
  69427. height: number;
  69428. /**
  69429. * Gets the depth of the texture
  69430. */
  69431. depth: number;
  69432. /**
  69433. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69434. */
  69435. baseWidth: number;
  69436. /**
  69437. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69438. */
  69439. baseHeight: number;
  69440. /**
  69441. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69442. */
  69443. baseDepth: number;
  69444. /**
  69445. * Gets a boolean indicating if the texture is inverted on Y axis
  69446. */
  69447. invertY: boolean;
  69448. /** @hidden */
  69449. _invertVScale: boolean;
  69450. /** @hidden */
  69451. _associatedChannel: number;
  69452. /** @hidden */
  69453. _dataSource: number;
  69454. /** @hidden */
  69455. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69456. /** @hidden */
  69457. _bufferView: Nullable<ArrayBufferView>;
  69458. /** @hidden */
  69459. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69460. /** @hidden */
  69461. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69462. /** @hidden */
  69463. _size: number;
  69464. /** @hidden */
  69465. _extension: string;
  69466. /** @hidden */
  69467. _files: Nullable<string[]>;
  69468. /** @hidden */
  69469. _workingCanvas: Nullable<HTMLCanvasElement>;
  69470. /** @hidden */
  69471. _workingContext: Nullable<CanvasRenderingContext2D>;
  69472. /** @hidden */
  69473. _framebuffer: Nullable<WebGLFramebuffer>;
  69474. /** @hidden */
  69475. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69476. /** @hidden */
  69477. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69478. /** @hidden */
  69479. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69480. /** @hidden */
  69481. _attachments: Nullable<number[]>;
  69482. /** @hidden */
  69483. _cachedCoordinatesMode: Nullable<number>;
  69484. /** @hidden */
  69485. _cachedWrapU: Nullable<number>;
  69486. /** @hidden */
  69487. _cachedWrapV: Nullable<number>;
  69488. /** @hidden */
  69489. _cachedWrapR: Nullable<number>;
  69490. /** @hidden */
  69491. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69492. /** @hidden */
  69493. _isDisabled: boolean;
  69494. /** @hidden */
  69495. _compression: Nullable<string>;
  69496. /** @hidden */
  69497. _generateStencilBuffer: boolean;
  69498. /** @hidden */
  69499. _generateDepthBuffer: boolean;
  69500. /** @hidden */
  69501. _comparisonFunction: number;
  69502. /** @hidden */
  69503. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69504. /** @hidden */
  69505. _lodGenerationScale: number;
  69506. /** @hidden */
  69507. _lodGenerationOffset: number;
  69508. /** @hidden */
  69509. _colorTextureArray: Nullable<WebGLTexture>;
  69510. /** @hidden */
  69511. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69512. /** @hidden */
  69513. _lodTextureHigh: Nullable<BaseTexture>;
  69514. /** @hidden */
  69515. _lodTextureMid: Nullable<BaseTexture>;
  69516. /** @hidden */
  69517. _lodTextureLow: Nullable<BaseTexture>;
  69518. /** @hidden */
  69519. _isRGBD: boolean;
  69520. /** @hidden */
  69521. _linearSpecularLOD: boolean;
  69522. /** @hidden */
  69523. _irradianceTexture: Nullable<BaseTexture>;
  69524. /** @hidden */
  69525. _webGLTexture: Nullable<WebGLTexture>;
  69526. /** @hidden */
  69527. _references: number;
  69528. private _engine;
  69529. /**
  69530. * Gets the Engine the texture belongs to.
  69531. * @returns The babylon engine
  69532. */
  69533. getEngine(): Engine;
  69534. /**
  69535. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69536. */
  69537. readonly dataSource: number;
  69538. /**
  69539. * Creates a new InternalTexture
  69540. * @param engine defines the engine to use
  69541. * @param dataSource defines the type of data that will be used
  69542. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69543. */
  69544. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69545. /**
  69546. * Increments the number of references (ie. the number of Texture that point to it)
  69547. */
  69548. incrementReferences(): void;
  69549. /**
  69550. * Change the size of the texture (not the size of the content)
  69551. * @param width defines the new width
  69552. * @param height defines the new height
  69553. * @param depth defines the new depth (1 by default)
  69554. */
  69555. updateSize(width: int, height: int, depth?: int): void;
  69556. /** @hidden */
  69557. _rebuild(): void;
  69558. /** @hidden */
  69559. _swapAndDie(target: InternalTexture): void;
  69560. /**
  69561. * Dispose the current allocated resources
  69562. */
  69563. dispose(): void;
  69564. }
  69565. }
  69566. declare module BABYLON {
  69567. /**
  69568. * This represents the main contract an easing function should follow.
  69569. * Easing functions are used throughout the animation system.
  69570. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69571. */
  69572. export interface IEasingFunction {
  69573. /**
  69574. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69575. * of the easing function.
  69576. * The link below provides some of the most common examples of easing functions.
  69577. * @see https://easings.net/
  69578. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69579. * @returns the corresponding value on the curve defined by the easing function
  69580. */
  69581. ease(gradient: number): number;
  69582. }
  69583. /**
  69584. * Base class used for every default easing function.
  69585. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69586. */
  69587. export class EasingFunction implements IEasingFunction {
  69588. /**
  69589. * Interpolation follows the mathematical formula associated with the easing function.
  69590. */
  69591. static readonly EASINGMODE_EASEIN: number;
  69592. /**
  69593. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69594. */
  69595. static readonly EASINGMODE_EASEOUT: number;
  69596. /**
  69597. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69598. */
  69599. static readonly EASINGMODE_EASEINOUT: number;
  69600. private _easingMode;
  69601. /**
  69602. * Sets the easing mode of the current function.
  69603. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69604. */
  69605. setEasingMode(easingMode: number): void;
  69606. /**
  69607. * Gets the current easing mode.
  69608. * @returns the easing mode
  69609. */
  69610. getEasingMode(): number;
  69611. /**
  69612. * @hidden
  69613. */
  69614. easeInCore(gradient: number): number;
  69615. /**
  69616. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69617. * of the easing function.
  69618. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69619. * @returns the corresponding value on the curve defined by the easing function
  69620. */
  69621. ease(gradient: number): number;
  69622. }
  69623. /**
  69624. * Easing function with a circle shape (see link below).
  69625. * @see https://easings.net/#easeInCirc
  69626. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69627. */
  69628. export class CircleEase extends EasingFunction implements IEasingFunction {
  69629. /** @hidden */
  69630. easeInCore(gradient: number): number;
  69631. }
  69632. /**
  69633. * Easing function with a ease back shape (see link below).
  69634. * @see https://easings.net/#easeInBack
  69635. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69636. */
  69637. export class BackEase extends EasingFunction implements IEasingFunction {
  69638. /** Defines the amplitude of the function */
  69639. amplitude: number;
  69640. /**
  69641. * Instantiates a back ease easing
  69642. * @see https://easings.net/#easeInBack
  69643. * @param amplitude Defines the amplitude of the function
  69644. */
  69645. constructor(
  69646. /** Defines the amplitude of the function */
  69647. amplitude?: number);
  69648. /** @hidden */
  69649. easeInCore(gradient: number): number;
  69650. }
  69651. /**
  69652. * Easing function with a bouncing shape (see link below).
  69653. * @see https://easings.net/#easeInBounce
  69654. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69655. */
  69656. export class BounceEase extends EasingFunction implements IEasingFunction {
  69657. /** Defines the number of bounces */
  69658. bounces: number;
  69659. /** Defines the amplitude of the bounce */
  69660. bounciness: number;
  69661. /**
  69662. * Instantiates a bounce easing
  69663. * @see https://easings.net/#easeInBounce
  69664. * @param bounces Defines the number of bounces
  69665. * @param bounciness Defines the amplitude of the bounce
  69666. */
  69667. constructor(
  69668. /** Defines the number of bounces */
  69669. bounces?: number,
  69670. /** Defines the amplitude of the bounce */
  69671. bounciness?: number);
  69672. /** @hidden */
  69673. easeInCore(gradient: number): number;
  69674. }
  69675. /**
  69676. * Easing function with a power of 3 shape (see link below).
  69677. * @see https://easings.net/#easeInCubic
  69678. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69679. */
  69680. export class CubicEase extends EasingFunction implements IEasingFunction {
  69681. /** @hidden */
  69682. easeInCore(gradient: number): number;
  69683. }
  69684. /**
  69685. * Easing function with an elastic shape (see link below).
  69686. * @see https://easings.net/#easeInElastic
  69687. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69688. */
  69689. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69690. /** Defines the number of oscillations*/
  69691. oscillations: number;
  69692. /** Defines the amplitude of the oscillations*/
  69693. springiness: number;
  69694. /**
  69695. * Instantiates an elastic easing function
  69696. * @see https://easings.net/#easeInElastic
  69697. * @param oscillations Defines the number of oscillations
  69698. * @param springiness Defines the amplitude of the oscillations
  69699. */
  69700. constructor(
  69701. /** Defines the number of oscillations*/
  69702. oscillations?: number,
  69703. /** Defines the amplitude of the oscillations*/
  69704. springiness?: number);
  69705. /** @hidden */
  69706. easeInCore(gradient: number): number;
  69707. }
  69708. /**
  69709. * Easing function with an exponential shape (see link below).
  69710. * @see https://easings.net/#easeInExpo
  69711. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69712. */
  69713. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69714. /** Defines the exponent of the function */
  69715. exponent: number;
  69716. /**
  69717. * Instantiates an exponential easing function
  69718. * @see https://easings.net/#easeInExpo
  69719. * @param exponent Defines the exponent of the function
  69720. */
  69721. constructor(
  69722. /** Defines the exponent of the function */
  69723. exponent?: number);
  69724. /** @hidden */
  69725. easeInCore(gradient: number): number;
  69726. }
  69727. /**
  69728. * Easing function with a power shape (see link below).
  69729. * @see https://easings.net/#easeInQuad
  69730. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69731. */
  69732. export class PowerEase extends EasingFunction implements IEasingFunction {
  69733. /** Defines the power of the function */
  69734. power: number;
  69735. /**
  69736. * Instantiates an power base easing function
  69737. * @see https://easings.net/#easeInQuad
  69738. * @param power Defines the power of the function
  69739. */
  69740. constructor(
  69741. /** Defines the power of the function */
  69742. power?: number);
  69743. /** @hidden */
  69744. easeInCore(gradient: number): number;
  69745. }
  69746. /**
  69747. * Easing function with a power of 2 shape (see link below).
  69748. * @see https://easings.net/#easeInQuad
  69749. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69750. */
  69751. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69752. /** @hidden */
  69753. easeInCore(gradient: number): number;
  69754. }
  69755. /**
  69756. * Easing function with a power of 4 shape (see link below).
  69757. * @see https://easings.net/#easeInQuart
  69758. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69759. */
  69760. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69761. /** @hidden */
  69762. easeInCore(gradient: number): number;
  69763. }
  69764. /**
  69765. * Easing function with a power of 5 shape (see link below).
  69766. * @see https://easings.net/#easeInQuint
  69767. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69768. */
  69769. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69770. /** @hidden */
  69771. easeInCore(gradient: number): number;
  69772. }
  69773. /**
  69774. * Easing function with a sin shape (see link below).
  69775. * @see https://easings.net/#easeInSine
  69776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69777. */
  69778. export class SineEase extends EasingFunction implements IEasingFunction {
  69779. /** @hidden */
  69780. easeInCore(gradient: number): number;
  69781. }
  69782. /**
  69783. * Easing function with a bezier shape (see link below).
  69784. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69785. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69786. */
  69787. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69788. /** Defines the x component of the start tangent in the bezier curve */
  69789. x1: number;
  69790. /** Defines the y component of the start tangent in the bezier curve */
  69791. y1: number;
  69792. /** Defines the x component of the end tangent in the bezier curve */
  69793. x2: number;
  69794. /** Defines the y component of the end tangent in the bezier curve */
  69795. y2: number;
  69796. /**
  69797. * Instantiates a bezier function
  69798. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69799. * @param x1 Defines the x component of the start tangent in the bezier curve
  69800. * @param y1 Defines the y component of the start tangent in the bezier curve
  69801. * @param x2 Defines the x component of the end tangent in the bezier curve
  69802. * @param y2 Defines the y component of the end tangent in the bezier curve
  69803. */
  69804. constructor(
  69805. /** Defines the x component of the start tangent in the bezier curve */
  69806. x1?: number,
  69807. /** Defines the y component of the start tangent in the bezier curve */
  69808. y1?: number,
  69809. /** Defines the x component of the end tangent in the bezier curve */
  69810. x2?: number,
  69811. /** Defines the y component of the end tangent in the bezier curve */
  69812. y2?: number);
  69813. /** @hidden */
  69814. easeInCore(gradient: number): number;
  69815. }
  69816. }
  69817. declare module BABYLON {
  69818. /**
  69819. * Defines an interface which represents an animation key frame
  69820. */
  69821. export interface IAnimationKey {
  69822. /**
  69823. * Frame of the key frame
  69824. */
  69825. frame: number;
  69826. /**
  69827. * Value at the specifies key frame
  69828. */
  69829. value: any;
  69830. /**
  69831. * The input tangent for the cubic hermite spline
  69832. */
  69833. inTangent?: any;
  69834. /**
  69835. * The output tangent for the cubic hermite spline
  69836. */
  69837. outTangent?: any;
  69838. /**
  69839. * The animation interpolation type
  69840. */
  69841. interpolation?: AnimationKeyInterpolation;
  69842. }
  69843. /**
  69844. * Enum for the animation key frame interpolation type
  69845. */
  69846. export enum AnimationKeyInterpolation {
  69847. /**
  69848. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69849. */
  69850. STEP = 1
  69851. }
  69852. }
  69853. declare module BABYLON {
  69854. /**
  69855. * Represents the range of an animation
  69856. */
  69857. export class AnimationRange {
  69858. /**The name of the animation range**/
  69859. name: string;
  69860. /**The starting frame of the animation */
  69861. from: number;
  69862. /**The ending frame of the animation*/
  69863. to: number;
  69864. /**
  69865. * Initializes the range of an animation
  69866. * @param name The name of the animation range
  69867. * @param from The starting frame of the animation
  69868. * @param to The ending frame of the animation
  69869. */
  69870. constructor(
  69871. /**The name of the animation range**/
  69872. name: string,
  69873. /**The starting frame of the animation */
  69874. from: number,
  69875. /**The ending frame of the animation*/
  69876. to: number);
  69877. /**
  69878. * Makes a copy of the animation range
  69879. * @returns A copy of the animation range
  69880. */
  69881. clone(): AnimationRange;
  69882. }
  69883. }
  69884. declare module BABYLON {
  69885. /**
  69886. * Composed of a frame, and an action function
  69887. */
  69888. export class AnimationEvent {
  69889. /** The frame for which the event is triggered **/
  69890. frame: number;
  69891. /** The event to perform when triggered **/
  69892. action: (currentFrame: number) => void;
  69893. /** Specifies if the event should be triggered only once**/
  69894. onlyOnce?: boolean | undefined;
  69895. /**
  69896. * Specifies if the animation event is done
  69897. */
  69898. isDone: boolean;
  69899. /**
  69900. * Initializes the animation event
  69901. * @param frame The frame for which the event is triggered
  69902. * @param action The event to perform when triggered
  69903. * @param onlyOnce Specifies if the event should be triggered only once
  69904. */
  69905. constructor(
  69906. /** The frame for which the event is triggered **/
  69907. frame: number,
  69908. /** The event to perform when triggered **/
  69909. action: (currentFrame: number) => void,
  69910. /** Specifies if the event should be triggered only once**/
  69911. onlyOnce?: boolean | undefined);
  69912. /** @hidden */
  69913. _clone(): AnimationEvent;
  69914. }
  69915. }
  69916. declare module BABYLON {
  69917. /**
  69918. * Interface used to define a behavior
  69919. */
  69920. export interface Behavior<T> {
  69921. /** gets or sets behavior's name */
  69922. name: string;
  69923. /**
  69924. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69925. */
  69926. init(): void;
  69927. /**
  69928. * Called when the behavior is attached to a target
  69929. * @param target defines the target where the behavior is attached to
  69930. */
  69931. attach(target: T): void;
  69932. /**
  69933. * Called when the behavior is detached from its target
  69934. */
  69935. detach(): void;
  69936. }
  69937. /**
  69938. * Interface implemented by classes supporting behaviors
  69939. */
  69940. export interface IBehaviorAware<T> {
  69941. /**
  69942. * Attach a behavior
  69943. * @param behavior defines the behavior to attach
  69944. * @returns the current host
  69945. */
  69946. addBehavior(behavior: Behavior<T>): T;
  69947. /**
  69948. * Remove a behavior from the current object
  69949. * @param behavior defines the behavior to detach
  69950. * @returns the current host
  69951. */
  69952. removeBehavior(behavior: Behavior<T>): T;
  69953. /**
  69954. * Gets a behavior using its name to search
  69955. * @param name defines the name to search
  69956. * @returns the behavior or null if not found
  69957. */
  69958. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69959. }
  69960. }
  69961. declare module BABYLON {
  69962. /**
  69963. * @hidden
  69964. */
  69965. export class IntersectionInfo {
  69966. bu: Nullable<number>;
  69967. bv: Nullable<number>;
  69968. distance: number;
  69969. faceId: number;
  69970. subMeshId: number;
  69971. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69972. }
  69973. }
  69974. declare module BABYLON {
  69975. /**
  69976. * Class used to store bounding sphere information
  69977. */
  69978. export class BoundingSphere {
  69979. /**
  69980. * Gets the center of the bounding sphere in local space
  69981. */
  69982. readonly center: Vector3;
  69983. /**
  69984. * Radius of the bounding sphere in local space
  69985. */
  69986. radius: number;
  69987. /**
  69988. * Gets the center of the bounding sphere in world space
  69989. */
  69990. readonly centerWorld: Vector3;
  69991. /**
  69992. * Radius of the bounding sphere in world space
  69993. */
  69994. radiusWorld: number;
  69995. /**
  69996. * Gets the minimum vector in local space
  69997. */
  69998. readonly minimum: Vector3;
  69999. /**
  70000. * Gets the maximum vector in local space
  70001. */
  70002. readonly maximum: Vector3;
  70003. private _worldMatrix;
  70004. private static readonly TmpVector3;
  70005. /**
  70006. * Creates a new bounding sphere
  70007. * @param min defines the minimum vector (in local space)
  70008. * @param max defines the maximum vector (in local space)
  70009. * @param worldMatrix defines the new world matrix
  70010. */
  70011. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70012. /**
  70013. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70014. * @param min defines the new minimum vector (in local space)
  70015. * @param max defines the new maximum vector (in local space)
  70016. * @param worldMatrix defines the new world matrix
  70017. */
  70018. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70019. /**
  70020. * Scale the current bounding sphere by applying a scale factor
  70021. * @param factor defines the scale factor to apply
  70022. * @returns the current bounding box
  70023. */
  70024. scale(factor: number): BoundingSphere;
  70025. /**
  70026. * Gets the world matrix of the bounding box
  70027. * @returns a matrix
  70028. */
  70029. getWorldMatrix(): DeepImmutable<Matrix>;
  70030. /** @hidden */
  70031. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70032. /**
  70033. * Tests if the bounding sphere is intersecting the frustum planes
  70034. * @param frustumPlanes defines the frustum planes to test
  70035. * @returns true if there is an intersection
  70036. */
  70037. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70038. /**
  70039. * Tests if the bounding sphere center is in between the frustum planes.
  70040. * Used for optimistic fast inclusion.
  70041. * @param frustumPlanes defines the frustum planes to test
  70042. * @returns true if the sphere center is in between the frustum planes
  70043. */
  70044. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70045. /**
  70046. * Tests if a point is inside the bounding sphere
  70047. * @param point defines the point to test
  70048. * @returns true if the point is inside the bounding sphere
  70049. */
  70050. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70051. /**
  70052. * Checks if two sphere intersct
  70053. * @param sphere0 sphere 0
  70054. * @param sphere1 sphere 1
  70055. * @returns true if the speres intersect
  70056. */
  70057. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70058. }
  70059. }
  70060. declare module BABYLON {
  70061. /**
  70062. * Class used to store bounding box information
  70063. */
  70064. export class BoundingBox implements ICullable {
  70065. /**
  70066. * Gets the 8 vectors representing the bounding box in local space
  70067. */
  70068. readonly vectors: Vector3[];
  70069. /**
  70070. * Gets the center of the bounding box in local space
  70071. */
  70072. readonly center: Vector3;
  70073. /**
  70074. * Gets the center of the bounding box in world space
  70075. */
  70076. readonly centerWorld: Vector3;
  70077. /**
  70078. * Gets the extend size in local space
  70079. */
  70080. readonly extendSize: Vector3;
  70081. /**
  70082. * Gets the extend size in world space
  70083. */
  70084. readonly extendSizeWorld: Vector3;
  70085. /**
  70086. * Gets the OBB (object bounding box) directions
  70087. */
  70088. readonly directions: Vector3[];
  70089. /**
  70090. * Gets the 8 vectors representing the bounding box in world space
  70091. */
  70092. readonly vectorsWorld: Vector3[];
  70093. /**
  70094. * Gets the minimum vector in world space
  70095. */
  70096. readonly minimumWorld: Vector3;
  70097. /**
  70098. * Gets the maximum vector in world space
  70099. */
  70100. readonly maximumWorld: Vector3;
  70101. /**
  70102. * Gets the minimum vector in local space
  70103. */
  70104. readonly minimum: Vector3;
  70105. /**
  70106. * Gets the maximum vector in local space
  70107. */
  70108. readonly maximum: Vector3;
  70109. private _worldMatrix;
  70110. private static readonly TmpVector3;
  70111. /**
  70112. * @hidden
  70113. */
  70114. _tag: number;
  70115. /**
  70116. * Creates a new bounding box
  70117. * @param min defines the minimum vector (in local space)
  70118. * @param max defines the maximum vector (in local space)
  70119. * @param worldMatrix defines the new world matrix
  70120. */
  70121. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70122. /**
  70123. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70124. * @param min defines the new minimum vector (in local space)
  70125. * @param max defines the new maximum vector (in local space)
  70126. * @param worldMatrix defines the new world matrix
  70127. */
  70128. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70129. /**
  70130. * Scale the current bounding box by applying a scale factor
  70131. * @param factor defines the scale factor to apply
  70132. * @returns the current bounding box
  70133. */
  70134. scale(factor: number): BoundingBox;
  70135. /**
  70136. * Gets the world matrix of the bounding box
  70137. * @returns a matrix
  70138. */
  70139. getWorldMatrix(): DeepImmutable<Matrix>;
  70140. /** @hidden */
  70141. _update(world: DeepImmutable<Matrix>): void;
  70142. /**
  70143. * Tests if the bounding box is intersecting the frustum planes
  70144. * @param frustumPlanes defines the frustum planes to test
  70145. * @returns true if there is an intersection
  70146. */
  70147. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70148. /**
  70149. * Tests if the bounding box is entirely inside the frustum planes
  70150. * @param frustumPlanes defines the frustum planes to test
  70151. * @returns true if there is an inclusion
  70152. */
  70153. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70154. /**
  70155. * Tests if a point is inside the bounding box
  70156. * @param point defines the point to test
  70157. * @returns true if the point is inside the bounding box
  70158. */
  70159. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70160. /**
  70161. * Tests if the bounding box intersects with a bounding sphere
  70162. * @param sphere defines the sphere to test
  70163. * @returns true if there is an intersection
  70164. */
  70165. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70166. /**
  70167. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70168. * @param min defines the min vector to use
  70169. * @param max defines the max vector to use
  70170. * @returns true if there is an intersection
  70171. */
  70172. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70173. /**
  70174. * Tests if two bounding boxes are intersections
  70175. * @param box0 defines the first box to test
  70176. * @param box1 defines the second box to test
  70177. * @returns true if there is an intersection
  70178. */
  70179. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70180. /**
  70181. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70182. * @param minPoint defines the minimum vector of the bounding box
  70183. * @param maxPoint defines the maximum vector of the bounding box
  70184. * @param sphereCenter defines the sphere center
  70185. * @param sphereRadius defines the sphere radius
  70186. * @returns true if there is an intersection
  70187. */
  70188. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70189. /**
  70190. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70191. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70192. * @param frustumPlanes defines the frustum planes to test
  70193. * @return true if there is an inclusion
  70194. */
  70195. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70196. /**
  70197. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70198. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70199. * @param frustumPlanes defines the frustum planes to test
  70200. * @return true if there is an intersection
  70201. */
  70202. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70203. }
  70204. }
  70205. declare module BABYLON {
  70206. /** @hidden */
  70207. export class Collider {
  70208. /** Define if a collision was found */
  70209. collisionFound: boolean;
  70210. /**
  70211. * Define last intersection point in local space
  70212. */
  70213. intersectionPoint: Vector3;
  70214. /**
  70215. * Define last collided mesh
  70216. */
  70217. collidedMesh: Nullable<AbstractMesh>;
  70218. private _collisionPoint;
  70219. private _planeIntersectionPoint;
  70220. private _tempVector;
  70221. private _tempVector2;
  70222. private _tempVector3;
  70223. private _tempVector4;
  70224. private _edge;
  70225. private _baseToVertex;
  70226. private _destinationPoint;
  70227. private _slidePlaneNormal;
  70228. private _displacementVector;
  70229. /** @hidden */
  70230. _radius: Vector3;
  70231. /** @hidden */
  70232. _retry: number;
  70233. private _velocity;
  70234. private _basePoint;
  70235. private _epsilon;
  70236. /** @hidden */
  70237. _velocityWorldLength: number;
  70238. /** @hidden */
  70239. _basePointWorld: Vector3;
  70240. private _velocityWorld;
  70241. private _normalizedVelocity;
  70242. /** @hidden */
  70243. _initialVelocity: Vector3;
  70244. /** @hidden */
  70245. _initialPosition: Vector3;
  70246. private _nearestDistance;
  70247. private _collisionMask;
  70248. collisionMask: number;
  70249. /**
  70250. * Gets the plane normal used to compute the sliding response (in local space)
  70251. */
  70252. readonly slidePlaneNormal: Vector3;
  70253. /** @hidden */
  70254. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70255. /** @hidden */
  70256. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70257. /** @hidden */
  70258. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70259. /** @hidden */
  70260. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  70261. /** @hidden */
  70262. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  70263. /** @hidden */
  70264. _getResponse(pos: Vector3, vel: Vector3): void;
  70265. }
  70266. }
  70267. declare module BABYLON {
  70268. /**
  70269. * Interface for cullable objects
  70270. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70271. */
  70272. export interface ICullable {
  70273. /**
  70274. * Checks if the object or part of the object is in the frustum
  70275. * @param frustumPlanes Camera near/planes
  70276. * @returns true if the object is in frustum otherwise false
  70277. */
  70278. isInFrustum(frustumPlanes: Plane[]): boolean;
  70279. /**
  70280. * Checks if a cullable object (mesh...) is in the camera frustum
  70281. * Unlike isInFrustum this cheks the full bounding box
  70282. * @param frustumPlanes Camera near/planes
  70283. * @returns true if the object is in frustum otherwise false
  70284. */
  70285. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70286. }
  70287. /**
  70288. * Info for a bounding data of a mesh
  70289. */
  70290. export class BoundingInfo implements ICullable {
  70291. /**
  70292. * Bounding box for the mesh
  70293. */
  70294. readonly boundingBox: BoundingBox;
  70295. /**
  70296. * Bounding sphere for the mesh
  70297. */
  70298. readonly boundingSphere: BoundingSphere;
  70299. private _isLocked;
  70300. private static readonly TmpVector3;
  70301. /**
  70302. * Constructs bounding info
  70303. * @param minimum min vector of the bounding box/sphere
  70304. * @param maximum max vector of the bounding box/sphere
  70305. * @param worldMatrix defines the new world matrix
  70306. */
  70307. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70308. /**
  70309. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70310. * @param min defines the new minimum vector (in local space)
  70311. * @param max defines the new maximum vector (in local space)
  70312. * @param worldMatrix defines the new world matrix
  70313. */
  70314. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70315. /**
  70316. * min vector of the bounding box/sphere
  70317. */
  70318. readonly minimum: Vector3;
  70319. /**
  70320. * max vector of the bounding box/sphere
  70321. */
  70322. readonly maximum: Vector3;
  70323. /**
  70324. * If the info is locked and won't be updated to avoid perf overhead
  70325. */
  70326. isLocked: boolean;
  70327. /**
  70328. * Updates the bounding sphere and box
  70329. * @param world world matrix to be used to update
  70330. */
  70331. update(world: DeepImmutable<Matrix>): void;
  70332. /**
  70333. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70334. * @param center New center of the bounding info
  70335. * @param extend New extend of the bounding info
  70336. * @returns the current bounding info
  70337. */
  70338. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70339. /**
  70340. * Scale the current bounding info by applying a scale factor
  70341. * @param factor defines the scale factor to apply
  70342. * @returns the current bounding info
  70343. */
  70344. scale(factor: number): BoundingInfo;
  70345. /**
  70346. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70347. * @param frustumPlanes defines the frustum to test
  70348. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70349. * @returns true if the bounding info is in the frustum planes
  70350. */
  70351. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70352. /**
  70353. * Gets the world distance between the min and max points of the bounding box
  70354. */
  70355. readonly diagonalLength: number;
  70356. /**
  70357. * Checks if a cullable object (mesh...) is in the camera frustum
  70358. * Unlike isInFrustum this cheks the full bounding box
  70359. * @param frustumPlanes Camera near/planes
  70360. * @returns true if the object is in frustum otherwise false
  70361. */
  70362. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70363. /** @hidden */
  70364. _checkCollision(collider: Collider): boolean;
  70365. /**
  70366. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70367. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70368. * @param point the point to check intersection with
  70369. * @returns if the point intersects
  70370. */
  70371. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70372. /**
  70373. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70374. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70375. * @param boundingInfo the bounding info to check intersection with
  70376. * @param precise if the intersection should be done using OBB
  70377. * @returns if the bounding info intersects
  70378. */
  70379. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70380. }
  70381. }
  70382. declare module BABYLON {
  70383. /**
  70384. * Defines an array and its length.
  70385. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70386. */
  70387. export interface ISmartArrayLike<T> {
  70388. /**
  70389. * The data of the array.
  70390. */
  70391. data: Array<T>;
  70392. /**
  70393. * The active length of the array.
  70394. */
  70395. length: number;
  70396. }
  70397. /**
  70398. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70399. */
  70400. export class SmartArray<T> implements ISmartArrayLike<T> {
  70401. /**
  70402. * The full set of data from the array.
  70403. */
  70404. data: Array<T>;
  70405. /**
  70406. * The active length of the array.
  70407. */
  70408. length: number;
  70409. protected _id: number;
  70410. /**
  70411. * Instantiates a Smart Array.
  70412. * @param capacity defines the default capacity of the array.
  70413. */
  70414. constructor(capacity: number);
  70415. /**
  70416. * Pushes a value at the end of the active data.
  70417. * @param value defines the object to push in the array.
  70418. */
  70419. push(value: T): void;
  70420. /**
  70421. * Iterates over the active data and apply the lambda to them.
  70422. * @param func defines the action to apply on each value.
  70423. */
  70424. forEach(func: (content: T) => void): void;
  70425. /**
  70426. * Sorts the full sets of data.
  70427. * @param compareFn defines the comparison function to apply.
  70428. */
  70429. sort(compareFn: (a: T, b: T) => number): void;
  70430. /**
  70431. * Resets the active data to an empty array.
  70432. */
  70433. reset(): void;
  70434. /**
  70435. * Releases all the data from the array as well as the array.
  70436. */
  70437. dispose(): void;
  70438. /**
  70439. * Concats the active data with a given array.
  70440. * @param array defines the data to concatenate with.
  70441. */
  70442. concat(array: any): void;
  70443. /**
  70444. * Returns the position of a value in the active data.
  70445. * @param value defines the value to find the index for
  70446. * @returns the index if found in the active data otherwise -1
  70447. */
  70448. indexOf(value: T): number;
  70449. /**
  70450. * Returns whether an element is part of the active data.
  70451. * @param value defines the value to look for
  70452. * @returns true if found in the active data otherwise false
  70453. */
  70454. contains(value: T): boolean;
  70455. private static _GlobalId;
  70456. }
  70457. /**
  70458. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70459. * The data in this array can only be present once
  70460. */
  70461. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70462. private _duplicateId;
  70463. /**
  70464. * Pushes a value at the end of the active data.
  70465. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70466. * @param value defines the object to push in the array.
  70467. */
  70468. push(value: T): void;
  70469. /**
  70470. * Pushes a value at the end of the active data.
  70471. * If the data is already present, it won t be added again
  70472. * @param value defines the object to push in the array.
  70473. * @returns true if added false if it was already present
  70474. */
  70475. pushNoDuplicate(value: T): boolean;
  70476. /**
  70477. * Resets the active data to an empty array.
  70478. */
  70479. reset(): void;
  70480. /**
  70481. * Concats the active data with a given array.
  70482. * This ensures no dupplicate will be present in the result.
  70483. * @param array defines the data to concatenate with.
  70484. */
  70485. concatWithNoDuplicate(array: any): void;
  70486. }
  70487. }
  70488. declare module BABYLON {
  70489. /**
  70490. * Enum that determines the text-wrapping mode to use.
  70491. */
  70492. export enum InspectableType {
  70493. /**
  70494. * Checkbox for booleans
  70495. */
  70496. Checkbox = 0,
  70497. /**
  70498. * Sliders for numbers
  70499. */
  70500. Slider = 1,
  70501. /**
  70502. * Vector3
  70503. */
  70504. Vector3 = 2,
  70505. /**
  70506. * Quaternions
  70507. */
  70508. Quaternion = 3,
  70509. /**
  70510. * Color3
  70511. */
  70512. Color3 = 4
  70513. }
  70514. /**
  70515. * Interface used to define custom inspectable properties.
  70516. * This interface is used by the inspector to display custom property grids
  70517. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70518. */
  70519. export interface IInspectable {
  70520. /**
  70521. * Gets the label to display
  70522. */
  70523. label: string;
  70524. /**
  70525. * Gets the name of the property to edit
  70526. */
  70527. propertyName: string;
  70528. /**
  70529. * Gets the type of the editor to use
  70530. */
  70531. type: InspectableType;
  70532. /**
  70533. * Gets the minimum value of the property when using in "slider" mode
  70534. */
  70535. min?: number;
  70536. /**
  70537. * Gets the maximum value of the property when using in "slider" mode
  70538. */
  70539. max?: number;
  70540. /**
  70541. * Gets the setp to use when using in "slider" mode
  70542. */
  70543. step?: number;
  70544. }
  70545. }
  70546. declare module BABYLON {
  70547. /**
  70548. * This represents the required contract to create a new type of texture loader.
  70549. */
  70550. export interface IInternalTextureLoader {
  70551. /**
  70552. * Defines wether the loader supports cascade loading the different faces.
  70553. */
  70554. supportCascades: boolean;
  70555. /**
  70556. * This returns if the loader support the current file information.
  70557. * @param extension defines the file extension of the file being loaded
  70558. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70559. * @param fallback defines the fallback internal texture if any
  70560. * @param isBase64 defines whether the texture is encoded as a base64
  70561. * @param isBuffer defines whether the texture data are stored as a buffer
  70562. * @returns true if the loader can load the specified file
  70563. */
  70564. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70565. /**
  70566. * Transform the url before loading if required.
  70567. * @param rootUrl the url of the texture
  70568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70569. * @returns the transformed texture
  70570. */
  70571. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70572. /**
  70573. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70574. * @param rootUrl the url of the texture
  70575. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70576. * @returns the fallback texture
  70577. */
  70578. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70579. /**
  70580. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70581. * @param data contains the texture data
  70582. * @param texture defines the BabylonJS internal texture
  70583. * @param createPolynomials will be true if polynomials have been requested
  70584. * @param onLoad defines the callback to trigger once the texture is ready
  70585. * @param onError defines the callback to trigger in case of error
  70586. */
  70587. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70588. /**
  70589. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70590. * @param data contains the texture data
  70591. * @param texture defines the BabylonJS internal texture
  70592. * @param callback defines the method to call once ready to upload
  70593. */
  70594. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70595. }
  70596. }
  70597. declare module BABYLON {
  70598. interface Engine {
  70599. /**
  70600. * Creates a depth stencil cube texture.
  70601. * This is only available in WebGL 2.
  70602. * @param size The size of face edge in the cube texture.
  70603. * @param options The options defining the cube texture.
  70604. * @returns The cube texture
  70605. */
  70606. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70607. /**
  70608. * Creates a cube texture
  70609. * @param rootUrl defines the url where the files to load is located
  70610. * @param scene defines the current scene
  70611. * @param files defines the list of files to load (1 per face)
  70612. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70613. * @param onLoad defines an optional callback raised when the texture is loaded
  70614. * @param onError defines an optional callback raised if there is an issue to load the texture
  70615. * @param format defines the format of the data
  70616. * @param forcedExtension defines the extension to use to pick the right loader
  70617. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70618. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70619. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70620. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70621. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70622. * @returns the cube texture as an InternalTexture
  70623. */
  70624. 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;
  70625. /**
  70626. * Creates a cube texture
  70627. * @param rootUrl defines the url where the files to load is located
  70628. * @param scene defines the current scene
  70629. * @param files defines the list of files to load (1 per face)
  70630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70631. * @param onLoad defines an optional callback raised when the texture is loaded
  70632. * @param onError defines an optional callback raised if there is an issue to load the texture
  70633. * @param format defines the format of the data
  70634. * @param forcedExtension defines the extension to use to pick the right loader
  70635. * @returns the cube texture as an InternalTexture
  70636. */
  70637. 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;
  70638. /**
  70639. * Creates a cube texture
  70640. * @param rootUrl defines the url where the files to load is located
  70641. * @param scene defines the current scene
  70642. * @param files defines the list of files to load (1 per face)
  70643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70644. * @param onLoad defines an optional callback raised when the texture is loaded
  70645. * @param onError defines an optional callback raised if there is an issue to load the texture
  70646. * @param format defines the format of the data
  70647. * @param forcedExtension defines the extension to use to pick the right loader
  70648. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70649. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70650. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70651. * @returns the cube texture as an InternalTexture
  70652. */
  70653. 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;
  70654. /** @hidden */
  70655. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70656. /** @hidden */
  70657. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70658. /** @hidden */
  70659. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70660. /** @hidden */
  70661. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70662. }
  70663. }
  70664. declare module BABYLON {
  70665. /**
  70666. * Class for creating a cube texture
  70667. */
  70668. export class CubeTexture extends BaseTexture {
  70669. private _delayedOnLoad;
  70670. /**
  70671. * The url of the texture
  70672. */
  70673. url: string;
  70674. /**
  70675. * Gets or sets the center of the bounding box associated with the cube texture.
  70676. * It must define where the camera used to render the texture was set
  70677. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70678. */
  70679. boundingBoxPosition: Vector3;
  70680. private _boundingBoxSize;
  70681. /**
  70682. * Gets or sets the size of the bounding box associated with the cube texture
  70683. * When defined, the cubemap will switch to local mode
  70684. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70685. * @example https://www.babylonjs-playground.com/#RNASML
  70686. */
  70687. /**
  70688. * Returns the bounding box size
  70689. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70690. */
  70691. boundingBoxSize: Vector3;
  70692. protected _rotationY: number;
  70693. /**
  70694. * Sets texture matrix rotation angle around Y axis in radians.
  70695. */
  70696. /**
  70697. * Gets texture matrix rotation angle around Y axis radians.
  70698. */
  70699. rotationY: number;
  70700. /**
  70701. * Are mip maps generated for this texture or not.
  70702. */
  70703. readonly noMipmap: boolean;
  70704. private _noMipmap;
  70705. private _files;
  70706. private _extensions;
  70707. private _textureMatrix;
  70708. private _format;
  70709. private _createPolynomials;
  70710. /** @hidden */
  70711. _prefiltered: boolean;
  70712. /**
  70713. * Creates a cube texture from an array of image urls
  70714. * @param files defines an array of image urls
  70715. * @param scene defines the hosting scene
  70716. * @param noMipmap specifies if mip maps are not used
  70717. * @returns a cube texture
  70718. */
  70719. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70720. /**
  70721. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70722. * @param url defines the url of the prefiltered texture
  70723. * @param scene defines the scene the texture is attached to
  70724. * @param forcedExtension defines the extension of the file if different from the url
  70725. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70726. * @return the prefiltered texture
  70727. */
  70728. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70729. /**
  70730. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70731. * as prefiltered data.
  70732. * @param rootUrl defines the url of the texture or the root name of the six images
  70733. * @param scene defines the scene the texture is attached to
  70734. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70735. * @param noMipmap defines if mipmaps should be created or not
  70736. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70737. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70738. * @param onError defines a callback triggered in case of error during load
  70739. * @param format defines the internal format to use for the texture once loaded
  70740. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70741. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70742. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70743. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70744. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70745. * @return the cube texture
  70746. */
  70747. 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);
  70748. /**
  70749. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70750. */
  70751. readonly isPrefiltered: boolean;
  70752. /**
  70753. * Get the current class name of the texture useful for serialization or dynamic coding.
  70754. * @returns "CubeTexture"
  70755. */
  70756. getClassName(): string;
  70757. /**
  70758. * Update the url (and optional buffer) of this texture if url was null during construction.
  70759. * @param url the url of the texture
  70760. * @param forcedExtension defines the extension to use
  70761. * @param onLoad callback called when the texture is loaded (defaults to null)
  70762. */
  70763. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70764. /**
  70765. * Delays loading of the cube texture
  70766. * @param forcedExtension defines the extension to use
  70767. */
  70768. delayLoad(forcedExtension?: string): void;
  70769. /**
  70770. * Returns the reflection texture matrix
  70771. * @returns the reflection texture matrix
  70772. */
  70773. getReflectionTextureMatrix(): Matrix;
  70774. /**
  70775. * Sets the reflection texture matrix
  70776. * @param value Reflection texture matrix
  70777. */
  70778. setReflectionTextureMatrix(value: Matrix): void;
  70779. /**
  70780. * Parses text to create a cube texture
  70781. * @param parsedTexture define the serialized text to read from
  70782. * @param scene defines the hosting scene
  70783. * @param rootUrl defines the root url of the cube texture
  70784. * @returns a cube texture
  70785. */
  70786. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70787. /**
  70788. * Makes a clone, or deep copy, of the cube texture
  70789. * @returns a new cube texture
  70790. */
  70791. clone(): CubeTexture;
  70792. }
  70793. }
  70794. declare module BABYLON {
  70795. /** @hidden */
  70796. export var postprocessVertexShader: {
  70797. name: string;
  70798. shader: string;
  70799. };
  70800. }
  70801. declare module BABYLON {
  70802. /**
  70803. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70804. * This is the base of the follow, arc rotate cameras and Free camera
  70805. * @see http://doc.babylonjs.com/features/cameras
  70806. */
  70807. export class TargetCamera extends Camera {
  70808. private static _RigCamTransformMatrix;
  70809. private static _TargetTransformMatrix;
  70810. private static _TargetFocalPoint;
  70811. /**
  70812. * Define the current direction the camera is moving to
  70813. */
  70814. cameraDirection: Vector3;
  70815. /**
  70816. * Define the current rotation the camera is rotating to
  70817. */
  70818. cameraRotation: Vector2;
  70819. /**
  70820. * When set, the up vector of the camera will be updated by the rotation of the camera
  70821. */
  70822. updateUpVectorFromRotation: boolean;
  70823. private _tmpQuaternion;
  70824. /**
  70825. * Define the current rotation of the camera
  70826. */
  70827. rotation: Vector3;
  70828. /**
  70829. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70830. */
  70831. rotationQuaternion: Quaternion;
  70832. /**
  70833. * Define the current speed of the camera
  70834. */
  70835. speed: number;
  70836. /**
  70837. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70838. * around all axis.
  70839. */
  70840. noRotationConstraint: boolean;
  70841. /**
  70842. * Define the current target of the camera as an object or a position.
  70843. */
  70844. lockedTarget: any;
  70845. /** @hidden */
  70846. _currentTarget: Vector3;
  70847. /** @hidden */
  70848. _initialFocalDistance: number;
  70849. /** @hidden */
  70850. _viewMatrix: Matrix;
  70851. /** @hidden */
  70852. _camMatrix: Matrix;
  70853. /** @hidden */
  70854. _cameraTransformMatrix: Matrix;
  70855. /** @hidden */
  70856. _cameraRotationMatrix: Matrix;
  70857. /** @hidden */
  70858. _referencePoint: Vector3;
  70859. /** @hidden */
  70860. _transformedReferencePoint: Vector3;
  70861. protected _globalCurrentTarget: Vector3;
  70862. protected _globalCurrentUpVector: Vector3;
  70863. /** @hidden */
  70864. _reset: () => void;
  70865. private _defaultUp;
  70866. /**
  70867. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70868. * This is the base of the follow, arc rotate cameras and Free camera
  70869. * @see http://doc.babylonjs.com/features/cameras
  70870. * @param name Defines the name of the camera in the scene
  70871. * @param position Defines the start position of the camera in the scene
  70872. * @param scene Defines the scene the camera belongs to
  70873. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70874. */
  70875. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70876. /**
  70877. * Gets the position in front of the camera at a given distance.
  70878. * @param distance The distance from the camera we want the position to be
  70879. * @returns the position
  70880. */
  70881. getFrontPosition(distance: number): Vector3;
  70882. /** @hidden */
  70883. _getLockedTargetPosition(): Nullable<Vector3>;
  70884. private _storedPosition;
  70885. private _storedRotation;
  70886. private _storedRotationQuaternion;
  70887. /**
  70888. * Store current camera state of the camera (fov, position, rotation, etc..)
  70889. * @returns the camera
  70890. */
  70891. storeState(): Camera;
  70892. /**
  70893. * Restored camera state. You must call storeState() first
  70894. * @returns whether it was successful or not
  70895. * @hidden
  70896. */
  70897. _restoreStateValues(): boolean;
  70898. /** @hidden */
  70899. _initCache(): void;
  70900. /** @hidden */
  70901. _updateCache(ignoreParentClass?: boolean): void;
  70902. /** @hidden */
  70903. _isSynchronizedViewMatrix(): boolean;
  70904. /** @hidden */
  70905. _computeLocalCameraSpeed(): number;
  70906. /**
  70907. * Defines the target the camera should look at.
  70908. * This will automatically adapt alpha beta and radius to fit within the new target.
  70909. * @param target Defines the new target as a Vector or a mesh
  70910. */
  70911. setTarget(target: Vector3): void;
  70912. /**
  70913. * Return the current target position of the camera. This value is expressed in local space.
  70914. * @returns the target position
  70915. */
  70916. getTarget(): Vector3;
  70917. /** @hidden */
  70918. _decideIfNeedsToMove(): boolean;
  70919. /** @hidden */
  70920. _updatePosition(): void;
  70921. /** @hidden */
  70922. _checkInputs(): void;
  70923. protected _updateCameraRotationMatrix(): void;
  70924. /**
  70925. * 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)
  70926. * @returns the current camera
  70927. */
  70928. private _rotateUpVectorWithCameraRotationMatrix;
  70929. private _cachedRotationZ;
  70930. private _cachedQuaternionRotationZ;
  70931. /** @hidden */
  70932. _getViewMatrix(): Matrix;
  70933. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70934. /**
  70935. * @hidden
  70936. */
  70937. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70938. /**
  70939. * @hidden
  70940. */
  70941. _updateRigCameras(): void;
  70942. private _getRigCamPositionAndTarget;
  70943. /**
  70944. * Gets the current object class name.
  70945. * @return the class name
  70946. */
  70947. getClassName(): string;
  70948. }
  70949. }
  70950. declare module BABYLON {
  70951. /**
  70952. * @ignore
  70953. * This is a list of all the different input types that are available in the application.
  70954. * Fo instance: ArcRotateCameraGamepadInput...
  70955. */
  70956. export var CameraInputTypes: {};
  70957. /**
  70958. * This is the contract to implement in order to create a new input class.
  70959. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70960. */
  70961. export interface ICameraInput<TCamera extends Camera> {
  70962. /**
  70963. * Defines the camera the input is attached to.
  70964. */
  70965. camera: Nullable<TCamera>;
  70966. /**
  70967. * Gets the class name of the current intput.
  70968. * @returns the class name
  70969. */
  70970. getClassName(): string;
  70971. /**
  70972. * Get the friendly name associated with the input class.
  70973. * @returns the input friendly name
  70974. */
  70975. getSimpleName(): string;
  70976. /**
  70977. * Attach the input controls to a specific dom element to get the input from.
  70978. * @param element Defines the element the controls should be listened from
  70979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70980. */
  70981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70982. /**
  70983. * Detach the current controls from the specified dom element.
  70984. * @param element Defines the element to stop listening the inputs from
  70985. */
  70986. detachControl(element: Nullable<HTMLElement>): void;
  70987. /**
  70988. * Update the current camera state depending on the inputs that have been used this frame.
  70989. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70990. */
  70991. checkInputs?: () => void;
  70992. }
  70993. /**
  70994. * Represents a map of input types to input instance or input index to input instance.
  70995. */
  70996. export interface CameraInputsMap<TCamera extends Camera> {
  70997. /**
  70998. * Accessor to the input by input type.
  70999. */
  71000. [name: string]: ICameraInput<TCamera>;
  71001. /**
  71002. * Accessor to the input by input index.
  71003. */
  71004. [idx: number]: ICameraInput<TCamera>;
  71005. }
  71006. /**
  71007. * This represents the input manager used within a camera.
  71008. * It helps dealing with all the different kind of input attached to a camera.
  71009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71010. */
  71011. export class CameraInputsManager<TCamera extends Camera> {
  71012. /**
  71013. * Defines the list of inputs attahed to the camera.
  71014. */
  71015. attached: CameraInputsMap<TCamera>;
  71016. /**
  71017. * Defines the dom element the camera is collecting inputs from.
  71018. * This is null if the controls have not been attached.
  71019. */
  71020. attachedElement: Nullable<HTMLElement>;
  71021. /**
  71022. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71023. */
  71024. noPreventDefault: boolean;
  71025. /**
  71026. * Defined the camera the input manager belongs to.
  71027. */
  71028. camera: TCamera;
  71029. /**
  71030. * Update the current camera state depending on the inputs that have been used this frame.
  71031. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71032. */
  71033. checkInputs: () => void;
  71034. /**
  71035. * Instantiate a new Camera Input Manager.
  71036. * @param camera Defines the camera the input manager blongs to
  71037. */
  71038. constructor(camera: TCamera);
  71039. /**
  71040. * Add an input method to a camera
  71041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71042. * @param input camera input method
  71043. */
  71044. add(input: ICameraInput<TCamera>): void;
  71045. /**
  71046. * Remove a specific input method from a camera
  71047. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71048. * @param inputToRemove camera input method
  71049. */
  71050. remove(inputToRemove: ICameraInput<TCamera>): void;
  71051. /**
  71052. * Remove a specific input type from a camera
  71053. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71054. * @param inputType the type of the input to remove
  71055. */
  71056. removeByType(inputType: string): void;
  71057. private _addCheckInputs;
  71058. /**
  71059. * Attach the input controls to the currently attached dom element to listen the events from.
  71060. * @param input Defines the input to attach
  71061. */
  71062. attachInput(input: ICameraInput<TCamera>): void;
  71063. /**
  71064. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71065. * @param element Defines the dom element to collect the events from
  71066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71067. */
  71068. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71069. /**
  71070. * Detach the current manager inputs controls from a specific dom element.
  71071. * @param element Defines the dom element to collect the events from
  71072. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71073. */
  71074. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71075. /**
  71076. * Rebuild the dynamic inputCheck function from the current list of
  71077. * defined inputs in the manager.
  71078. */
  71079. rebuildInputCheck(): void;
  71080. /**
  71081. * Remove all attached input methods from a camera
  71082. */
  71083. clear(): void;
  71084. /**
  71085. * Serialize the current input manager attached to a camera.
  71086. * This ensures than once parsed,
  71087. * the input associated to the camera will be identical to the current ones
  71088. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71089. */
  71090. serialize(serializedCamera: any): void;
  71091. /**
  71092. * Parses an input manager serialized JSON to restore the previous list of inputs
  71093. * and states associated to a camera.
  71094. * @param parsedCamera Defines the JSON to parse
  71095. */
  71096. parse(parsedCamera: any): void;
  71097. }
  71098. }
  71099. declare module BABYLON {
  71100. /**
  71101. * Gather the list of keyboard event types as constants.
  71102. */
  71103. export class KeyboardEventTypes {
  71104. /**
  71105. * The keydown event is fired when a key becomes active (pressed).
  71106. */
  71107. static readonly KEYDOWN: number;
  71108. /**
  71109. * The keyup event is fired when a key has been released.
  71110. */
  71111. static readonly KEYUP: number;
  71112. }
  71113. /**
  71114. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71115. */
  71116. export class KeyboardInfo {
  71117. /**
  71118. * Defines the type of event (KeyboardEventTypes)
  71119. */
  71120. type: number;
  71121. /**
  71122. * Defines the related dom event
  71123. */
  71124. event: KeyboardEvent;
  71125. /**
  71126. * Instantiates a new keyboard info.
  71127. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71128. * @param type Defines the type of event (KeyboardEventTypes)
  71129. * @param event Defines the related dom event
  71130. */
  71131. constructor(
  71132. /**
  71133. * Defines the type of event (KeyboardEventTypes)
  71134. */
  71135. type: number,
  71136. /**
  71137. * Defines the related dom event
  71138. */
  71139. event: KeyboardEvent);
  71140. }
  71141. /**
  71142. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71143. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71144. */
  71145. export class KeyboardInfoPre extends KeyboardInfo {
  71146. /**
  71147. * Defines the type of event (KeyboardEventTypes)
  71148. */
  71149. type: number;
  71150. /**
  71151. * Defines the related dom event
  71152. */
  71153. event: KeyboardEvent;
  71154. /**
  71155. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71156. */
  71157. skipOnPointerObservable: boolean;
  71158. /**
  71159. * Instantiates a new keyboard pre info.
  71160. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71161. * @param type Defines the type of event (KeyboardEventTypes)
  71162. * @param event Defines the related dom event
  71163. */
  71164. constructor(
  71165. /**
  71166. * Defines the type of event (KeyboardEventTypes)
  71167. */
  71168. type: number,
  71169. /**
  71170. * Defines the related dom event
  71171. */
  71172. event: KeyboardEvent);
  71173. }
  71174. }
  71175. declare module BABYLON {
  71176. /**
  71177. * Manage the keyboard inputs to control the movement of a free camera.
  71178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71179. */
  71180. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71181. /**
  71182. * Defines the camera the input is attached to.
  71183. */
  71184. camera: FreeCamera;
  71185. /**
  71186. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71187. */
  71188. keysUp: number[];
  71189. /**
  71190. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71191. */
  71192. keysDown: number[];
  71193. /**
  71194. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71195. */
  71196. keysLeft: number[];
  71197. /**
  71198. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71199. */
  71200. keysRight: number[];
  71201. private _keys;
  71202. private _onCanvasBlurObserver;
  71203. private _onKeyboardObserver;
  71204. private _engine;
  71205. private _scene;
  71206. /**
  71207. * Attach the input controls to a specific dom element to get the input from.
  71208. * @param element Defines the element the controls should be listened from
  71209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71210. */
  71211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71212. /**
  71213. * Detach the current controls from the specified dom element.
  71214. * @param element Defines the element to stop listening the inputs from
  71215. */
  71216. detachControl(element: Nullable<HTMLElement>): void;
  71217. /**
  71218. * Update the current camera state depending on the inputs that have been used this frame.
  71219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71220. */
  71221. checkInputs(): void;
  71222. /**
  71223. * Gets the class name of the current intput.
  71224. * @returns the class name
  71225. */
  71226. getClassName(): string;
  71227. /** @hidden */
  71228. _onLostFocus(): void;
  71229. /**
  71230. * Get the friendly name associated with the input class.
  71231. * @returns the input friendly name
  71232. */
  71233. getSimpleName(): string;
  71234. }
  71235. }
  71236. declare module BABYLON {
  71237. /**
  71238. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71239. * separate meshes. This can be use to improve performances.
  71240. * @see http://doc.babylonjs.com/how_to/multi_materials
  71241. */
  71242. export class MultiMaterial extends Material {
  71243. private _subMaterials;
  71244. /**
  71245. * Gets or Sets the list of Materials used within the multi material.
  71246. * They need to be ordered according to the submeshes order in the associated mesh
  71247. */
  71248. subMaterials: Nullable<Material>[];
  71249. /**
  71250. * Function used to align with Node.getChildren()
  71251. * @returns the list of Materials used within the multi material
  71252. */
  71253. getChildren(): Nullable<Material>[];
  71254. /**
  71255. * Instantiates a new Multi Material
  71256. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71257. * separate meshes. This can be use to improve performances.
  71258. * @see http://doc.babylonjs.com/how_to/multi_materials
  71259. * @param name Define the name in the scene
  71260. * @param scene Define the scene the material belongs to
  71261. */
  71262. constructor(name: string, scene: Scene);
  71263. private _hookArray;
  71264. /**
  71265. * Get one of the submaterial by its index in the submaterials array
  71266. * @param index The index to look the sub material at
  71267. * @returns The Material if the index has been defined
  71268. */
  71269. getSubMaterial(index: number): Nullable<Material>;
  71270. /**
  71271. * Get the list of active textures for the whole sub materials list.
  71272. * @returns All the textures that will be used during the rendering
  71273. */
  71274. getActiveTextures(): BaseTexture[];
  71275. /**
  71276. * Gets the current class name of the material e.g. "MultiMaterial"
  71277. * Mainly use in serialization.
  71278. * @returns the class name
  71279. */
  71280. getClassName(): string;
  71281. /**
  71282. * Checks if the material is ready to render the requested sub mesh
  71283. * @param mesh Define the mesh the submesh belongs to
  71284. * @param subMesh Define the sub mesh to look readyness for
  71285. * @param useInstances Define whether or not the material is used with instances
  71286. * @returns true if ready, otherwise false
  71287. */
  71288. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  71289. /**
  71290. * Clones the current material and its related sub materials
  71291. * @param name Define the name of the newly cloned material
  71292. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  71293. * @returns the cloned material
  71294. */
  71295. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  71296. /**
  71297. * Serializes the materials into a JSON representation.
  71298. * @returns the JSON representation
  71299. */
  71300. serialize(): any;
  71301. /**
  71302. * Dispose the material and release its associated resources
  71303. * @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)
  71304. * @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)
  71305. * @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)
  71306. */
  71307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71308. /**
  71309. * Creates a MultiMaterial from parsed MultiMaterial data.
  71310. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71311. * @param scene defines the hosting scene
  71312. * @returns a new MultiMaterial
  71313. */
  71314. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71315. }
  71316. }
  71317. declare module BABYLON {
  71318. /**
  71319. * Class used to represent data loading progression
  71320. */
  71321. export class SceneLoaderFlags {
  71322. private static _ForceFullSceneLoadingForIncremental;
  71323. private static _ShowLoadingScreen;
  71324. private static _CleanBoneMatrixWeights;
  71325. private static _loggingLevel;
  71326. /**
  71327. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71328. */
  71329. static ForceFullSceneLoadingForIncremental: boolean;
  71330. /**
  71331. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71332. */
  71333. static ShowLoadingScreen: boolean;
  71334. /**
  71335. * Defines the current logging level (while loading the scene)
  71336. * @ignorenaming
  71337. */
  71338. static loggingLevel: number;
  71339. /**
  71340. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71341. */
  71342. static CleanBoneMatrixWeights: boolean;
  71343. }
  71344. }
  71345. declare module BABYLON {
  71346. /**
  71347. * 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.
  71348. * @see https://doc.babylonjs.com/how_to/transformnode
  71349. */
  71350. export class TransformNode extends Node {
  71351. /**
  71352. * Object will not rotate to face the camera
  71353. */
  71354. static BILLBOARDMODE_NONE: number;
  71355. /**
  71356. * Object will rotate to face the camera but only on the x axis
  71357. */
  71358. static BILLBOARDMODE_X: number;
  71359. /**
  71360. * Object will rotate to face the camera but only on the y axis
  71361. */
  71362. static BILLBOARDMODE_Y: number;
  71363. /**
  71364. * Object will rotate to face the camera but only on the z axis
  71365. */
  71366. static BILLBOARDMODE_Z: number;
  71367. /**
  71368. * Object will rotate to face the camera
  71369. */
  71370. static BILLBOARDMODE_ALL: number;
  71371. private _forward;
  71372. private _forwardInverted;
  71373. private _up;
  71374. private _right;
  71375. private _rightInverted;
  71376. private _position;
  71377. private _rotation;
  71378. private _rotationQuaternion;
  71379. protected _scaling: Vector3;
  71380. protected _isDirty: boolean;
  71381. private _transformToBoneReferal;
  71382. private _billboardMode;
  71383. /**
  71384. * Gets or sets the billboard mode. Default is 0.
  71385. *
  71386. * | Value | Type | Description |
  71387. * | --- | --- | --- |
  71388. * | 0 | BILLBOARDMODE_NONE | |
  71389. * | 1 | BILLBOARDMODE_X | |
  71390. * | 2 | BILLBOARDMODE_Y | |
  71391. * | 4 | BILLBOARDMODE_Z | |
  71392. * | 7 | BILLBOARDMODE_ALL | |
  71393. *
  71394. */
  71395. billboardMode: number;
  71396. private _preserveParentRotationForBillboard;
  71397. /**
  71398. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71399. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71400. */
  71401. preserveParentRotationForBillboard: boolean;
  71402. /**
  71403. * 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
  71404. */
  71405. scalingDeterminant: number;
  71406. private _infiniteDistance;
  71407. /**
  71408. * Gets or sets the distance of the object to max, often used by skybox
  71409. */
  71410. infiniteDistance: boolean;
  71411. /**
  71412. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71413. * By default the system will update normals to compensate
  71414. */
  71415. ignoreNonUniformScaling: boolean;
  71416. /**
  71417. * 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
  71418. */
  71419. reIntegrateRotationIntoRotationQuaternion: boolean;
  71420. /** @hidden */
  71421. _poseMatrix: Nullable<Matrix>;
  71422. /** @hidden */
  71423. _localMatrix: Matrix;
  71424. private _usePivotMatrix;
  71425. private _absolutePosition;
  71426. private _pivotMatrix;
  71427. private _pivotMatrixInverse;
  71428. protected _postMultiplyPivotMatrix: boolean;
  71429. protected _isWorldMatrixFrozen: boolean;
  71430. /** @hidden */
  71431. _indexInSceneTransformNodesArray: number;
  71432. /**
  71433. * An event triggered after the world matrix is updated
  71434. */
  71435. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71436. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71437. /**
  71438. * Gets a string identifying the name of the class
  71439. * @returns "TransformNode" string
  71440. */
  71441. getClassName(): string;
  71442. /**
  71443. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71444. */
  71445. position: Vector3;
  71446. /**
  71447. * 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)).
  71448. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71449. */
  71450. rotation: Vector3;
  71451. /**
  71452. * 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)).
  71453. */
  71454. scaling: Vector3;
  71455. /**
  71456. * 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).
  71457. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71458. */
  71459. rotationQuaternion: Nullable<Quaternion>;
  71460. /**
  71461. * The forward direction of that transform in world space.
  71462. */
  71463. readonly forward: Vector3;
  71464. /**
  71465. * The up direction of that transform in world space.
  71466. */
  71467. readonly up: Vector3;
  71468. /**
  71469. * The right direction of that transform in world space.
  71470. */
  71471. readonly right: Vector3;
  71472. /**
  71473. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71474. * @param matrix the matrix to copy the pose from
  71475. * @returns this TransformNode.
  71476. */
  71477. updatePoseMatrix(matrix: Matrix): TransformNode;
  71478. /**
  71479. * Returns the mesh Pose matrix.
  71480. * @returns the pose matrix
  71481. */
  71482. getPoseMatrix(): Matrix;
  71483. /** @hidden */
  71484. _isSynchronized(): boolean;
  71485. /** @hidden */
  71486. _initCache(): void;
  71487. /**
  71488. * Flag the transform node as dirty (Forcing it to update everything)
  71489. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71490. * @returns this transform node
  71491. */
  71492. markAsDirty(property: string): TransformNode;
  71493. /**
  71494. * Returns the current mesh absolute position.
  71495. * Returns a Vector3.
  71496. */
  71497. readonly absolutePosition: Vector3;
  71498. /**
  71499. * Sets a new matrix to apply before all other transformation
  71500. * @param matrix defines the transform matrix
  71501. * @returns the current TransformNode
  71502. */
  71503. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71504. /**
  71505. * Sets a new pivot matrix to the current node
  71506. * @param matrix defines the new pivot matrix to use
  71507. * @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
  71508. * @returns the current TransformNode
  71509. */
  71510. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71511. /**
  71512. * Returns the mesh pivot matrix.
  71513. * Default : Identity.
  71514. * @returns the matrix
  71515. */
  71516. getPivotMatrix(): Matrix;
  71517. /**
  71518. * Prevents the World matrix to be computed any longer.
  71519. * @returns the TransformNode.
  71520. */
  71521. freezeWorldMatrix(): TransformNode;
  71522. /**
  71523. * Allows back the World matrix computation.
  71524. * @returns the TransformNode.
  71525. */
  71526. unfreezeWorldMatrix(): this;
  71527. /**
  71528. * True if the World matrix has been frozen.
  71529. */
  71530. readonly isWorldMatrixFrozen: boolean;
  71531. /**
  71532. * Retuns the mesh absolute position in the World.
  71533. * @returns a Vector3.
  71534. */
  71535. getAbsolutePosition(): Vector3;
  71536. /**
  71537. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71538. * @param absolutePosition the absolute position to set
  71539. * @returns the TransformNode.
  71540. */
  71541. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71542. /**
  71543. * Sets the mesh position in its local space.
  71544. * @param vector3 the position to set in localspace
  71545. * @returns the TransformNode.
  71546. */
  71547. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71548. /**
  71549. * Returns the mesh position in the local space from the current World matrix values.
  71550. * @returns a new Vector3.
  71551. */
  71552. getPositionExpressedInLocalSpace(): Vector3;
  71553. /**
  71554. * Translates the mesh along the passed Vector3 in its local space.
  71555. * @param vector3 the distance to translate in localspace
  71556. * @returns the TransformNode.
  71557. */
  71558. locallyTranslate(vector3: Vector3): TransformNode;
  71559. private static _lookAtVectorCache;
  71560. /**
  71561. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71562. * @param targetPoint the position (must be in same space as current mesh) to look at
  71563. * @param yawCor optional yaw (y-axis) correction in radians
  71564. * @param pitchCor optional pitch (x-axis) correction in radians
  71565. * @param rollCor optional roll (z-axis) correction in radians
  71566. * @param space the choosen space of the target
  71567. * @returns the TransformNode.
  71568. */
  71569. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71570. /**
  71571. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71572. * This Vector3 is expressed in the World space.
  71573. * @param localAxis axis to rotate
  71574. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71575. */
  71576. getDirection(localAxis: Vector3): Vector3;
  71577. /**
  71578. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71579. * localAxis is expressed in the mesh local space.
  71580. * result is computed in the Wordl space from the mesh World matrix.
  71581. * @param localAxis axis to rotate
  71582. * @param result the resulting transformnode
  71583. * @returns this TransformNode.
  71584. */
  71585. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71586. /**
  71587. * Sets this transform node rotation to the given local axis.
  71588. * @param localAxis the axis in local space
  71589. * @param yawCor optional yaw (y-axis) correction in radians
  71590. * @param pitchCor optional pitch (x-axis) correction in radians
  71591. * @param rollCor optional roll (z-axis) correction in radians
  71592. * @returns this TransformNode
  71593. */
  71594. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71595. /**
  71596. * Sets a new pivot point to the current node
  71597. * @param point defines the new pivot point to use
  71598. * @param space defines if the point is in world or local space (local by default)
  71599. * @returns the current TransformNode
  71600. */
  71601. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71602. /**
  71603. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71604. * @returns the pivot point
  71605. */
  71606. getPivotPoint(): Vector3;
  71607. /**
  71608. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71609. * @param result the vector3 to store the result
  71610. * @returns this TransformNode.
  71611. */
  71612. getPivotPointToRef(result: Vector3): TransformNode;
  71613. /**
  71614. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71615. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71616. */
  71617. getAbsolutePivotPoint(): Vector3;
  71618. /**
  71619. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71620. * @param result vector3 to store the result
  71621. * @returns this TransformNode.
  71622. */
  71623. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71624. /**
  71625. * Defines the passed node as the parent of the current node.
  71626. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71627. * @see https://doc.babylonjs.com/how_to/parenting
  71628. * @param node the node ot set as the parent
  71629. * @returns this TransformNode.
  71630. */
  71631. setParent(node: Nullable<Node>): TransformNode;
  71632. private _nonUniformScaling;
  71633. /**
  71634. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71635. */
  71636. readonly nonUniformScaling: boolean;
  71637. /** @hidden */
  71638. _updateNonUniformScalingState(value: boolean): boolean;
  71639. /**
  71640. * Attach the current TransformNode to another TransformNode associated with a bone
  71641. * @param bone Bone affecting the TransformNode
  71642. * @param affectedTransformNode TransformNode associated with the bone
  71643. * @returns this object
  71644. */
  71645. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71646. /**
  71647. * Detach the transform node if its associated with a bone
  71648. * @returns this object
  71649. */
  71650. detachFromBone(): TransformNode;
  71651. private static _rotationAxisCache;
  71652. /**
  71653. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71654. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71655. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71656. * The passed axis is also normalized.
  71657. * @param axis the axis to rotate around
  71658. * @param amount the amount to rotate in radians
  71659. * @param space Space to rotate in (Default: local)
  71660. * @returns the TransformNode.
  71661. */
  71662. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71663. /**
  71664. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71665. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71666. * The passed axis is also normalized. .
  71667. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71668. * @param point the point to rotate around
  71669. * @param axis the axis to rotate around
  71670. * @param amount the amount to rotate in radians
  71671. * @returns the TransformNode
  71672. */
  71673. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71674. /**
  71675. * Translates the mesh along the axis vector for the passed distance in the given space.
  71676. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71677. * @param axis the axis to translate in
  71678. * @param distance the distance to translate
  71679. * @param space Space to rotate in (Default: local)
  71680. * @returns the TransformNode.
  71681. */
  71682. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71683. /**
  71684. * Adds a rotation step to the mesh current rotation.
  71685. * x, y, z are Euler angles expressed in radians.
  71686. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71687. * This means this rotation is made in the mesh local space only.
  71688. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71689. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71690. * ```javascript
  71691. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71692. * ```
  71693. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71694. * 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.
  71695. * @param x Rotation to add
  71696. * @param y Rotation to add
  71697. * @param z Rotation to add
  71698. * @returns the TransformNode.
  71699. */
  71700. addRotation(x: number, y: number, z: number): TransformNode;
  71701. /**
  71702. * @hidden
  71703. */
  71704. protected _getEffectiveParent(): Nullable<Node>;
  71705. /**
  71706. * Computes the world matrix of the node
  71707. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71708. * @returns the world matrix
  71709. */
  71710. computeWorldMatrix(force?: boolean): Matrix;
  71711. protected _afterComputeWorldMatrix(): void;
  71712. /**
  71713. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71714. * @param func callback function to add
  71715. *
  71716. * @returns the TransformNode.
  71717. */
  71718. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71719. /**
  71720. * Removes a registered callback function.
  71721. * @param func callback function to remove
  71722. * @returns the TransformNode.
  71723. */
  71724. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71725. /**
  71726. * Gets the position of the current mesh in camera space
  71727. * @param camera defines the camera to use
  71728. * @returns a position
  71729. */
  71730. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71731. /**
  71732. * Returns the distance from the mesh to the active camera
  71733. * @param camera defines the camera to use
  71734. * @returns the distance
  71735. */
  71736. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71737. /**
  71738. * Clone the current transform node
  71739. * @param name Name of the new clone
  71740. * @param newParent New parent for the clone
  71741. * @param doNotCloneChildren Do not clone children hierarchy
  71742. * @returns the new transform node
  71743. */
  71744. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71745. /**
  71746. * Serializes the objects information.
  71747. * @param currentSerializationObject defines the object to serialize in
  71748. * @returns the serialized object
  71749. */
  71750. serialize(currentSerializationObject?: any): any;
  71751. /**
  71752. * Returns a new TransformNode object parsed from the source provided.
  71753. * @param parsedTransformNode is the source.
  71754. * @param scene the scne the object belongs to
  71755. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71756. * @returns a new TransformNode object parsed from the source provided.
  71757. */
  71758. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71759. /**
  71760. * Get all child-transformNodes of this node
  71761. * @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
  71762. * @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
  71763. * @returns an array of TransformNode
  71764. */
  71765. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71766. /**
  71767. * Releases resources associated with this transform node.
  71768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71770. */
  71771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71772. /**
  71773. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71774. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71775. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71776. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71777. * @returns the current mesh
  71778. */
  71779. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71780. }
  71781. }
  71782. declare module BABYLON {
  71783. /**
  71784. * Class used to override all child animations of a given target
  71785. */
  71786. export class AnimationPropertiesOverride {
  71787. /**
  71788. * Gets or sets a value indicating if animation blending must be used
  71789. */
  71790. enableBlending: boolean;
  71791. /**
  71792. * Gets or sets the blending speed to use when enableBlending is true
  71793. */
  71794. blendingSpeed: number;
  71795. /**
  71796. * Gets or sets the default loop mode to use
  71797. */
  71798. loopMode: number;
  71799. }
  71800. }
  71801. declare module BABYLON {
  71802. /**
  71803. * Class used to store bone information
  71804. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71805. */
  71806. export class Bone extends Node {
  71807. /**
  71808. * defines the bone name
  71809. */
  71810. name: string;
  71811. private static _tmpVecs;
  71812. private static _tmpQuat;
  71813. private static _tmpMats;
  71814. /**
  71815. * Gets the list of child bones
  71816. */
  71817. children: Bone[];
  71818. /** Gets the animations associated with this bone */
  71819. animations: Animation[];
  71820. /**
  71821. * Gets or sets bone length
  71822. */
  71823. length: number;
  71824. /**
  71825. * @hidden Internal only
  71826. * Set this value to map this bone to a different index in the transform matrices
  71827. * Set this value to -1 to exclude the bone from the transform matrices
  71828. */
  71829. _index: Nullable<number>;
  71830. private _skeleton;
  71831. private _localMatrix;
  71832. private _restPose;
  71833. private _baseMatrix;
  71834. private _absoluteTransform;
  71835. private _invertedAbsoluteTransform;
  71836. private _parent;
  71837. private _scalingDeterminant;
  71838. private _worldTransform;
  71839. private _localScaling;
  71840. private _localRotation;
  71841. private _localPosition;
  71842. private _needToDecompose;
  71843. private _needToCompose;
  71844. /** @hidden */
  71845. _linkedTransformNode: Nullable<TransformNode>;
  71846. /** @hidden */
  71847. _waitingTransformNodeId: Nullable<string>;
  71848. /** @hidden */
  71849. /** @hidden */
  71850. _matrix: Matrix;
  71851. /**
  71852. * Create a new bone
  71853. * @param name defines the bone name
  71854. * @param skeleton defines the parent skeleton
  71855. * @param parentBone defines the parent (can be null if the bone is the root)
  71856. * @param localMatrix defines the local matrix
  71857. * @param restPose defines the rest pose matrix
  71858. * @param baseMatrix defines the base matrix
  71859. * @param index defines index of the bone in the hiearchy
  71860. */
  71861. constructor(
  71862. /**
  71863. * defines the bone name
  71864. */
  71865. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71866. /**
  71867. * Gets the current object class name.
  71868. * @return the class name
  71869. */
  71870. getClassName(): string;
  71871. /**
  71872. * Gets the parent skeleton
  71873. * @returns a skeleton
  71874. */
  71875. getSkeleton(): Skeleton;
  71876. /**
  71877. * Gets parent bone
  71878. * @returns a bone or null if the bone is the root of the bone hierarchy
  71879. */
  71880. getParent(): Nullable<Bone>;
  71881. /**
  71882. * Returns an array containing the root bones
  71883. * @returns an array containing the root bones
  71884. */
  71885. getChildren(): Array<Bone>;
  71886. /**
  71887. * Sets the parent bone
  71888. * @param parent defines the parent (can be null if the bone is the root)
  71889. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71890. */
  71891. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71892. /**
  71893. * Gets the local matrix
  71894. * @returns a matrix
  71895. */
  71896. getLocalMatrix(): Matrix;
  71897. /**
  71898. * Gets the base matrix (initial matrix which remains unchanged)
  71899. * @returns a matrix
  71900. */
  71901. getBaseMatrix(): Matrix;
  71902. /**
  71903. * Gets the rest pose matrix
  71904. * @returns a matrix
  71905. */
  71906. getRestPose(): Matrix;
  71907. /**
  71908. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71909. */
  71910. getWorldMatrix(): Matrix;
  71911. /**
  71912. * Sets the local matrix to rest pose matrix
  71913. */
  71914. returnToRest(): void;
  71915. /**
  71916. * Gets the inverse of the absolute transform matrix.
  71917. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71918. * @returns a matrix
  71919. */
  71920. getInvertedAbsoluteTransform(): Matrix;
  71921. /**
  71922. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71923. * @returns a matrix
  71924. */
  71925. getAbsoluteTransform(): Matrix;
  71926. /**
  71927. * Links with the given transform node.
  71928. * The local matrix of this bone is copied from the transform node every frame.
  71929. * @param transformNode defines the transform node to link to
  71930. */
  71931. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71932. /** Gets or sets current position (in local space) */
  71933. position: Vector3;
  71934. /** Gets or sets current rotation (in local space) */
  71935. rotation: Vector3;
  71936. /** Gets or sets current rotation quaternion (in local space) */
  71937. rotationQuaternion: Quaternion;
  71938. /** Gets or sets current scaling (in local space) */
  71939. scaling: Vector3;
  71940. /**
  71941. * Gets the animation properties override
  71942. */
  71943. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71944. private _decompose;
  71945. private _compose;
  71946. /**
  71947. * Update the base and local matrices
  71948. * @param matrix defines the new base or local matrix
  71949. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71950. * @param updateLocalMatrix defines if the local matrix should be updated
  71951. */
  71952. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71953. /** @hidden */
  71954. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71955. /**
  71956. * Flag the bone as dirty (Forcing it to update everything)
  71957. */
  71958. markAsDirty(): void;
  71959. /** @hidden */
  71960. _markAsDirtyAndCompose(): void;
  71961. private _markAsDirtyAndDecompose;
  71962. /**
  71963. * Translate the bone in local or world space
  71964. * @param vec The amount to translate the bone
  71965. * @param space The space that the translation is in
  71966. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71967. */
  71968. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71969. /**
  71970. * Set the postion of the bone in local or world space
  71971. * @param position The position to set the bone
  71972. * @param space The space that the position is in
  71973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71974. */
  71975. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71976. /**
  71977. * Set the absolute position of the bone (world space)
  71978. * @param position The position to set the bone
  71979. * @param mesh The mesh that this bone is attached to
  71980. */
  71981. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71982. /**
  71983. * Scale the bone on the x, y and z axes (in local space)
  71984. * @param x The amount to scale the bone on the x axis
  71985. * @param y The amount to scale the bone on the y axis
  71986. * @param z The amount to scale the bone on the z axis
  71987. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71988. */
  71989. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71990. /**
  71991. * Set the bone scaling in local space
  71992. * @param scale defines the scaling vector
  71993. */
  71994. setScale(scale: Vector3): void;
  71995. /**
  71996. * Gets the current scaling in local space
  71997. * @returns the current scaling vector
  71998. */
  71999. getScale(): Vector3;
  72000. /**
  72001. * Gets the current scaling in local space and stores it in a target vector
  72002. * @param result defines the target vector
  72003. */
  72004. getScaleToRef(result: Vector3): void;
  72005. /**
  72006. * Set the yaw, pitch, and roll of the bone in local or world space
  72007. * @param yaw The rotation of the bone on the y axis
  72008. * @param pitch The rotation of the bone on the x axis
  72009. * @param roll The rotation of the bone on the z axis
  72010. * @param space The space that the axes of rotation are in
  72011. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72012. */
  72013. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  72014. /**
  72015. * Add a rotation to the bone on an axis in local or world space
  72016. * @param axis The axis to rotate the bone on
  72017. * @param amount The amount to rotate the bone
  72018. * @param space The space that the axis is in
  72019. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72020. */
  72021. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  72022. /**
  72023. * Set the rotation of the bone to a particular axis angle in local or world space
  72024. * @param axis The axis to rotate the bone on
  72025. * @param angle The angle that the bone should be rotated to
  72026. * @param space The space that the axis is in
  72027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72028. */
  72029. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  72030. /**
  72031. * Set the euler rotation of the bone in local of world space
  72032. * @param rotation The euler rotation that the bone should be set to
  72033. * @param space The space that the rotation is in
  72034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72035. */
  72036. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  72037. /**
  72038. * Set the quaternion rotation of the bone in local of world space
  72039. * @param quat The quaternion rotation that the bone should be set to
  72040. * @param space The space that the rotation is in
  72041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72042. */
  72043. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  72044. /**
  72045. * Set the rotation matrix of the bone in local of world space
  72046. * @param rotMat The rotation matrix that the bone should be set to
  72047. * @param space The space that the rotation is in
  72048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72049. */
  72050. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  72051. private _rotateWithMatrix;
  72052. private _getNegativeRotationToRef;
  72053. /**
  72054. * Get the position of the bone in local or world space
  72055. * @param space The space that the returned position is in
  72056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72057. * @returns The position of the bone
  72058. */
  72059. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72060. /**
  72061. * Copy the position of the bone to a vector3 in local or world space
  72062. * @param space The space that the returned position is in
  72063. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72064. * @param result The vector3 to copy the position to
  72065. */
  72066. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  72067. /**
  72068. * Get the absolute position of the bone (world space)
  72069. * @param mesh The mesh that this bone is attached to
  72070. * @returns The absolute position of the bone
  72071. */
  72072. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  72073. /**
  72074. * Copy the absolute position of the bone (world space) to the result param
  72075. * @param mesh The mesh that this bone is attached to
  72076. * @param result The vector3 to copy the absolute position to
  72077. */
  72078. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  72079. /**
  72080. * Compute the absolute transforms of this bone and its children
  72081. */
  72082. computeAbsoluteTransforms(): void;
  72083. /**
  72084. * Get the world direction from an axis that is in the local space of the bone
  72085. * @param localAxis The local direction that is used to compute the world direction
  72086. * @param mesh The mesh that this bone is attached to
  72087. * @returns The world direction
  72088. */
  72089. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72090. /**
  72091. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  72092. * @param localAxis The local direction that is used to compute the world direction
  72093. * @param mesh The mesh that this bone is attached to
  72094. * @param result The vector3 that the world direction will be copied to
  72095. */
  72096. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72097. /**
  72098. * Get the euler rotation of the bone in local or world space
  72099. * @param space The space that the rotation should be in
  72100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72101. * @returns The euler rotation
  72102. */
  72103. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72104. /**
  72105. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  72106. * @param space The space that the rotation should be in
  72107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72108. * @param result The vector3 that the rotation should be copied to
  72109. */
  72110. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72111. /**
  72112. * Get the quaternion rotation of the bone in either local or world space
  72113. * @param space The space that the rotation should be in
  72114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72115. * @returns The quaternion rotation
  72116. */
  72117. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  72118. /**
  72119. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  72120. * @param space The space that the rotation should be in
  72121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72122. * @param result The quaternion that the rotation should be copied to
  72123. */
  72124. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  72125. /**
  72126. * Get the rotation matrix of the bone in local or world space
  72127. * @param space The space that the rotation should be in
  72128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72129. * @returns The rotation matrix
  72130. */
  72131. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  72132. /**
  72133. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  72134. * @param space The space that the rotation should be in
  72135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72136. * @param result The quaternion that the rotation should be copied to
  72137. */
  72138. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  72139. /**
  72140. * Get the world position of a point that is in the local space of the bone
  72141. * @param position The local position
  72142. * @param mesh The mesh that this bone is attached to
  72143. * @returns The world position
  72144. */
  72145. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72146. /**
  72147. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  72148. * @param position The local position
  72149. * @param mesh The mesh that this bone is attached to
  72150. * @param result The vector3 that the world position should be copied to
  72151. */
  72152. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72153. /**
  72154. * Get the local position of a point that is in world space
  72155. * @param position The world position
  72156. * @param mesh The mesh that this bone is attached to
  72157. * @returns The local position
  72158. */
  72159. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72160. /**
  72161. * Get the local position of a point that is in world space and copy it to the result param
  72162. * @param position The world position
  72163. * @param mesh The mesh that this bone is attached to
  72164. * @param result The vector3 that the local position should be copied to
  72165. */
  72166. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72167. }
  72168. }
  72169. declare module BABYLON {
  72170. interface Engine {
  72171. /**
  72172. * Creates a raw texture
  72173. * @param data defines the data to store in the texture
  72174. * @param width defines the width of the texture
  72175. * @param height defines the height of the texture
  72176. * @param format defines the format of the data
  72177. * @param generateMipMaps defines if the engine should generate the mip levels
  72178. * @param invertY defines if data must be stored with Y axis inverted
  72179. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  72180. * @param compression defines the compression used (null by default)
  72181. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72182. * @returns the raw texture inside an InternalTexture
  72183. */
  72184. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  72185. /**
  72186. * Update a raw texture
  72187. * @param texture defines the texture to update
  72188. * @param data defines the data to store in the texture
  72189. * @param format defines the format of the data
  72190. * @param invertY defines if data must be stored with Y axis inverted
  72191. */
  72192. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72193. /**
  72194. * Update a raw texture
  72195. * @param texture defines the texture to update
  72196. * @param data defines the data to store in the texture
  72197. * @param format defines the format of the data
  72198. * @param invertY defines if data must be stored with Y axis inverted
  72199. * @param compression defines the compression used (null by default)
  72200. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72201. */
  72202. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  72203. /**
  72204. * Creates a new raw cube texture
  72205. * @param data defines the array of data to use to create each face
  72206. * @param size defines the size of the textures
  72207. * @param format defines the format of the data
  72208. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72209. * @param generateMipMaps defines if the engine should generate the mip levels
  72210. * @param invertY defines if data must be stored with Y axis inverted
  72211. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72212. * @param compression defines the compression used (null by default)
  72213. * @returns the cube texture as an InternalTexture
  72214. */
  72215. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  72216. /**
  72217. * Update a raw cube texture
  72218. * @param texture defines the texture to udpdate
  72219. * @param data defines the data to store
  72220. * @param format defines the data format
  72221. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72222. * @param invertY defines if data must be stored with Y axis inverted
  72223. */
  72224. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  72225. /**
  72226. * Update a raw cube texture
  72227. * @param texture defines the texture to udpdate
  72228. * @param data defines the data to store
  72229. * @param format defines the data format
  72230. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72231. * @param invertY defines if data must be stored with Y axis inverted
  72232. * @param compression defines the compression used (null by default)
  72233. */
  72234. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  72235. /**
  72236. * Update a raw cube texture
  72237. * @param texture defines the texture to udpdate
  72238. * @param data defines the data to store
  72239. * @param format defines the data format
  72240. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72241. * @param invertY defines if data must be stored with Y axis inverted
  72242. * @param compression defines the compression used (null by default)
  72243. * @param level defines which level of the texture to update
  72244. */
  72245. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  72246. /**
  72247. * Creates a new raw cube texture from a specified url
  72248. * @param url defines the url where the data is located
  72249. * @param scene defines the current scene
  72250. * @param size defines the size of the textures
  72251. * @param format defines the format of the data
  72252. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72253. * @param noMipmap defines if the engine should avoid generating the mip levels
  72254. * @param callback defines a callback used to extract texture data from loaded data
  72255. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72256. * @param onLoad defines a callback called when texture is loaded
  72257. * @param onError defines a callback called if there is an error
  72258. * @returns the cube texture as an InternalTexture
  72259. */
  72260. 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;
  72261. /**
  72262. * Creates a new raw cube texture from a specified url
  72263. * @param url defines the url where the data is located
  72264. * @param scene defines the current scene
  72265. * @param size defines the size of the textures
  72266. * @param format defines the format of the data
  72267. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72268. * @param noMipmap defines if the engine should avoid generating the mip levels
  72269. * @param callback defines a callback used to extract texture data from loaded data
  72270. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72271. * @param onLoad defines a callback called when texture is loaded
  72272. * @param onError defines a callback called if there is an error
  72273. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72274. * @param invertY defines if data must be stored with Y axis inverted
  72275. * @returns the cube texture as an InternalTexture
  72276. */
  72277. 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;
  72278. /**
  72279. * Creates a new raw 3D texture
  72280. * @param data defines the data used to create the texture
  72281. * @param width defines the width of the texture
  72282. * @param height defines the height of the texture
  72283. * @param depth defines the depth of the texture
  72284. * @param format defines the format of the texture
  72285. * @param generateMipMaps defines if the engine must generate mip levels
  72286. * @param invertY defines if data must be stored with Y axis inverted
  72287. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72288. * @param compression defines the compressed used (can be null)
  72289. * @param textureType defines the compressed used (can be null)
  72290. * @returns a new raw 3D texture (stored in an InternalTexture)
  72291. */
  72292. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  72293. /**
  72294. * Update a raw 3D texture
  72295. * @param texture defines the texture to update
  72296. * @param data defines the data to store
  72297. * @param format defines the data format
  72298. * @param invertY defines if data must be stored with Y axis inverted
  72299. */
  72300. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72301. /**
  72302. * Update a raw 3D texture
  72303. * @param texture defines the texture to update
  72304. * @param data defines the data to store
  72305. * @param format defines the data format
  72306. * @param invertY defines if data must be stored with Y axis inverted
  72307. * @param compression defines the used compression (can be null)
  72308. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72309. */
  72310. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72311. }
  72312. }
  72313. declare module BABYLON {
  72314. /**
  72315. * Raw texture can help creating a texture directly from an array of data.
  72316. * This can be super useful if you either get the data from an uncompressed source or
  72317. * if you wish to create your texture pixel by pixel.
  72318. */
  72319. export class RawTexture extends Texture {
  72320. /**
  72321. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72322. */
  72323. format: number;
  72324. private _engine;
  72325. /**
  72326. * Instantiates a new RawTexture.
  72327. * Raw texture can help creating a texture directly from an array of data.
  72328. * This can be super useful if you either get the data from an uncompressed source or
  72329. * if you wish to create your texture pixel by pixel.
  72330. * @param data define the array of data to use to create the texture
  72331. * @param width define the width of the texture
  72332. * @param height define the height of the texture
  72333. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72334. * @param scene define the scene the texture belongs to
  72335. * @param generateMipMaps define whether mip maps should be generated or not
  72336. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72337. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72338. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72339. */
  72340. constructor(data: ArrayBufferView, width: number, height: number,
  72341. /**
  72342. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72343. */
  72344. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72345. /**
  72346. * Updates the texture underlying data.
  72347. * @param data Define the new data of the texture
  72348. */
  72349. update(data: ArrayBufferView): void;
  72350. /**
  72351. * Creates a luminance texture from some data.
  72352. * @param data Define the texture data
  72353. * @param width Define the width of the texture
  72354. * @param height Define the height of the texture
  72355. * @param scene Define the scene the texture belongs to
  72356. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72357. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72358. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72359. * @returns the luminance texture
  72360. */
  72361. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72362. /**
  72363. * Creates a luminance alpha texture from some data.
  72364. * @param data Define the texture data
  72365. * @param width Define the width of the texture
  72366. * @param height Define the height of the texture
  72367. * @param scene Define the scene the texture belongs to
  72368. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72369. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72370. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72371. * @returns the luminance alpha texture
  72372. */
  72373. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72374. /**
  72375. * Creates an alpha texture from some data.
  72376. * @param data Define the texture data
  72377. * @param width Define the width of the texture
  72378. * @param height Define the height of the texture
  72379. * @param scene Define the scene the texture belongs to
  72380. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72381. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72382. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72383. * @returns the alpha texture
  72384. */
  72385. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72386. /**
  72387. * Creates a RGB texture from some data.
  72388. * @param data Define the texture data
  72389. * @param width Define the width of the texture
  72390. * @param height Define the height of the texture
  72391. * @param scene Define the scene the texture belongs to
  72392. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72395. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72396. * @returns the RGB alpha texture
  72397. */
  72398. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72399. /**
  72400. * Creates a RGBA texture from some data.
  72401. * @param data Define the texture data
  72402. * @param width Define the width of the texture
  72403. * @param height Define the height of the texture
  72404. * @param scene Define the scene the texture belongs to
  72405. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72406. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72407. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72408. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72409. * @returns the RGBA texture
  72410. */
  72411. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72412. /**
  72413. * Creates a R texture from some data.
  72414. * @param data Define the texture data
  72415. * @param width Define the width of the texture
  72416. * @param height Define the height of the texture
  72417. * @param scene Define the scene the texture belongs to
  72418. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72419. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72420. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72421. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72422. * @returns the R texture
  72423. */
  72424. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72425. }
  72426. }
  72427. declare module BABYLON {
  72428. /**
  72429. * Defines a runtime animation
  72430. */
  72431. export class RuntimeAnimation {
  72432. private _events;
  72433. /**
  72434. * The current frame of the runtime animation
  72435. */
  72436. private _currentFrame;
  72437. /**
  72438. * The animation used by the runtime animation
  72439. */
  72440. private _animation;
  72441. /**
  72442. * The target of the runtime animation
  72443. */
  72444. private _target;
  72445. /**
  72446. * The initiating animatable
  72447. */
  72448. private _host;
  72449. /**
  72450. * The original value of the runtime animation
  72451. */
  72452. private _originalValue;
  72453. /**
  72454. * The original blend value of the runtime animation
  72455. */
  72456. private _originalBlendValue;
  72457. /**
  72458. * The offsets cache of the runtime animation
  72459. */
  72460. private _offsetsCache;
  72461. /**
  72462. * The high limits cache of the runtime animation
  72463. */
  72464. private _highLimitsCache;
  72465. /**
  72466. * Specifies if the runtime animation has been stopped
  72467. */
  72468. private _stopped;
  72469. /**
  72470. * The blending factor of the runtime animation
  72471. */
  72472. private _blendingFactor;
  72473. /**
  72474. * The BabylonJS scene
  72475. */
  72476. private _scene;
  72477. /**
  72478. * The current value of the runtime animation
  72479. */
  72480. private _currentValue;
  72481. /** @hidden */
  72482. _animationState: _IAnimationState;
  72483. /**
  72484. * The active target of the runtime animation
  72485. */
  72486. private _activeTargets;
  72487. private _currentActiveTarget;
  72488. private _directTarget;
  72489. /**
  72490. * The target path of the runtime animation
  72491. */
  72492. private _targetPath;
  72493. /**
  72494. * The weight of the runtime animation
  72495. */
  72496. private _weight;
  72497. /**
  72498. * The ratio offset of the runtime animation
  72499. */
  72500. private _ratioOffset;
  72501. /**
  72502. * The previous delay of the runtime animation
  72503. */
  72504. private _previousDelay;
  72505. /**
  72506. * The previous ratio of the runtime animation
  72507. */
  72508. private _previousRatio;
  72509. private _enableBlending;
  72510. private _keys;
  72511. private _minFrame;
  72512. private _maxFrame;
  72513. private _minValue;
  72514. private _maxValue;
  72515. private _targetIsArray;
  72516. /**
  72517. * Gets the current frame of the runtime animation
  72518. */
  72519. readonly currentFrame: number;
  72520. /**
  72521. * Gets the weight of the runtime animation
  72522. */
  72523. readonly weight: number;
  72524. /**
  72525. * Gets the current value of the runtime animation
  72526. */
  72527. readonly currentValue: any;
  72528. /**
  72529. * Gets the target path of the runtime animation
  72530. */
  72531. readonly targetPath: string;
  72532. /**
  72533. * Gets the actual target of the runtime animation
  72534. */
  72535. readonly target: any;
  72536. /** @hidden */
  72537. _onLoop: () => void;
  72538. /**
  72539. * Create a new RuntimeAnimation object
  72540. * @param target defines the target of the animation
  72541. * @param animation defines the source animation object
  72542. * @param scene defines the hosting scene
  72543. * @param host defines the initiating Animatable
  72544. */
  72545. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72546. private _preparePath;
  72547. /**
  72548. * Gets the animation from the runtime animation
  72549. */
  72550. readonly animation: Animation;
  72551. /**
  72552. * Resets the runtime animation to the beginning
  72553. * @param restoreOriginal defines whether to restore the target property to the original value
  72554. */
  72555. reset(restoreOriginal?: boolean): void;
  72556. /**
  72557. * Specifies if the runtime animation is stopped
  72558. * @returns Boolean specifying if the runtime animation is stopped
  72559. */
  72560. isStopped(): boolean;
  72561. /**
  72562. * Disposes of the runtime animation
  72563. */
  72564. dispose(): void;
  72565. /**
  72566. * Apply the interpolated value to the target
  72567. * @param currentValue defines the value computed by the animation
  72568. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72569. */
  72570. setValue(currentValue: any, weight: number): void;
  72571. private _getOriginalValues;
  72572. private _setValue;
  72573. /**
  72574. * Gets the loop pmode of the runtime animation
  72575. * @returns Loop Mode
  72576. */
  72577. private _getCorrectLoopMode;
  72578. /**
  72579. * Move the current animation to a given frame
  72580. * @param frame defines the frame to move to
  72581. */
  72582. goToFrame(frame: number): void;
  72583. /**
  72584. * @hidden Internal use only
  72585. */
  72586. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72587. /**
  72588. * Execute the current animation
  72589. * @param delay defines the delay to add to the current frame
  72590. * @param from defines the lower bound of the animation range
  72591. * @param to defines the upper bound of the animation range
  72592. * @param loop defines if the current animation must loop
  72593. * @param speedRatio defines the current speed ratio
  72594. * @param weight defines the weight of the animation (default is -1 so no weight)
  72595. * @param onLoop optional callback called when animation loops
  72596. * @returns a boolean indicating if the animation is running
  72597. */
  72598. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72599. }
  72600. }
  72601. declare module BABYLON {
  72602. /**
  72603. * Class used to store an actual running animation
  72604. */
  72605. export class Animatable {
  72606. /** defines the target object */
  72607. target: any;
  72608. /** defines the starting frame number (default is 0) */
  72609. fromFrame: number;
  72610. /** defines the ending frame number (default is 100) */
  72611. toFrame: number;
  72612. /** defines if the animation must loop (default is false) */
  72613. loopAnimation: boolean;
  72614. /** defines a callback to call when animation ends if it is not looping */
  72615. onAnimationEnd?: (() => void) | null | undefined;
  72616. /** defines a callback to call when animation loops */
  72617. onAnimationLoop?: (() => void) | null | undefined;
  72618. private _localDelayOffset;
  72619. private _pausedDelay;
  72620. private _runtimeAnimations;
  72621. private _paused;
  72622. private _scene;
  72623. private _speedRatio;
  72624. private _weight;
  72625. private _syncRoot;
  72626. /**
  72627. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72628. * This will only apply for non looping animation (default is true)
  72629. */
  72630. disposeOnEnd: boolean;
  72631. /**
  72632. * Gets a boolean indicating if the animation has started
  72633. */
  72634. animationStarted: boolean;
  72635. /**
  72636. * Observer raised when the animation ends
  72637. */
  72638. onAnimationEndObservable: Observable<Animatable>;
  72639. /**
  72640. * Observer raised when the animation loops
  72641. */
  72642. onAnimationLoopObservable: Observable<Animatable>;
  72643. /**
  72644. * Gets the root Animatable used to synchronize and normalize animations
  72645. */
  72646. readonly syncRoot: Nullable<Animatable>;
  72647. /**
  72648. * Gets the current frame of the first RuntimeAnimation
  72649. * Used to synchronize Animatables
  72650. */
  72651. readonly masterFrame: number;
  72652. /**
  72653. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72654. */
  72655. weight: number;
  72656. /**
  72657. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72658. */
  72659. speedRatio: number;
  72660. /**
  72661. * Creates a new Animatable
  72662. * @param scene defines the hosting scene
  72663. * @param target defines the target object
  72664. * @param fromFrame defines the starting frame number (default is 0)
  72665. * @param toFrame defines the ending frame number (default is 100)
  72666. * @param loopAnimation defines if the animation must loop (default is false)
  72667. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72668. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72669. * @param animations defines a group of animation to add to the new Animatable
  72670. * @param onAnimationLoop defines a callback to call when animation loops
  72671. */
  72672. constructor(scene: Scene,
  72673. /** defines the target object */
  72674. target: any,
  72675. /** defines the starting frame number (default is 0) */
  72676. fromFrame?: number,
  72677. /** defines the ending frame number (default is 100) */
  72678. toFrame?: number,
  72679. /** defines if the animation must loop (default is false) */
  72680. loopAnimation?: boolean, speedRatio?: number,
  72681. /** defines a callback to call when animation ends if it is not looping */
  72682. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72683. /** defines a callback to call when animation loops */
  72684. onAnimationLoop?: (() => void) | null | undefined);
  72685. /**
  72686. * Synchronize and normalize current Animatable with a source Animatable
  72687. * This is useful when using animation weights and when animations are not of the same length
  72688. * @param root defines the root Animatable to synchronize with
  72689. * @returns the current Animatable
  72690. */
  72691. syncWith(root: Animatable): Animatable;
  72692. /**
  72693. * Gets the list of runtime animations
  72694. * @returns an array of RuntimeAnimation
  72695. */
  72696. getAnimations(): RuntimeAnimation[];
  72697. /**
  72698. * Adds more animations to the current animatable
  72699. * @param target defines the target of the animations
  72700. * @param animations defines the new animations to add
  72701. */
  72702. appendAnimations(target: any, animations: Animation[]): void;
  72703. /**
  72704. * Gets the source animation for a specific property
  72705. * @param property defines the propertyu to look for
  72706. * @returns null or the source animation for the given property
  72707. */
  72708. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72709. /**
  72710. * Gets the runtime animation for a specific property
  72711. * @param property defines the propertyu to look for
  72712. * @returns null or the runtime animation for the given property
  72713. */
  72714. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72715. /**
  72716. * Resets the animatable to its original state
  72717. */
  72718. reset(): void;
  72719. /**
  72720. * Allows the animatable to blend with current running animations
  72721. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72722. * @param blendingSpeed defines the blending speed to use
  72723. */
  72724. enableBlending(blendingSpeed: number): void;
  72725. /**
  72726. * Disable animation blending
  72727. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72728. */
  72729. disableBlending(): void;
  72730. /**
  72731. * Jump directly to a given frame
  72732. * @param frame defines the frame to jump to
  72733. */
  72734. goToFrame(frame: number): void;
  72735. /**
  72736. * Pause the animation
  72737. */
  72738. pause(): void;
  72739. /**
  72740. * Restart the animation
  72741. */
  72742. restart(): void;
  72743. private _raiseOnAnimationEnd;
  72744. /**
  72745. * Stop and delete the current animation
  72746. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72747. * @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)
  72748. */
  72749. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72750. /**
  72751. * Wait asynchronously for the animation to end
  72752. * @returns a promise which will be fullfilled when the animation ends
  72753. */
  72754. waitAsync(): Promise<Animatable>;
  72755. /** @hidden */
  72756. _animate(delay: number): boolean;
  72757. }
  72758. interface Scene {
  72759. /** @hidden */
  72760. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72761. /** @hidden */
  72762. _processLateAnimationBindingsForMatrices(holder: {
  72763. totalWeight: number;
  72764. animations: RuntimeAnimation[];
  72765. originalValue: Matrix;
  72766. }): any;
  72767. /** @hidden */
  72768. _processLateAnimationBindingsForQuaternions(holder: {
  72769. totalWeight: number;
  72770. animations: RuntimeAnimation[];
  72771. originalValue: Quaternion;
  72772. }, refQuaternion: Quaternion): Quaternion;
  72773. /** @hidden */
  72774. _processLateAnimationBindings(): void;
  72775. /**
  72776. * Will start the animation sequence of a given target
  72777. * @param target defines the target
  72778. * @param from defines from which frame should animation start
  72779. * @param to defines until which frame should animation run.
  72780. * @param weight defines the weight to apply to the animation (1.0 by default)
  72781. * @param loop defines if the animation loops
  72782. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72783. * @param onAnimationEnd defines the function to be executed when the animation ends
  72784. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72785. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72786. * @param onAnimationLoop defines the callback to call when an animation loops
  72787. * @returns the animatable object created for this animation
  72788. */
  72789. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72790. /**
  72791. * Will start the animation sequence of a given target
  72792. * @param target defines the target
  72793. * @param from defines from which frame should animation start
  72794. * @param to defines until which frame should animation run.
  72795. * @param loop defines if the animation loops
  72796. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72797. * @param onAnimationEnd defines the function to be executed when the animation ends
  72798. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72799. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72800. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72801. * @param onAnimationLoop defines the callback to call when an animation loops
  72802. * @returns the animatable object created for this animation
  72803. */
  72804. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72805. /**
  72806. * Will start the animation sequence of a given target and its hierarchy
  72807. * @param target defines the target
  72808. * @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.
  72809. * @param from defines from which frame should animation start
  72810. * @param to defines until which frame should animation run.
  72811. * @param loop defines if the animation loops
  72812. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72813. * @param onAnimationEnd defines the function to be executed when the animation ends
  72814. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72815. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72816. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72817. * @param onAnimationLoop defines the callback to call when an animation loops
  72818. * @returns the list of created animatables
  72819. */
  72820. 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[];
  72821. /**
  72822. * Begin a new animation on a given node
  72823. * @param target defines the target where the animation will take place
  72824. * @param animations defines the list of animations to start
  72825. * @param from defines the initial value
  72826. * @param to defines the final value
  72827. * @param loop defines if you want animation to loop (off by default)
  72828. * @param speedRatio defines the speed ratio to apply to all animations
  72829. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72830. * @param onAnimationLoop defines the callback to call when an animation loops
  72831. * @returns the list of created animatables
  72832. */
  72833. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72834. /**
  72835. * Begin a new animation on a given node and its hierarchy
  72836. * @param target defines the root node where the animation will take place
  72837. * @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.
  72838. * @param animations defines the list of animations to start
  72839. * @param from defines the initial value
  72840. * @param to defines the final value
  72841. * @param loop defines if you want animation to loop (off by default)
  72842. * @param speedRatio defines the speed ratio to apply to all animations
  72843. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72844. * @param onAnimationLoop defines the callback to call when an animation loops
  72845. * @returns the list of animatables created for all nodes
  72846. */
  72847. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72848. /**
  72849. * Gets the animatable associated with a specific target
  72850. * @param target defines the target of the animatable
  72851. * @returns the required animatable if found
  72852. */
  72853. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72854. /**
  72855. * Gets all animatables associated with a given target
  72856. * @param target defines the target to look animatables for
  72857. * @returns an array of Animatables
  72858. */
  72859. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72860. /**
  72861. * Stops and removes all animations that have been applied to the scene
  72862. */
  72863. stopAllAnimations(): void;
  72864. }
  72865. interface Bone {
  72866. /**
  72867. * Copy an animation range from another bone
  72868. * @param source defines the source bone
  72869. * @param rangeName defines the range name to copy
  72870. * @param frameOffset defines the frame offset
  72871. * @param rescaleAsRequired defines if rescaling must be applied if required
  72872. * @param skelDimensionsRatio defines the scaling ratio
  72873. * @returns true if operation was successful
  72874. */
  72875. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72876. }
  72877. }
  72878. declare module BABYLON {
  72879. /**
  72880. * Class used to handle skinning animations
  72881. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72882. */
  72883. export class Skeleton implements IAnimatable {
  72884. /** defines the skeleton name */
  72885. name: string;
  72886. /** defines the skeleton Id */
  72887. id: string;
  72888. /**
  72889. * Defines the list of child bones
  72890. */
  72891. bones: Bone[];
  72892. /**
  72893. * Defines an estimate of the dimension of the skeleton at rest
  72894. */
  72895. dimensionsAtRest: Vector3;
  72896. /**
  72897. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72898. */
  72899. needInitialSkinMatrix: boolean;
  72900. /**
  72901. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72902. */
  72903. overrideMesh: Nullable<AbstractMesh>;
  72904. /**
  72905. * Gets the list of animations attached to this skeleton
  72906. */
  72907. animations: Array<Animation>;
  72908. private _scene;
  72909. private _isDirty;
  72910. private _transformMatrices;
  72911. private _transformMatrixTexture;
  72912. private _meshesWithPoseMatrix;
  72913. private _animatables;
  72914. private _identity;
  72915. private _synchronizedWithMesh;
  72916. private _ranges;
  72917. private _lastAbsoluteTransformsUpdateId;
  72918. private _canUseTextureForBones;
  72919. private _uniqueId;
  72920. /** @hidden */
  72921. _numBonesWithLinkedTransformNode: number;
  72922. /** @hidden */
  72923. _hasWaitingData: Nullable<boolean>;
  72924. /**
  72925. * Specifies if the skeleton should be serialized
  72926. */
  72927. doNotSerialize: boolean;
  72928. private _useTextureToStoreBoneMatrices;
  72929. /**
  72930. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72931. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  72932. */
  72933. useTextureToStoreBoneMatrices: boolean;
  72934. private _animationPropertiesOverride;
  72935. /**
  72936. * Gets or sets the animation properties override
  72937. */
  72938. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72939. /**
  72940. * List of inspectable custom properties (used by the Inspector)
  72941. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72942. */
  72943. inspectableCustomProperties: IInspectable[];
  72944. /**
  72945. * An observable triggered before computing the skeleton's matrices
  72946. */
  72947. onBeforeComputeObservable: Observable<Skeleton>;
  72948. /**
  72949. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72950. */
  72951. readonly isUsingTextureForMatrices: boolean;
  72952. /**
  72953. * Gets the unique ID of this skeleton
  72954. */
  72955. readonly uniqueId: number;
  72956. /**
  72957. * Creates a new skeleton
  72958. * @param name defines the skeleton name
  72959. * @param id defines the skeleton Id
  72960. * @param scene defines the hosting scene
  72961. */
  72962. constructor(
  72963. /** defines the skeleton name */
  72964. name: string,
  72965. /** defines the skeleton Id */
  72966. id: string, scene: Scene);
  72967. /**
  72968. * Gets the current object class name.
  72969. * @return the class name
  72970. */
  72971. getClassName(): string;
  72972. /**
  72973. * Returns an array containing the root bones
  72974. * @returns an array containing the root bones
  72975. */
  72976. getChildren(): Array<Bone>;
  72977. /**
  72978. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72979. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72980. * @returns a Float32Array containing matrices data
  72981. */
  72982. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72983. /**
  72984. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72985. * @returns a raw texture containing the data
  72986. */
  72987. getTransformMatrixTexture(): Nullable<RawTexture>;
  72988. /**
  72989. * Gets the current hosting scene
  72990. * @returns a scene object
  72991. */
  72992. getScene(): Scene;
  72993. /**
  72994. * Gets a string representing the current skeleton data
  72995. * @param fullDetails defines a boolean indicating if we want a verbose version
  72996. * @returns a string representing the current skeleton data
  72997. */
  72998. toString(fullDetails?: boolean): string;
  72999. /**
  73000. * Get bone's index searching by name
  73001. * @param name defines bone's name to search for
  73002. * @return the indice of the bone. Returns -1 if not found
  73003. */
  73004. getBoneIndexByName(name: string): number;
  73005. /**
  73006. * Creater a new animation range
  73007. * @param name defines the name of the range
  73008. * @param from defines the start key
  73009. * @param to defines the end key
  73010. */
  73011. createAnimationRange(name: string, from: number, to: number): void;
  73012. /**
  73013. * Delete a specific animation range
  73014. * @param name defines the name of the range
  73015. * @param deleteFrames defines if frames must be removed as well
  73016. */
  73017. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  73018. /**
  73019. * Gets a specific animation range
  73020. * @param name defines the name of the range to look for
  73021. * @returns the requested animation range or null if not found
  73022. */
  73023. getAnimationRange(name: string): Nullable<AnimationRange>;
  73024. /**
  73025. * Gets the list of all animation ranges defined on this skeleton
  73026. * @returns an array
  73027. */
  73028. getAnimationRanges(): Nullable<AnimationRange>[];
  73029. /**
  73030. * Copy animation range from a source skeleton.
  73031. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  73032. * @param source defines the source skeleton
  73033. * @param name defines the name of the range to copy
  73034. * @param rescaleAsRequired defines if rescaling must be applied if required
  73035. * @returns true if operation was successful
  73036. */
  73037. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  73038. /**
  73039. * Forces the skeleton to go to rest pose
  73040. */
  73041. returnToRest(): void;
  73042. private _getHighestAnimationFrame;
  73043. /**
  73044. * Begin a specific animation range
  73045. * @param name defines the name of the range to start
  73046. * @param loop defines if looping must be turned on (false by default)
  73047. * @param speedRatio defines the speed ratio to apply (1 by default)
  73048. * @param onAnimationEnd defines a callback which will be called when animation will end
  73049. * @returns a new animatable
  73050. */
  73051. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  73052. /** @hidden */
  73053. _markAsDirty(): void;
  73054. /** @hidden */
  73055. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73056. /** @hidden */
  73057. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  73058. private _computeTransformMatrices;
  73059. /**
  73060. * Build all resources required to render a skeleton
  73061. */
  73062. prepare(): void;
  73063. /**
  73064. * Gets the list of animatables currently running for this skeleton
  73065. * @returns an array of animatables
  73066. */
  73067. getAnimatables(): IAnimatable[];
  73068. /**
  73069. * Clone the current skeleton
  73070. * @param name defines the name of the new skeleton
  73071. * @param id defines the id of the new skeleton
  73072. * @returns the new skeleton
  73073. */
  73074. clone(name: string, id: string): Skeleton;
  73075. /**
  73076. * Enable animation blending for this skeleton
  73077. * @param blendingSpeed defines the blending speed to apply
  73078. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  73079. */
  73080. enableBlending(blendingSpeed?: number): void;
  73081. /**
  73082. * Releases all resources associated with the current skeleton
  73083. */
  73084. dispose(): void;
  73085. /**
  73086. * Serialize the skeleton in a JSON object
  73087. * @returns a JSON object
  73088. */
  73089. serialize(): any;
  73090. /**
  73091. * Creates a new skeleton from serialized data
  73092. * @param parsedSkeleton defines the serialized data
  73093. * @param scene defines the hosting scene
  73094. * @returns a new skeleton
  73095. */
  73096. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  73097. /**
  73098. * Compute all node absolute transforms
  73099. * @param forceUpdate defines if computation must be done even if cache is up to date
  73100. */
  73101. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  73102. /**
  73103. * Gets the root pose matrix
  73104. * @returns a matrix
  73105. */
  73106. getPoseMatrix(): Nullable<Matrix>;
  73107. /**
  73108. * Sorts bones per internal index
  73109. */
  73110. sortBones(): void;
  73111. private _sortBones;
  73112. }
  73113. }
  73114. declare module BABYLON {
  73115. /**
  73116. * Defines a target to use with MorphTargetManager
  73117. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73118. */
  73119. export class MorphTarget implements IAnimatable {
  73120. /** defines the name of the target */
  73121. name: string;
  73122. /**
  73123. * Gets or sets the list of animations
  73124. */
  73125. animations: Animation[];
  73126. private _scene;
  73127. private _positions;
  73128. private _normals;
  73129. private _tangents;
  73130. private _uvs;
  73131. private _influence;
  73132. /**
  73133. * Observable raised when the influence changes
  73134. */
  73135. onInfluenceChanged: Observable<boolean>;
  73136. /** @hidden */
  73137. _onDataLayoutChanged: Observable<void>;
  73138. /**
  73139. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  73140. */
  73141. influence: number;
  73142. /**
  73143. * Gets or sets the id of the morph Target
  73144. */
  73145. id: string;
  73146. private _animationPropertiesOverride;
  73147. /**
  73148. * Gets or sets the animation properties override
  73149. */
  73150. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73151. /**
  73152. * Creates a new MorphTarget
  73153. * @param name defines the name of the target
  73154. * @param influence defines the influence to use
  73155. * @param scene defines the scene the morphtarget belongs to
  73156. */
  73157. constructor(
  73158. /** defines the name of the target */
  73159. name: string, influence?: number, scene?: Nullable<Scene>);
  73160. /**
  73161. * Gets a boolean defining if the target contains position data
  73162. */
  73163. readonly hasPositions: boolean;
  73164. /**
  73165. * Gets a boolean defining if the target contains normal data
  73166. */
  73167. readonly hasNormals: boolean;
  73168. /**
  73169. * Gets a boolean defining if the target contains tangent data
  73170. */
  73171. readonly hasTangents: boolean;
  73172. /**
  73173. * Gets a boolean defining if the target contains texture coordinates data
  73174. */
  73175. readonly hasUVs: boolean;
  73176. /**
  73177. * Affects position data to this target
  73178. * @param data defines the position data to use
  73179. */
  73180. setPositions(data: Nullable<FloatArray>): void;
  73181. /**
  73182. * Gets the position data stored in this target
  73183. * @returns a FloatArray containing the position data (or null if not present)
  73184. */
  73185. getPositions(): Nullable<FloatArray>;
  73186. /**
  73187. * Affects normal data to this target
  73188. * @param data defines the normal data to use
  73189. */
  73190. setNormals(data: Nullable<FloatArray>): void;
  73191. /**
  73192. * Gets the normal data stored in this target
  73193. * @returns a FloatArray containing the normal data (or null if not present)
  73194. */
  73195. getNormals(): Nullable<FloatArray>;
  73196. /**
  73197. * Affects tangent data to this target
  73198. * @param data defines the tangent data to use
  73199. */
  73200. setTangents(data: Nullable<FloatArray>): void;
  73201. /**
  73202. * Gets the tangent data stored in this target
  73203. * @returns a FloatArray containing the tangent data (or null if not present)
  73204. */
  73205. getTangents(): Nullable<FloatArray>;
  73206. /**
  73207. * Affects texture coordinates data to this target
  73208. * @param data defines the texture coordinates data to use
  73209. */
  73210. setUVs(data: Nullable<FloatArray>): void;
  73211. /**
  73212. * Gets the texture coordinates data stored in this target
  73213. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  73214. */
  73215. getUVs(): Nullable<FloatArray>;
  73216. /**
  73217. * Serializes the current target into a Serialization object
  73218. * @returns the serialized object
  73219. */
  73220. serialize(): any;
  73221. /**
  73222. * Returns the string "MorphTarget"
  73223. * @returns "MorphTarget"
  73224. */
  73225. getClassName(): string;
  73226. /**
  73227. * Creates a new target from serialized data
  73228. * @param serializationObject defines the serialized data to use
  73229. * @returns a new MorphTarget
  73230. */
  73231. static Parse(serializationObject: any): MorphTarget;
  73232. /**
  73233. * Creates a MorphTarget from mesh data
  73234. * @param mesh defines the source mesh
  73235. * @param name defines the name to use for the new target
  73236. * @param influence defines the influence to attach to the target
  73237. * @returns a new MorphTarget
  73238. */
  73239. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  73240. }
  73241. }
  73242. declare module BABYLON {
  73243. /**
  73244. * This class is used to deform meshes using morphing between different targets
  73245. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73246. */
  73247. export class MorphTargetManager {
  73248. private _targets;
  73249. private _targetInfluenceChangedObservers;
  73250. private _targetDataLayoutChangedObservers;
  73251. private _activeTargets;
  73252. private _scene;
  73253. private _influences;
  73254. private _supportsNormals;
  73255. private _supportsTangents;
  73256. private _supportsUVs;
  73257. private _vertexCount;
  73258. private _uniqueId;
  73259. private _tempInfluences;
  73260. /**
  73261. * Creates a new MorphTargetManager
  73262. * @param scene defines the current scene
  73263. */
  73264. constructor(scene?: Nullable<Scene>);
  73265. /**
  73266. * Gets the unique ID of this manager
  73267. */
  73268. readonly uniqueId: number;
  73269. /**
  73270. * Gets the number of vertices handled by this manager
  73271. */
  73272. readonly vertexCount: number;
  73273. /**
  73274. * Gets a boolean indicating if this manager supports morphing of normals
  73275. */
  73276. readonly supportsNormals: boolean;
  73277. /**
  73278. * Gets a boolean indicating if this manager supports morphing of tangents
  73279. */
  73280. readonly supportsTangents: boolean;
  73281. /**
  73282. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  73283. */
  73284. readonly supportsUVs: boolean;
  73285. /**
  73286. * Gets the number of targets stored in this manager
  73287. */
  73288. readonly numTargets: number;
  73289. /**
  73290. * Gets the number of influencers (ie. the number of targets with influences > 0)
  73291. */
  73292. readonly numInfluencers: number;
  73293. /**
  73294. * Gets the list of influences (one per target)
  73295. */
  73296. readonly influences: Float32Array;
  73297. /**
  73298. * Gets the active target at specified index. An active target is a target with an influence > 0
  73299. * @param index defines the index to check
  73300. * @returns the requested target
  73301. */
  73302. getActiveTarget(index: number): MorphTarget;
  73303. /**
  73304. * Gets the target at specified index
  73305. * @param index defines the index to check
  73306. * @returns the requested target
  73307. */
  73308. getTarget(index: number): MorphTarget;
  73309. /**
  73310. * Add a new target to this manager
  73311. * @param target defines the target to add
  73312. */
  73313. addTarget(target: MorphTarget): void;
  73314. /**
  73315. * Removes a target from the manager
  73316. * @param target defines the target to remove
  73317. */
  73318. removeTarget(target: MorphTarget): void;
  73319. /**
  73320. * Serializes the current manager into a Serialization object
  73321. * @returns the serialized object
  73322. */
  73323. serialize(): any;
  73324. private _syncActiveTargets;
  73325. /**
  73326. * Syncrhonize the targets with all the meshes using this morph target manager
  73327. */
  73328. synchronize(): void;
  73329. /**
  73330. * Creates a new MorphTargetManager from serialized data
  73331. * @param serializationObject defines the serialized data
  73332. * @param scene defines the hosting scene
  73333. * @returns the new MorphTargetManager
  73334. */
  73335. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73336. }
  73337. }
  73338. declare module BABYLON {
  73339. /**
  73340. * Groups all the scene component constants in one place to ease maintenance.
  73341. * @hidden
  73342. */
  73343. export class SceneComponentConstants {
  73344. static readonly NAME_EFFECTLAYER: string;
  73345. static readonly NAME_LAYER: string;
  73346. static readonly NAME_LENSFLARESYSTEM: string;
  73347. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73348. static readonly NAME_PARTICLESYSTEM: string;
  73349. static readonly NAME_GAMEPAD: string;
  73350. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73351. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73352. static readonly NAME_DEPTHRENDERER: string;
  73353. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73354. static readonly NAME_SPRITE: string;
  73355. static readonly NAME_OUTLINERENDERER: string;
  73356. static readonly NAME_PROCEDURALTEXTURE: string;
  73357. static readonly NAME_SHADOWGENERATOR: string;
  73358. static readonly NAME_OCTREE: string;
  73359. static readonly NAME_PHYSICSENGINE: string;
  73360. static readonly NAME_AUDIO: string;
  73361. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73362. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73363. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73364. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73365. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73366. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73367. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73368. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73369. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73370. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73371. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73372. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73373. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73374. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73375. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73376. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73377. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73378. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73379. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73380. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73381. static readonly STEP_AFTERRENDER_AUDIO: number;
  73382. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73383. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73384. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73385. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73386. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73387. static readonly STEP_POINTERMOVE_SPRITE: number;
  73388. static readonly STEP_POINTERDOWN_SPRITE: number;
  73389. static readonly STEP_POINTERUP_SPRITE: number;
  73390. }
  73391. /**
  73392. * This represents a scene component.
  73393. *
  73394. * This is used to decouple the dependency the scene is having on the different workloads like
  73395. * layers, post processes...
  73396. */
  73397. export interface ISceneComponent {
  73398. /**
  73399. * The name of the component. Each component must have a unique name.
  73400. */
  73401. name: string;
  73402. /**
  73403. * The scene the component belongs to.
  73404. */
  73405. scene: Scene;
  73406. /**
  73407. * Register the component to one instance of a scene.
  73408. */
  73409. register(): void;
  73410. /**
  73411. * Rebuilds the elements related to this component in case of
  73412. * context lost for instance.
  73413. */
  73414. rebuild(): void;
  73415. /**
  73416. * Disposes the component and the associated ressources.
  73417. */
  73418. dispose(): void;
  73419. }
  73420. /**
  73421. * This represents a SERIALIZABLE scene component.
  73422. *
  73423. * This extends Scene Component to add Serialization methods on top.
  73424. */
  73425. export interface ISceneSerializableComponent extends ISceneComponent {
  73426. /**
  73427. * Adds all the elements from the container to the scene
  73428. * @param container the container holding the elements
  73429. */
  73430. addFromContainer(container: AbstractScene): void;
  73431. /**
  73432. * Removes all the elements in the container from the scene
  73433. * @param container contains the elements to remove
  73434. * @param dispose if the removed element should be disposed (default: false)
  73435. */
  73436. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73437. /**
  73438. * Serializes the component data to the specified json object
  73439. * @param serializationObject The object to serialize to
  73440. */
  73441. serialize(serializationObject: any): void;
  73442. }
  73443. /**
  73444. * Strong typing of a Mesh related stage step action
  73445. */
  73446. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73447. /**
  73448. * Strong typing of a Evaluate Sub Mesh related stage step action
  73449. */
  73450. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73451. /**
  73452. * Strong typing of a Active Mesh related stage step action
  73453. */
  73454. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73455. /**
  73456. * Strong typing of a Camera related stage step action
  73457. */
  73458. export type CameraStageAction = (camera: Camera) => void;
  73459. /**
  73460. * Strong typing of a Camera Frame buffer related stage step action
  73461. */
  73462. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73463. /**
  73464. * Strong typing of a Render Target related stage step action
  73465. */
  73466. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73467. /**
  73468. * Strong typing of a RenderingGroup related stage step action
  73469. */
  73470. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73471. /**
  73472. * Strong typing of a Mesh Render related stage step action
  73473. */
  73474. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73475. /**
  73476. * Strong typing of a simple stage step action
  73477. */
  73478. export type SimpleStageAction = () => void;
  73479. /**
  73480. * Strong typing of a render target action.
  73481. */
  73482. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73483. /**
  73484. * Strong typing of a pointer move action.
  73485. */
  73486. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73487. /**
  73488. * Strong typing of a pointer up/down action.
  73489. */
  73490. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73491. /**
  73492. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73493. * @hidden
  73494. */
  73495. export class Stage<T extends Function> extends Array<{
  73496. index: number;
  73497. component: ISceneComponent;
  73498. action: T;
  73499. }> {
  73500. /**
  73501. * Hide ctor from the rest of the world.
  73502. * @param items The items to add.
  73503. */
  73504. private constructor();
  73505. /**
  73506. * Creates a new Stage.
  73507. * @returns A new instance of a Stage
  73508. */
  73509. static Create<T extends Function>(): Stage<T>;
  73510. /**
  73511. * Registers a step in an ordered way in the targeted stage.
  73512. * @param index Defines the position to register the step in
  73513. * @param component Defines the component attached to the step
  73514. * @param action Defines the action to launch during the step
  73515. */
  73516. registerStep(index: number, component: ISceneComponent, action: T): void;
  73517. /**
  73518. * Clears all the steps from the stage.
  73519. */
  73520. clear(): void;
  73521. }
  73522. }
  73523. declare module BABYLON {
  73524. /**
  73525. * Class used to represent a specific level of detail of a mesh
  73526. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73527. */
  73528. export class MeshLODLevel {
  73529. /** Defines the distance where this level should star being displayed */
  73530. distance: number;
  73531. /** Defines the mesh to use to render this level */
  73532. mesh: Nullable<Mesh>;
  73533. /**
  73534. * Creates a new LOD level
  73535. * @param distance defines the distance where this level should star being displayed
  73536. * @param mesh defines the mesh to use to render this level
  73537. */
  73538. constructor(
  73539. /** Defines the distance where this level should star being displayed */
  73540. distance: number,
  73541. /** Defines the mesh to use to render this level */
  73542. mesh: Nullable<Mesh>);
  73543. }
  73544. }
  73545. declare module BABYLON {
  73546. /**
  73547. * Interface describing all the common properties and methods a shadow light needs to implement.
  73548. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73549. * as well as binding the different shadow properties to the effects.
  73550. */
  73551. export interface IShadowLight extends Light {
  73552. /**
  73553. * The light id in the scene (used in scene.findLighById for instance)
  73554. */
  73555. id: string;
  73556. /**
  73557. * The position the shdow will be casted from.
  73558. */
  73559. position: Vector3;
  73560. /**
  73561. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73562. */
  73563. direction: Vector3;
  73564. /**
  73565. * The transformed position. Position of the light in world space taking parenting in account.
  73566. */
  73567. transformedPosition: Vector3;
  73568. /**
  73569. * The transformed direction. Direction of the light in world space taking parenting in account.
  73570. */
  73571. transformedDirection: Vector3;
  73572. /**
  73573. * The friendly name of the light in the scene.
  73574. */
  73575. name: string;
  73576. /**
  73577. * Defines the shadow projection clipping minimum z value.
  73578. */
  73579. shadowMinZ: number;
  73580. /**
  73581. * Defines the shadow projection clipping maximum z value.
  73582. */
  73583. shadowMaxZ: number;
  73584. /**
  73585. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73586. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73587. */
  73588. computeTransformedInformation(): boolean;
  73589. /**
  73590. * Gets the scene the light belongs to.
  73591. * @returns The scene
  73592. */
  73593. getScene(): Scene;
  73594. /**
  73595. * Callback defining a custom Projection Matrix Builder.
  73596. * This can be used to override the default projection matrix computation.
  73597. */
  73598. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73599. /**
  73600. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73601. * @param matrix The materix to updated with the projection information
  73602. * @param viewMatrix The transform matrix of the light
  73603. * @param renderList The list of mesh to render in the map
  73604. * @returns The current light
  73605. */
  73606. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73607. /**
  73608. * Gets the current depth scale used in ESM.
  73609. * @returns The scale
  73610. */
  73611. getDepthScale(): number;
  73612. /**
  73613. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73614. * @returns true if a cube texture needs to be use
  73615. */
  73616. needCube(): boolean;
  73617. /**
  73618. * Detects if the projection matrix requires to be recomputed this frame.
  73619. * @returns true if it requires to be recomputed otherwise, false.
  73620. */
  73621. needProjectionMatrixCompute(): boolean;
  73622. /**
  73623. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73624. */
  73625. forceProjectionMatrixCompute(): void;
  73626. /**
  73627. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73628. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73629. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73630. */
  73631. getShadowDirection(faceIndex?: number): Vector3;
  73632. /**
  73633. * Gets the minZ used for shadow according to both the scene and the light.
  73634. * @param activeCamera The camera we are returning the min for
  73635. * @returns the depth min z
  73636. */
  73637. getDepthMinZ(activeCamera: Camera): number;
  73638. /**
  73639. * Gets the maxZ used for shadow according to both the scene and the light.
  73640. * @param activeCamera The camera we are returning the max for
  73641. * @returns the depth max z
  73642. */
  73643. getDepthMaxZ(activeCamera: Camera): number;
  73644. }
  73645. /**
  73646. * Base implementation IShadowLight
  73647. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73648. */
  73649. export abstract class ShadowLight extends Light implements IShadowLight {
  73650. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73651. protected _position: Vector3;
  73652. protected _setPosition(value: Vector3): void;
  73653. /**
  73654. * Sets the position the shadow will be casted from. Also use as the light position for both
  73655. * point and spot lights.
  73656. */
  73657. /**
  73658. * Sets the position the shadow will be casted from. Also use as the light position for both
  73659. * point and spot lights.
  73660. */
  73661. position: Vector3;
  73662. protected _direction: Vector3;
  73663. protected _setDirection(value: Vector3): void;
  73664. /**
  73665. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73666. * Also use as the light direction on spot and directional lights.
  73667. */
  73668. /**
  73669. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73670. * Also use as the light direction on spot and directional lights.
  73671. */
  73672. direction: Vector3;
  73673. private _shadowMinZ;
  73674. /**
  73675. * Gets the shadow projection clipping minimum z value.
  73676. */
  73677. /**
  73678. * Sets the shadow projection clipping minimum z value.
  73679. */
  73680. shadowMinZ: number;
  73681. private _shadowMaxZ;
  73682. /**
  73683. * Sets the shadow projection clipping maximum z value.
  73684. */
  73685. /**
  73686. * Gets the shadow projection clipping maximum z value.
  73687. */
  73688. shadowMaxZ: number;
  73689. /**
  73690. * Callback defining a custom Projection Matrix Builder.
  73691. * This can be used to override the default projection matrix computation.
  73692. */
  73693. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73694. /**
  73695. * The transformed position. Position of the light in world space taking parenting in account.
  73696. */
  73697. transformedPosition: Vector3;
  73698. /**
  73699. * The transformed direction. Direction of the light in world space taking parenting in account.
  73700. */
  73701. transformedDirection: Vector3;
  73702. private _needProjectionMatrixCompute;
  73703. /**
  73704. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73705. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73706. */
  73707. computeTransformedInformation(): boolean;
  73708. /**
  73709. * Return the depth scale used for the shadow map.
  73710. * @returns the depth scale.
  73711. */
  73712. getDepthScale(): number;
  73713. /**
  73714. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73715. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73716. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73717. */
  73718. getShadowDirection(faceIndex?: number): Vector3;
  73719. /**
  73720. * Returns the ShadowLight absolute position in the World.
  73721. * @returns the position vector in world space
  73722. */
  73723. getAbsolutePosition(): Vector3;
  73724. /**
  73725. * Sets the ShadowLight direction toward the passed target.
  73726. * @param target The point to target in local space
  73727. * @returns the updated ShadowLight direction
  73728. */
  73729. setDirectionToTarget(target: Vector3): Vector3;
  73730. /**
  73731. * Returns the light rotation in euler definition.
  73732. * @returns the x y z rotation in local space.
  73733. */
  73734. getRotation(): Vector3;
  73735. /**
  73736. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73737. * @returns true if a cube texture needs to be use
  73738. */
  73739. needCube(): boolean;
  73740. /**
  73741. * Detects if the projection matrix requires to be recomputed this frame.
  73742. * @returns true if it requires to be recomputed otherwise, false.
  73743. */
  73744. needProjectionMatrixCompute(): boolean;
  73745. /**
  73746. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73747. */
  73748. forceProjectionMatrixCompute(): void;
  73749. /** @hidden */
  73750. _initCache(): void;
  73751. /** @hidden */
  73752. _isSynchronized(): boolean;
  73753. /**
  73754. * Computes the world matrix of the node
  73755. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73756. * @returns the world matrix
  73757. */
  73758. computeWorldMatrix(force?: boolean): Matrix;
  73759. /**
  73760. * Gets the minZ used for shadow according to both the scene and the light.
  73761. * @param activeCamera The camera we are returning the min for
  73762. * @returns the depth min z
  73763. */
  73764. getDepthMinZ(activeCamera: Camera): number;
  73765. /**
  73766. * Gets the maxZ used for shadow according to both the scene and the light.
  73767. * @param activeCamera The camera we are returning the max for
  73768. * @returns the depth max z
  73769. */
  73770. getDepthMaxZ(activeCamera: Camera): number;
  73771. /**
  73772. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73773. * @param matrix The materix to updated with the projection information
  73774. * @param viewMatrix The transform matrix of the light
  73775. * @param renderList The list of mesh to render in the map
  73776. * @returns The current light
  73777. */
  73778. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73779. }
  73780. }
  73781. declare module BABYLON {
  73782. /**
  73783. * "Static Class" containing the most commonly used helper while dealing with material for
  73784. * rendering purpose.
  73785. *
  73786. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73787. *
  73788. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73789. */
  73790. export class MaterialHelper {
  73791. /**
  73792. * Bind the current view position to an effect.
  73793. * @param effect The effect to be bound
  73794. * @param scene The scene the eyes position is used from
  73795. */
  73796. static BindEyePosition(effect: Effect, scene: Scene): void;
  73797. /**
  73798. * Helps preparing the defines values about the UVs in used in the effect.
  73799. * UVs are shared as much as we can accross channels in the shaders.
  73800. * @param texture The texture we are preparing the UVs for
  73801. * @param defines The defines to update
  73802. * @param key The channel key "diffuse", "specular"... used in the shader
  73803. */
  73804. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73805. /**
  73806. * Binds a texture matrix value to its corrsponding uniform
  73807. * @param texture The texture to bind the matrix for
  73808. * @param uniformBuffer The uniform buffer receivin the data
  73809. * @param key The channel key "diffuse", "specular"... used in the shader
  73810. */
  73811. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73812. /**
  73813. * Gets the current status of the fog (should it be enabled?)
  73814. * @param mesh defines the mesh to evaluate for fog support
  73815. * @param scene defines the hosting scene
  73816. * @returns true if fog must be enabled
  73817. */
  73818. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73819. /**
  73820. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73821. * @param mesh defines the current mesh
  73822. * @param scene defines the current scene
  73823. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73824. * @param pointsCloud defines if point cloud rendering has to be turned on
  73825. * @param fogEnabled defines if fog has to be turned on
  73826. * @param alphaTest defines if alpha testing has to be turned on
  73827. * @param defines defines the current list of defines
  73828. */
  73829. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73830. /**
  73831. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73832. * @param scene defines the current scene
  73833. * @param engine defines the current engine
  73834. * @param defines specifies the list of active defines
  73835. * @param useInstances defines if instances have to be turned on
  73836. * @param useClipPlane defines if clip plane have to be turned on
  73837. */
  73838. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73839. /**
  73840. * Prepares the defines for bones
  73841. * @param mesh The mesh containing the geometry data we will draw
  73842. * @param defines The defines to update
  73843. */
  73844. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73845. /**
  73846. * Prepares the defines for morph targets
  73847. * @param mesh The mesh containing the geometry data we will draw
  73848. * @param defines The defines to update
  73849. */
  73850. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73851. /**
  73852. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73853. * @param mesh The mesh containing the geometry data we will draw
  73854. * @param defines The defines to update
  73855. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73856. * @param useBones Precise whether bones should be used or not (override mesh info)
  73857. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73858. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73859. * @returns false if defines are considered not dirty and have not been checked
  73860. */
  73861. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73862. /**
  73863. * Prepares the defines related to multiview
  73864. * @param scene The scene we are intending to draw
  73865. * @param defines The defines to update
  73866. */
  73867. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73868. /**
  73869. * Prepares the defines related to the light information passed in parameter
  73870. * @param scene The scene we are intending to draw
  73871. * @param mesh The mesh the effect is compiling for
  73872. * @param light The light the effect is compiling for
  73873. * @param lightIndex The index of the light
  73874. * @param defines The defines to update
  73875. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73876. * @param state Defines the current state regarding what is needed (normals, etc...)
  73877. */
  73878. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73879. needNormals: boolean;
  73880. needRebuild: boolean;
  73881. shadowEnabled: boolean;
  73882. specularEnabled: boolean;
  73883. lightmapMode: boolean;
  73884. }): void;
  73885. /**
  73886. * Prepares the defines related to the light information passed in parameter
  73887. * @param scene The scene we are intending to draw
  73888. * @param mesh The mesh the effect is compiling for
  73889. * @param defines The defines to update
  73890. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73891. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73892. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73893. * @returns true if normals will be required for the rest of the effect
  73894. */
  73895. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73896. /**
  73897. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73898. * @param lightIndex defines the light index
  73899. * @param uniformsList The uniform list
  73900. * @param samplersList The sampler list
  73901. * @param projectedLightTexture defines if projected texture must be used
  73902. * @param uniformBuffersList defines an optional list of uniform buffers
  73903. */
  73904. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73905. /**
  73906. * Prepares the uniforms and samplers list to be used in the effect
  73907. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73908. * @param samplersList The sampler list
  73909. * @param defines The defines helping in the list generation
  73910. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73911. */
  73912. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73913. /**
  73914. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73915. * @param defines The defines to update while falling back
  73916. * @param fallbacks The authorized effect fallbacks
  73917. * @param maxSimultaneousLights The maximum number of lights allowed
  73918. * @param rank the current rank of the Effect
  73919. * @returns The newly affected rank
  73920. */
  73921. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73922. private static _TmpMorphInfluencers;
  73923. /**
  73924. * Prepares the list of attributes required for morph targets according to the effect defines.
  73925. * @param attribs The current list of supported attribs
  73926. * @param mesh The mesh to prepare the morph targets attributes for
  73927. * @param influencers The number of influencers
  73928. */
  73929. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73930. /**
  73931. * Prepares the list of attributes required for morph targets according to the effect defines.
  73932. * @param attribs The current list of supported attribs
  73933. * @param mesh The mesh to prepare the morph targets attributes for
  73934. * @param defines The current Defines of the effect
  73935. */
  73936. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73937. /**
  73938. * Prepares the list of attributes required for bones according to the effect defines.
  73939. * @param attribs The current list of supported attribs
  73940. * @param mesh The mesh to prepare the bones attributes for
  73941. * @param defines The current Defines of the effect
  73942. * @param fallbacks The current efffect fallback strategy
  73943. */
  73944. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73945. /**
  73946. * Check and prepare the list of attributes required for instances according to the effect defines.
  73947. * @param attribs The current list of supported attribs
  73948. * @param defines The current MaterialDefines of the effect
  73949. */
  73950. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73951. /**
  73952. * Add the list of attributes required for instances to the attribs array.
  73953. * @param attribs The current list of supported attribs
  73954. */
  73955. static PushAttributesForInstances(attribs: string[]): void;
  73956. /**
  73957. * Binds the light shadow information to the effect for the given mesh.
  73958. * @param light The light containing the generator
  73959. * @param scene The scene the lights belongs to
  73960. * @param mesh The mesh we are binding the information to render
  73961. * @param lightIndex The light index in the effect used to render the mesh
  73962. * @param effect The effect we are binding the data to
  73963. */
  73964. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73965. /**
  73966. * Binds the light information to the effect.
  73967. * @param light The light containing the generator
  73968. * @param effect The effect we are binding the data to
  73969. * @param lightIndex The light index in the effect used to render
  73970. */
  73971. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73972. /**
  73973. * Binds the lights information from the scene to the effect for the given mesh.
  73974. * @param light Light to bind
  73975. * @param lightIndex Light index
  73976. * @param scene The scene where the light belongs to
  73977. * @param mesh The mesh we are binding the information to render
  73978. * @param effect The effect we are binding the data to
  73979. * @param useSpecular Defines if specular is supported
  73980. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73981. */
  73982. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73983. /**
  73984. * Binds the lights information from the scene to the effect for the given mesh.
  73985. * @param scene The scene the lights belongs to
  73986. * @param mesh The mesh we are binding the information to render
  73987. * @param effect The effect we are binding the data to
  73988. * @param defines The generated defines for the effect
  73989. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73990. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73991. */
  73992. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73993. private static _tempFogColor;
  73994. /**
  73995. * Binds the fog information from the scene to the effect for the given mesh.
  73996. * @param scene The scene the lights belongs to
  73997. * @param mesh The mesh we are binding the information to render
  73998. * @param effect The effect we are binding the data to
  73999. * @param linearSpace Defines if the fog effect is applied in linear space
  74000. */
  74001. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74002. /**
  74003. * Binds the bones information from the mesh to the effect.
  74004. * @param mesh The mesh we are binding the information to render
  74005. * @param effect The effect we are binding the data to
  74006. */
  74007. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74008. /**
  74009. * Binds the morph targets information from the mesh to the effect.
  74010. * @param abstractMesh The mesh we are binding the information to render
  74011. * @param effect The effect we are binding the data to
  74012. */
  74013. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74014. /**
  74015. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74016. * @param defines The generated defines used in the effect
  74017. * @param effect The effect we are binding the data to
  74018. * @param scene The scene we are willing to render with logarithmic scale for
  74019. */
  74020. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74021. /**
  74022. * Binds the clip plane information from the scene to the effect.
  74023. * @param scene The scene the clip plane information are extracted from
  74024. * @param effect The effect we are binding the data to
  74025. */
  74026. static BindClipPlane(effect: Effect, scene: Scene): void;
  74027. }
  74028. }
  74029. declare module BABYLON {
  74030. /** @hidden */
  74031. export var shadowMapPixelShader: {
  74032. name: string;
  74033. shader: string;
  74034. };
  74035. }
  74036. declare module BABYLON {
  74037. /** @hidden */
  74038. export var bonesDeclaration: {
  74039. name: string;
  74040. shader: string;
  74041. };
  74042. }
  74043. declare module BABYLON {
  74044. /** @hidden */
  74045. export var morphTargetsVertexGlobalDeclaration: {
  74046. name: string;
  74047. shader: string;
  74048. };
  74049. }
  74050. declare module BABYLON {
  74051. /** @hidden */
  74052. export var morphTargetsVertexDeclaration: {
  74053. name: string;
  74054. shader: string;
  74055. };
  74056. }
  74057. declare module BABYLON {
  74058. /** @hidden */
  74059. export var instancesDeclaration: {
  74060. name: string;
  74061. shader: string;
  74062. };
  74063. }
  74064. declare module BABYLON {
  74065. /** @hidden */
  74066. export var helperFunctions: {
  74067. name: string;
  74068. shader: string;
  74069. };
  74070. }
  74071. declare module BABYLON {
  74072. /** @hidden */
  74073. export var morphTargetsVertex: {
  74074. name: string;
  74075. shader: string;
  74076. };
  74077. }
  74078. declare module BABYLON {
  74079. /** @hidden */
  74080. export var instancesVertex: {
  74081. name: string;
  74082. shader: string;
  74083. };
  74084. }
  74085. declare module BABYLON {
  74086. /** @hidden */
  74087. export var bonesVertex: {
  74088. name: string;
  74089. shader: string;
  74090. };
  74091. }
  74092. declare module BABYLON {
  74093. /** @hidden */
  74094. export var shadowMapVertexShader: {
  74095. name: string;
  74096. shader: string;
  74097. };
  74098. }
  74099. declare module BABYLON {
  74100. /** @hidden */
  74101. export var depthBoxBlurPixelShader: {
  74102. name: string;
  74103. shader: string;
  74104. };
  74105. }
  74106. declare module BABYLON {
  74107. /**
  74108. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74109. */
  74110. export interface ICustomShaderOptions {
  74111. /**
  74112. * Gets or sets the custom shader name to use
  74113. */
  74114. shaderName: string;
  74115. /**
  74116. * The list of attribute names used in the shader
  74117. */
  74118. attributes?: string[];
  74119. /**
  74120. * The list of unifrom names used in the shader
  74121. */
  74122. uniforms?: string[];
  74123. /**
  74124. * The list of sampler names used in the shader
  74125. */
  74126. samplers?: string[];
  74127. /**
  74128. * The list of defines used in the shader
  74129. */
  74130. defines?: string[];
  74131. }
  74132. /**
  74133. * Interface to implement to create a shadow generator compatible with BJS.
  74134. */
  74135. export interface IShadowGenerator {
  74136. /**
  74137. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74138. * @returns The render target texture if present otherwise, null
  74139. */
  74140. getShadowMap(): Nullable<RenderTargetTexture>;
  74141. /**
  74142. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74143. * @returns The render target texture if the shadow map is present otherwise, null
  74144. */
  74145. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74146. /**
  74147. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74148. * @param subMesh The submesh we want to render in the shadow map
  74149. * @param useInstances Defines wether will draw in the map using instances
  74150. * @returns true if ready otherwise, false
  74151. */
  74152. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74153. /**
  74154. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74155. * @param defines Defines of the material we want to update
  74156. * @param lightIndex Index of the light in the enabled light list of the material
  74157. */
  74158. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74159. /**
  74160. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74161. * defined in the generator but impacting the effect).
  74162. * It implies the unifroms available on the materials are the standard BJS ones.
  74163. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74164. * @param effect The effect we are binfing the information for
  74165. */
  74166. bindShadowLight(lightIndex: string, effect: Effect): void;
  74167. /**
  74168. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74169. * (eq to shadow prjection matrix * light transform matrix)
  74170. * @returns The transform matrix used to create the shadow map
  74171. */
  74172. getTransformMatrix(): Matrix;
  74173. /**
  74174. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74175. * Cube and 2D textures for instance.
  74176. */
  74177. recreateShadowMap(): void;
  74178. /**
  74179. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74180. * @param onCompiled Callback triggered at the and of the effects compilation
  74181. * @param options Sets of optional options forcing the compilation with different modes
  74182. */
  74183. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74184. useInstances: boolean;
  74185. }>): void;
  74186. /**
  74187. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74188. * @param options Sets of optional options forcing the compilation with different modes
  74189. * @returns A promise that resolves when the compilation completes
  74190. */
  74191. forceCompilationAsync(options?: Partial<{
  74192. useInstances: boolean;
  74193. }>): Promise<void>;
  74194. /**
  74195. * Serializes the shadow generator setup to a json object.
  74196. * @returns The serialized JSON object
  74197. */
  74198. serialize(): any;
  74199. /**
  74200. * Disposes the Shadow map and related Textures and effects.
  74201. */
  74202. dispose(): void;
  74203. }
  74204. /**
  74205. * Default implementation IShadowGenerator.
  74206. * This is the main object responsible of generating shadows in the framework.
  74207. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74208. */
  74209. export class ShadowGenerator implements IShadowGenerator {
  74210. /**
  74211. * Shadow generator mode None: no filtering applied.
  74212. */
  74213. static readonly FILTER_NONE: number;
  74214. /**
  74215. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74216. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74217. */
  74218. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74219. /**
  74220. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74221. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74222. */
  74223. static readonly FILTER_POISSONSAMPLING: number;
  74224. /**
  74225. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74226. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74227. */
  74228. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74229. /**
  74230. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74231. * edge artifacts on steep falloff.
  74232. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74233. */
  74234. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74235. /**
  74236. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74237. * edge artifacts on steep falloff.
  74238. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74239. */
  74240. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74241. /**
  74242. * Shadow generator mode PCF: Percentage Closer Filtering
  74243. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74244. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74245. */
  74246. static readonly FILTER_PCF: number;
  74247. /**
  74248. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74249. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74250. * Contact Hardening
  74251. */
  74252. static readonly FILTER_PCSS: number;
  74253. /**
  74254. * Reserved for PCF and PCSS
  74255. * Highest Quality.
  74256. *
  74257. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74258. *
  74259. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74260. */
  74261. static readonly QUALITY_HIGH: number;
  74262. /**
  74263. * Reserved for PCF and PCSS
  74264. * Good tradeoff for quality/perf cross devices
  74265. *
  74266. * Execute PCF on a 3*3 kernel.
  74267. *
  74268. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74269. */
  74270. static readonly QUALITY_MEDIUM: number;
  74271. /**
  74272. * Reserved for PCF and PCSS
  74273. * The lowest quality but the fastest.
  74274. *
  74275. * Execute PCF on a 1*1 kernel.
  74276. *
  74277. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74278. */
  74279. static readonly QUALITY_LOW: number;
  74280. /** Gets or sets the custom shader name to use */
  74281. customShaderOptions: ICustomShaderOptions;
  74282. /**
  74283. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74284. */
  74285. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74286. /**
  74287. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74288. */
  74289. onAfterShadowMapRenderObservable: Observable<Effect>;
  74290. /**
  74291. * Observable triggered before a mesh is rendered in the shadow map.
  74292. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74293. */
  74294. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74295. /**
  74296. * Observable triggered after a mesh is rendered in the shadow map.
  74297. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74298. */
  74299. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74300. private _bias;
  74301. /**
  74302. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74303. */
  74304. /**
  74305. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74306. */
  74307. bias: number;
  74308. private _normalBias;
  74309. /**
  74310. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74311. */
  74312. /**
  74313. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74314. */
  74315. normalBias: number;
  74316. private _blurBoxOffset;
  74317. /**
  74318. * Gets the blur box offset: offset applied during the blur pass.
  74319. * Only useful if useKernelBlur = false
  74320. */
  74321. /**
  74322. * Sets the blur box offset: offset applied during the blur pass.
  74323. * Only useful if useKernelBlur = false
  74324. */
  74325. blurBoxOffset: number;
  74326. private _blurScale;
  74327. /**
  74328. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74329. * 2 means half of the size.
  74330. */
  74331. /**
  74332. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74333. * 2 means half of the size.
  74334. */
  74335. blurScale: number;
  74336. private _blurKernel;
  74337. /**
  74338. * Gets the blur kernel: kernel size of the blur pass.
  74339. * Only useful if useKernelBlur = true
  74340. */
  74341. /**
  74342. * Sets the blur kernel: kernel size of the blur pass.
  74343. * Only useful if useKernelBlur = true
  74344. */
  74345. blurKernel: number;
  74346. private _useKernelBlur;
  74347. /**
  74348. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74349. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74350. */
  74351. /**
  74352. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74353. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74354. */
  74355. useKernelBlur: boolean;
  74356. private _depthScale;
  74357. /**
  74358. * Gets the depth scale used in ESM mode.
  74359. */
  74360. /**
  74361. * Sets the depth scale used in ESM mode.
  74362. * This can override the scale stored on the light.
  74363. */
  74364. depthScale: number;
  74365. private _filter;
  74366. /**
  74367. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74368. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74369. */
  74370. /**
  74371. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74372. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74373. */
  74374. filter: number;
  74375. /**
  74376. * Gets if the current filter is set to Poisson Sampling.
  74377. */
  74378. /**
  74379. * Sets the current filter to Poisson Sampling.
  74380. */
  74381. usePoissonSampling: boolean;
  74382. /**
  74383. * Gets if the current filter is set to ESM.
  74384. */
  74385. /**
  74386. * Sets the current filter is to ESM.
  74387. */
  74388. useExponentialShadowMap: boolean;
  74389. /**
  74390. * Gets if the current filter is set to filtered ESM.
  74391. */
  74392. /**
  74393. * Gets if the current filter is set to filtered ESM.
  74394. */
  74395. useBlurExponentialShadowMap: boolean;
  74396. /**
  74397. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74398. * exponential to prevent steep falloff artifacts).
  74399. */
  74400. /**
  74401. * Sets the current filter to "close ESM" (using the inverse of the
  74402. * exponential to prevent steep falloff artifacts).
  74403. */
  74404. useCloseExponentialShadowMap: boolean;
  74405. /**
  74406. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74407. * exponential to prevent steep falloff artifacts).
  74408. */
  74409. /**
  74410. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74411. * exponential to prevent steep falloff artifacts).
  74412. */
  74413. useBlurCloseExponentialShadowMap: boolean;
  74414. /**
  74415. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74416. */
  74417. /**
  74418. * Sets the current filter to "PCF" (percentage closer filtering).
  74419. */
  74420. usePercentageCloserFiltering: boolean;
  74421. private _filteringQuality;
  74422. /**
  74423. * Gets the PCF or PCSS Quality.
  74424. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74425. */
  74426. /**
  74427. * Sets the PCF or PCSS Quality.
  74428. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74429. */
  74430. filteringQuality: number;
  74431. /**
  74432. * Gets if the current filter is set to "PCSS" (contact hardening).
  74433. */
  74434. /**
  74435. * Sets the current filter to "PCSS" (contact hardening).
  74436. */
  74437. useContactHardeningShadow: boolean;
  74438. private _contactHardeningLightSizeUVRatio;
  74439. /**
  74440. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74441. * Using a ratio helps keeping shape stability independently of the map size.
  74442. *
  74443. * It does not account for the light projection as it was having too much
  74444. * instability during the light setup or during light position changes.
  74445. *
  74446. * Only valid if useContactHardeningShadow is true.
  74447. */
  74448. /**
  74449. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74450. * Using a ratio helps keeping shape stability independently of the map size.
  74451. *
  74452. * It does not account for the light projection as it was having too much
  74453. * instability during the light setup or during light position changes.
  74454. *
  74455. * Only valid if useContactHardeningShadow is true.
  74456. */
  74457. contactHardeningLightSizeUVRatio: number;
  74458. private _darkness;
  74459. /** Gets or sets the actual darkness of a shadow */
  74460. darkness: number;
  74461. /**
  74462. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74463. * 0 means strongest and 1 would means no shadow.
  74464. * @returns the darkness.
  74465. */
  74466. getDarkness(): number;
  74467. /**
  74468. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74469. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74470. * @returns the shadow generator allowing fluent coding.
  74471. */
  74472. setDarkness(darkness: number): ShadowGenerator;
  74473. private _transparencyShadow;
  74474. /** Gets or sets the ability to have transparent shadow */
  74475. transparencyShadow: boolean;
  74476. /**
  74477. * Sets the ability to have transparent shadow (boolean).
  74478. * @param transparent True if transparent else False
  74479. * @returns the shadow generator allowing fluent coding
  74480. */
  74481. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74482. private _shadowMap;
  74483. private _shadowMap2;
  74484. /**
  74485. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74486. * @returns The render target texture if present otherwise, null
  74487. */
  74488. getShadowMap(): Nullable<RenderTargetTexture>;
  74489. /**
  74490. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74491. * @returns The render target texture if the shadow map is present otherwise, null
  74492. */
  74493. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74494. /**
  74495. * Gets the class name of that object
  74496. * @returns "ShadowGenerator"
  74497. */
  74498. getClassName(): string;
  74499. /**
  74500. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74501. * @param mesh Mesh to add
  74502. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74503. * @returns the Shadow Generator itself
  74504. */
  74505. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74506. /**
  74507. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74508. * @param mesh Mesh to remove
  74509. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74510. * @returns the Shadow Generator itself
  74511. */
  74512. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74513. /**
  74514. * Controls the extent to which the shadows fade out at the edge of the frustum
  74515. * Used only by directionals and spots
  74516. */
  74517. frustumEdgeFalloff: number;
  74518. private _light;
  74519. /**
  74520. * Returns the associated light object.
  74521. * @returns the light generating the shadow
  74522. */
  74523. getLight(): IShadowLight;
  74524. /**
  74525. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74526. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74527. * It might on the other hand introduce peter panning.
  74528. */
  74529. forceBackFacesOnly: boolean;
  74530. private _scene;
  74531. private _lightDirection;
  74532. private _effect;
  74533. private _viewMatrix;
  74534. private _projectionMatrix;
  74535. private _transformMatrix;
  74536. private _cachedPosition;
  74537. private _cachedDirection;
  74538. private _cachedDefines;
  74539. private _currentRenderID;
  74540. private _boxBlurPostprocess;
  74541. private _kernelBlurXPostprocess;
  74542. private _kernelBlurYPostprocess;
  74543. private _blurPostProcesses;
  74544. private _mapSize;
  74545. private _currentFaceIndex;
  74546. private _currentFaceIndexCache;
  74547. private _textureType;
  74548. private _defaultTextureMatrix;
  74549. /** @hidden */
  74550. static _SceneComponentInitialization: (scene: Scene) => void;
  74551. /**
  74552. * Creates a ShadowGenerator object.
  74553. * A ShadowGenerator is the required tool to use the shadows.
  74554. * Each light casting shadows needs to use its own ShadowGenerator.
  74555. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74556. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74557. * @param light The light object generating the shadows.
  74558. * @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.
  74559. */
  74560. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74561. private _initializeGenerator;
  74562. private _initializeShadowMap;
  74563. private _initializeBlurRTTAndPostProcesses;
  74564. private _renderForShadowMap;
  74565. private _renderSubMeshForShadowMap;
  74566. private _applyFilterValues;
  74567. /**
  74568. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74569. * @param onCompiled Callback triggered at the and of the effects compilation
  74570. * @param options Sets of optional options forcing the compilation with different modes
  74571. */
  74572. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74573. useInstances: boolean;
  74574. }>): void;
  74575. /**
  74576. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74577. * @param options Sets of optional options forcing the compilation with different modes
  74578. * @returns A promise that resolves when the compilation completes
  74579. */
  74580. forceCompilationAsync(options?: Partial<{
  74581. useInstances: boolean;
  74582. }>): Promise<void>;
  74583. /**
  74584. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74585. * @param subMesh The submesh we want to render in the shadow map
  74586. * @param useInstances Defines wether will draw in the map using instances
  74587. * @returns true if ready otherwise, false
  74588. */
  74589. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74590. /**
  74591. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74592. * @param defines Defines of the material we want to update
  74593. * @param lightIndex Index of the light in the enabled light list of the material
  74594. */
  74595. prepareDefines(defines: any, lightIndex: number): void;
  74596. /**
  74597. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74598. * defined in the generator but impacting the effect).
  74599. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74600. * @param effect The effect we are binfing the information for
  74601. */
  74602. bindShadowLight(lightIndex: string, effect: Effect): void;
  74603. /**
  74604. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74605. * (eq to shadow prjection matrix * light transform matrix)
  74606. * @returns The transform matrix used to create the shadow map
  74607. */
  74608. getTransformMatrix(): Matrix;
  74609. /**
  74610. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74611. * Cube and 2D textures for instance.
  74612. */
  74613. recreateShadowMap(): void;
  74614. private _disposeBlurPostProcesses;
  74615. private _disposeRTTandPostProcesses;
  74616. /**
  74617. * Disposes the ShadowGenerator.
  74618. * Returns nothing.
  74619. */
  74620. dispose(): void;
  74621. /**
  74622. * Serializes the shadow generator setup to a json object.
  74623. * @returns The serialized JSON object
  74624. */
  74625. serialize(): any;
  74626. /**
  74627. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74628. * @param parsedShadowGenerator The JSON object to parse
  74629. * @param scene The scene to create the shadow map for
  74630. * @returns The parsed shadow generator
  74631. */
  74632. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74633. }
  74634. }
  74635. declare module BABYLON {
  74636. /**
  74637. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74638. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74639. * 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.
  74640. */
  74641. export abstract class Light extends Node {
  74642. /**
  74643. * Falloff Default: light is falling off following the material specification:
  74644. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74645. */
  74646. static readonly FALLOFF_DEFAULT: number;
  74647. /**
  74648. * Falloff Physical: light is falling off following the inverse squared distance law.
  74649. */
  74650. static readonly FALLOFF_PHYSICAL: number;
  74651. /**
  74652. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74653. * to enhance interoperability with other engines.
  74654. */
  74655. static readonly FALLOFF_GLTF: number;
  74656. /**
  74657. * Falloff Standard: light is falling off like in the standard material
  74658. * to enhance interoperability with other materials.
  74659. */
  74660. static readonly FALLOFF_STANDARD: number;
  74661. /**
  74662. * If every light affecting the material is in this lightmapMode,
  74663. * material.lightmapTexture adds or multiplies
  74664. * (depends on material.useLightmapAsShadowmap)
  74665. * after every other light calculations.
  74666. */
  74667. static readonly LIGHTMAP_DEFAULT: number;
  74668. /**
  74669. * material.lightmapTexture as only diffuse lighting from this light
  74670. * adds only specular lighting from this light
  74671. * adds dynamic shadows
  74672. */
  74673. static readonly LIGHTMAP_SPECULAR: number;
  74674. /**
  74675. * material.lightmapTexture as only lighting
  74676. * no light calculation from this light
  74677. * only adds dynamic shadows from this light
  74678. */
  74679. static readonly LIGHTMAP_SHADOWSONLY: number;
  74680. /**
  74681. * Each light type uses the default quantity according to its type:
  74682. * point/spot lights use luminous intensity
  74683. * directional lights use illuminance
  74684. */
  74685. static readonly INTENSITYMODE_AUTOMATIC: number;
  74686. /**
  74687. * lumen (lm)
  74688. */
  74689. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74690. /**
  74691. * candela (lm/sr)
  74692. */
  74693. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74694. /**
  74695. * lux (lm/m^2)
  74696. */
  74697. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74698. /**
  74699. * nit (cd/m^2)
  74700. */
  74701. static readonly INTENSITYMODE_LUMINANCE: number;
  74702. /**
  74703. * Light type const id of the point light.
  74704. */
  74705. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74706. /**
  74707. * Light type const id of the directional light.
  74708. */
  74709. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74710. /**
  74711. * Light type const id of the spot light.
  74712. */
  74713. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74714. /**
  74715. * Light type const id of the hemispheric light.
  74716. */
  74717. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74718. /**
  74719. * Diffuse gives the basic color to an object.
  74720. */
  74721. diffuse: Color3;
  74722. /**
  74723. * Specular produces a highlight color on an object.
  74724. * Note: This is note affecting PBR materials.
  74725. */
  74726. specular: Color3;
  74727. /**
  74728. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74729. * falling off base on range or angle.
  74730. * This can be set to any values in Light.FALLOFF_x.
  74731. *
  74732. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74733. * other types of materials.
  74734. */
  74735. falloffType: number;
  74736. /**
  74737. * Strength of the light.
  74738. * Note: By default it is define in the framework own unit.
  74739. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74740. */
  74741. intensity: number;
  74742. private _range;
  74743. protected _inverseSquaredRange: number;
  74744. /**
  74745. * Defines how far from the source the light is impacting in scene units.
  74746. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74747. */
  74748. /**
  74749. * Defines how far from the source the light is impacting in scene units.
  74750. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74751. */
  74752. range: number;
  74753. /**
  74754. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74755. * of light.
  74756. */
  74757. private _photometricScale;
  74758. private _intensityMode;
  74759. /**
  74760. * Gets the photometric scale used to interpret the intensity.
  74761. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74762. */
  74763. /**
  74764. * Sets the photometric scale used to interpret the intensity.
  74765. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74766. */
  74767. intensityMode: number;
  74768. private _radius;
  74769. /**
  74770. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74771. */
  74772. /**
  74773. * sets the light radius used by PBR Materials to simulate soft area lights.
  74774. */
  74775. radius: number;
  74776. private _renderPriority;
  74777. /**
  74778. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74779. * exceeding the number allowed of the materials.
  74780. */
  74781. renderPriority: number;
  74782. private _shadowEnabled;
  74783. /**
  74784. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74785. * the current shadow generator.
  74786. */
  74787. /**
  74788. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74789. * the current shadow generator.
  74790. */
  74791. shadowEnabled: boolean;
  74792. private _includedOnlyMeshes;
  74793. /**
  74794. * Gets the only meshes impacted by this light.
  74795. */
  74796. /**
  74797. * Sets the only meshes impacted by this light.
  74798. */
  74799. includedOnlyMeshes: AbstractMesh[];
  74800. private _excludedMeshes;
  74801. /**
  74802. * Gets the meshes not impacted by this light.
  74803. */
  74804. /**
  74805. * Sets the meshes not impacted by this light.
  74806. */
  74807. excludedMeshes: AbstractMesh[];
  74808. private _excludeWithLayerMask;
  74809. /**
  74810. * Gets the layer id use to find what meshes are not impacted by the light.
  74811. * Inactive if 0
  74812. */
  74813. /**
  74814. * Sets the layer id use to find what meshes are not impacted by the light.
  74815. * Inactive if 0
  74816. */
  74817. excludeWithLayerMask: number;
  74818. private _includeOnlyWithLayerMask;
  74819. /**
  74820. * Gets the layer id use to find what meshes are impacted by the light.
  74821. * Inactive if 0
  74822. */
  74823. /**
  74824. * Sets the layer id use to find what meshes are impacted by the light.
  74825. * Inactive if 0
  74826. */
  74827. includeOnlyWithLayerMask: number;
  74828. private _lightmapMode;
  74829. /**
  74830. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74831. */
  74832. /**
  74833. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74834. */
  74835. lightmapMode: number;
  74836. /**
  74837. * Shadow generator associted to the light.
  74838. * @hidden Internal use only.
  74839. */
  74840. _shadowGenerator: Nullable<IShadowGenerator>;
  74841. /**
  74842. * @hidden Internal use only.
  74843. */
  74844. _excludedMeshesIds: string[];
  74845. /**
  74846. * @hidden Internal use only.
  74847. */
  74848. _includedOnlyMeshesIds: string[];
  74849. /**
  74850. * The current light unifom buffer.
  74851. * @hidden Internal use only.
  74852. */
  74853. _uniformBuffer: UniformBuffer;
  74854. /**
  74855. * Creates a Light object in the scene.
  74856. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74857. * @param name The firendly name of the light
  74858. * @param scene The scene the light belongs too
  74859. */
  74860. constructor(name: string, scene: Scene);
  74861. protected abstract _buildUniformLayout(): void;
  74862. /**
  74863. * Sets the passed Effect "effect" with the Light information.
  74864. * @param effect The effect to update
  74865. * @param lightIndex The index of the light in the effect to update
  74866. * @returns The light
  74867. */
  74868. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74869. /**
  74870. * Returns the string "Light".
  74871. * @returns the class name
  74872. */
  74873. getClassName(): string;
  74874. /** @hidden */
  74875. readonly _isLight: boolean;
  74876. /**
  74877. * Converts the light information to a readable string for debug purpose.
  74878. * @param fullDetails Supports for multiple levels of logging within scene loading
  74879. * @returns the human readable light info
  74880. */
  74881. toString(fullDetails?: boolean): string;
  74882. /** @hidden */
  74883. protected _syncParentEnabledState(): void;
  74884. /**
  74885. * Set the enabled state of this node.
  74886. * @param value - the new enabled state
  74887. */
  74888. setEnabled(value: boolean): void;
  74889. /**
  74890. * Returns the Light associated shadow generator if any.
  74891. * @return the associated shadow generator.
  74892. */
  74893. getShadowGenerator(): Nullable<IShadowGenerator>;
  74894. /**
  74895. * Returns a Vector3, the absolute light position in the World.
  74896. * @returns the world space position of the light
  74897. */
  74898. getAbsolutePosition(): Vector3;
  74899. /**
  74900. * Specifies if the light will affect the passed mesh.
  74901. * @param mesh The mesh to test against the light
  74902. * @return true the mesh is affected otherwise, false.
  74903. */
  74904. canAffectMesh(mesh: AbstractMesh): boolean;
  74905. /**
  74906. * Sort function to order lights for rendering.
  74907. * @param a First Light object to compare to second.
  74908. * @param b Second Light object to compare first.
  74909. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74910. */
  74911. static CompareLightsPriority(a: Light, b: Light): number;
  74912. /**
  74913. * Releases resources associated with this node.
  74914. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74915. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74916. */
  74917. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74918. /**
  74919. * Returns the light type ID (integer).
  74920. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74921. */
  74922. getTypeID(): number;
  74923. /**
  74924. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74925. * @returns the scaled intensity in intensity mode unit
  74926. */
  74927. getScaledIntensity(): number;
  74928. /**
  74929. * Returns a new Light object, named "name", from the current one.
  74930. * @param name The name of the cloned light
  74931. * @returns the new created light
  74932. */
  74933. clone(name: string): Nullable<Light>;
  74934. /**
  74935. * Serializes the current light into a Serialization object.
  74936. * @returns the serialized object.
  74937. */
  74938. serialize(): any;
  74939. /**
  74940. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74941. * This new light is named "name" and added to the passed scene.
  74942. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74943. * @param name The friendly name of the light
  74944. * @param scene The scene the new light will belong to
  74945. * @returns the constructor function
  74946. */
  74947. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74948. /**
  74949. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74950. * @param parsedLight The JSON representation of the light
  74951. * @param scene The scene to create the parsed light in
  74952. * @returns the created light after parsing
  74953. */
  74954. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74955. private _hookArrayForExcluded;
  74956. private _hookArrayForIncludedOnly;
  74957. private _resyncMeshes;
  74958. /**
  74959. * Forces the meshes to update their light related information in their rendering used effects
  74960. * @hidden Internal Use Only
  74961. */
  74962. _markMeshesAsLightDirty(): void;
  74963. /**
  74964. * Recomputes the cached photometric scale if needed.
  74965. */
  74966. private _computePhotometricScale;
  74967. /**
  74968. * Returns the Photometric Scale according to the light type and intensity mode.
  74969. */
  74970. private _getPhotometricScale;
  74971. /**
  74972. * Reorder the light in the scene according to their defined priority.
  74973. * @hidden Internal Use Only
  74974. */
  74975. _reorderLightsInScene(): void;
  74976. /**
  74977. * Prepares the list of defines specific to the light type.
  74978. * @param defines the list of defines
  74979. * @param lightIndex defines the index of the light for the effect
  74980. */
  74981. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74982. }
  74983. }
  74984. declare module BABYLON {
  74985. /**
  74986. * Creates an instance based on a source mesh.
  74987. */
  74988. export class InstancedMesh extends AbstractMesh {
  74989. private _sourceMesh;
  74990. private _currentLOD;
  74991. /** @hidden */
  74992. _indexInSourceMeshInstanceArray: number;
  74993. constructor(name: string, source: Mesh);
  74994. /**
  74995. * Returns the string "InstancedMesh".
  74996. */
  74997. getClassName(): string;
  74998. /** Gets the list of lights affecting that mesh */
  74999. readonly lightSources: Light[];
  75000. _resyncLightSources(): void;
  75001. _resyncLighSource(light: Light): void;
  75002. _removeLightSource(light: Light): void;
  75003. /**
  75004. * If the source mesh receives shadows
  75005. */
  75006. readonly receiveShadows: boolean;
  75007. /**
  75008. * The material of the source mesh
  75009. */
  75010. readonly material: Nullable<Material>;
  75011. /**
  75012. * Visibility of the source mesh
  75013. */
  75014. readonly visibility: number;
  75015. /**
  75016. * Skeleton of the source mesh
  75017. */
  75018. readonly skeleton: Nullable<Skeleton>;
  75019. /**
  75020. * Rendering ground id of the source mesh
  75021. */
  75022. renderingGroupId: number;
  75023. /**
  75024. * Returns the total number of vertices (integer).
  75025. */
  75026. getTotalVertices(): number;
  75027. /**
  75028. * Returns a positive integer : the total number of indices in this mesh geometry.
  75029. * @returns the numner of indices or zero if the mesh has no geometry.
  75030. */
  75031. getTotalIndices(): number;
  75032. /**
  75033. * The source mesh of the instance
  75034. */
  75035. readonly sourceMesh: Mesh;
  75036. /**
  75037. * Is this node ready to be used/rendered
  75038. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75039. * @return {boolean} is it ready
  75040. */
  75041. isReady(completeCheck?: boolean): boolean;
  75042. /**
  75043. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75044. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75045. * @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.
  75046. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75047. */
  75048. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75049. /**
  75050. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75051. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75052. * The `data` are either a numeric array either a Float32Array.
  75053. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75054. * 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).
  75055. * Note that a new underlying VertexBuffer object is created each call.
  75056. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75057. *
  75058. * Possible `kind` values :
  75059. * - VertexBuffer.PositionKind
  75060. * - VertexBuffer.UVKind
  75061. * - VertexBuffer.UV2Kind
  75062. * - VertexBuffer.UV3Kind
  75063. * - VertexBuffer.UV4Kind
  75064. * - VertexBuffer.UV5Kind
  75065. * - VertexBuffer.UV6Kind
  75066. * - VertexBuffer.ColorKind
  75067. * - VertexBuffer.MatricesIndicesKind
  75068. * - VertexBuffer.MatricesIndicesExtraKind
  75069. * - VertexBuffer.MatricesWeightsKind
  75070. * - VertexBuffer.MatricesWeightsExtraKind
  75071. *
  75072. * Returns the Mesh.
  75073. */
  75074. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75075. /**
  75076. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75077. * If the mesh has no geometry, it is simply returned as it is.
  75078. * The `data` are either a numeric array either a Float32Array.
  75079. * No new underlying VertexBuffer object is created.
  75080. * 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.
  75081. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75082. *
  75083. * Possible `kind` values :
  75084. * - VertexBuffer.PositionKind
  75085. * - VertexBuffer.UVKind
  75086. * - VertexBuffer.UV2Kind
  75087. * - VertexBuffer.UV3Kind
  75088. * - VertexBuffer.UV4Kind
  75089. * - VertexBuffer.UV5Kind
  75090. * - VertexBuffer.UV6Kind
  75091. * - VertexBuffer.ColorKind
  75092. * - VertexBuffer.MatricesIndicesKind
  75093. * - VertexBuffer.MatricesIndicesExtraKind
  75094. * - VertexBuffer.MatricesWeightsKind
  75095. * - VertexBuffer.MatricesWeightsExtraKind
  75096. *
  75097. * Returns the Mesh.
  75098. */
  75099. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75100. /**
  75101. * Sets the mesh indices.
  75102. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75103. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75104. * This method creates a new index buffer each call.
  75105. * Returns the Mesh.
  75106. */
  75107. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75108. /**
  75109. * Boolean : True if the mesh owns the requested kind of data.
  75110. */
  75111. isVerticesDataPresent(kind: string): boolean;
  75112. /**
  75113. * Returns an array of indices (IndicesArray).
  75114. */
  75115. getIndices(): Nullable<IndicesArray>;
  75116. readonly _positions: Nullable<Vector3[]>;
  75117. /**
  75118. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75119. * This means the mesh underlying bounding box and sphere are recomputed.
  75120. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75121. * @returns the current mesh
  75122. */
  75123. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75124. /** @hidden */
  75125. _preActivate(): InstancedMesh;
  75126. /** @hidden */
  75127. _activate(renderId: number, intermediateRendering: boolean): boolean;
  75128. /** @hidden */
  75129. _postActivate(): void;
  75130. getWorldMatrix(): Matrix;
  75131. readonly isAnInstance: boolean;
  75132. /**
  75133. * Returns the current associated LOD AbstractMesh.
  75134. */
  75135. getLOD(camera: Camera): AbstractMesh;
  75136. /** @hidden */
  75137. _syncSubMeshes(): InstancedMesh;
  75138. /** @hidden */
  75139. _generatePointsArray(): boolean;
  75140. /**
  75141. * Creates a new InstancedMesh from the current mesh.
  75142. * - name (string) : the cloned mesh name
  75143. * - newParent (optional Node) : the optional Node to parent the clone to.
  75144. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75145. *
  75146. * Returns the clone.
  75147. */
  75148. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75149. /**
  75150. * Disposes the InstancedMesh.
  75151. * Returns nothing.
  75152. */
  75153. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75154. }
  75155. }
  75156. declare module BABYLON {
  75157. /**
  75158. * Defines the options associated with the creation of a shader material.
  75159. */
  75160. export interface IShaderMaterialOptions {
  75161. /**
  75162. * Does the material work in alpha blend mode
  75163. */
  75164. needAlphaBlending: boolean;
  75165. /**
  75166. * Does the material work in alpha test mode
  75167. */
  75168. needAlphaTesting: boolean;
  75169. /**
  75170. * The list of attribute names used in the shader
  75171. */
  75172. attributes: string[];
  75173. /**
  75174. * The list of unifrom names used in the shader
  75175. */
  75176. uniforms: string[];
  75177. /**
  75178. * The list of UBO names used in the shader
  75179. */
  75180. uniformBuffers: string[];
  75181. /**
  75182. * The list of sampler names used in the shader
  75183. */
  75184. samplers: string[];
  75185. /**
  75186. * The list of defines used in the shader
  75187. */
  75188. defines: string[];
  75189. }
  75190. /**
  75191. * 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.
  75192. *
  75193. * This returned material effects how the mesh will look based on the code in the shaders.
  75194. *
  75195. * @see http://doc.babylonjs.com/how_to/shader_material
  75196. */
  75197. export class ShaderMaterial extends Material {
  75198. private _shaderPath;
  75199. private _options;
  75200. private _textures;
  75201. private _textureArrays;
  75202. private _floats;
  75203. private _ints;
  75204. private _floatsArrays;
  75205. private _colors3;
  75206. private _colors3Arrays;
  75207. private _colors4;
  75208. private _colors4Arrays;
  75209. private _vectors2;
  75210. private _vectors3;
  75211. private _vectors4;
  75212. private _matrices;
  75213. private _matrices3x3;
  75214. private _matrices2x2;
  75215. private _vectors2Arrays;
  75216. private _vectors3Arrays;
  75217. private _vectors4Arrays;
  75218. private _cachedWorldViewMatrix;
  75219. private _cachedWorldViewProjectionMatrix;
  75220. private _renderId;
  75221. /**
  75222. * Instantiate a new shader material.
  75223. * 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.
  75224. * This returned material effects how the mesh will look based on the code in the shaders.
  75225. * @see http://doc.babylonjs.com/how_to/shader_material
  75226. * @param name Define the name of the material in the scene
  75227. * @param scene Define the scene the material belongs to
  75228. * @param shaderPath Defines the route to the shader code in one of three ways:
  75229. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75230. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75231. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75232. * @param options Define the options used to create the shader
  75233. */
  75234. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75235. /**
  75236. * Gets the options used to compile the shader.
  75237. * They can be modified to trigger a new compilation
  75238. */
  75239. readonly options: IShaderMaterialOptions;
  75240. /**
  75241. * Gets the current class name of the material e.g. "ShaderMaterial"
  75242. * Mainly use in serialization.
  75243. * @returns the class name
  75244. */
  75245. getClassName(): string;
  75246. /**
  75247. * Specifies if the material will require alpha blending
  75248. * @returns a boolean specifying if alpha blending is needed
  75249. */
  75250. needAlphaBlending(): boolean;
  75251. /**
  75252. * Specifies if this material should be rendered in alpha test mode
  75253. * @returns a boolean specifying if an alpha test is needed.
  75254. */
  75255. needAlphaTesting(): boolean;
  75256. private _checkUniform;
  75257. /**
  75258. * Set a texture in the shader.
  75259. * @param name Define the name of the uniform samplers as defined in the shader
  75260. * @param texture Define the texture to bind to this sampler
  75261. * @return the material itself allowing "fluent" like uniform updates
  75262. */
  75263. setTexture(name: string, texture: Texture): ShaderMaterial;
  75264. /**
  75265. * Set a texture array in the shader.
  75266. * @param name Define the name of the uniform sampler array as defined in the shader
  75267. * @param textures Define the list of textures to bind to this sampler
  75268. * @return the material itself allowing "fluent" like uniform updates
  75269. */
  75270. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75271. /**
  75272. * Set a float in the shader.
  75273. * @param name Define the name of the uniform as defined in the shader
  75274. * @param value Define the value to give to the uniform
  75275. * @return the material itself allowing "fluent" like uniform updates
  75276. */
  75277. setFloat(name: string, value: number): ShaderMaterial;
  75278. /**
  75279. * Set a int in the shader.
  75280. * @param name Define the name of the uniform as defined in the shader
  75281. * @param value Define the value to give to the uniform
  75282. * @return the material itself allowing "fluent" like uniform updates
  75283. */
  75284. setInt(name: string, value: number): ShaderMaterial;
  75285. /**
  75286. * Set an array of floats in the shader.
  75287. * @param name Define the name of the uniform as defined in the shader
  75288. * @param value Define the value to give to the uniform
  75289. * @return the material itself allowing "fluent" like uniform updates
  75290. */
  75291. setFloats(name: string, value: number[]): ShaderMaterial;
  75292. /**
  75293. * Set a vec3 in the shader from a Color3.
  75294. * @param name Define the name of the uniform as defined in the shader
  75295. * @param value Define the value to give to the uniform
  75296. * @return the material itself allowing "fluent" like uniform updates
  75297. */
  75298. setColor3(name: string, value: Color3): ShaderMaterial;
  75299. /**
  75300. * Set a vec3 array in the shader from a Color3 array.
  75301. * @param name Define the name of the uniform as defined in the shader
  75302. * @param value Define the value to give to the uniform
  75303. * @return the material itself allowing "fluent" like uniform updates
  75304. */
  75305. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75306. /**
  75307. * Set a vec4 in the shader from a Color4.
  75308. * @param name Define the name of the uniform as defined in the shader
  75309. * @param value Define the value to give to the uniform
  75310. * @return the material itself allowing "fluent" like uniform updates
  75311. */
  75312. setColor4(name: string, value: Color4): ShaderMaterial;
  75313. /**
  75314. * Set a vec4 array in the shader from a Color4 array.
  75315. * @param name Define the name of the uniform as defined in the shader
  75316. * @param value Define the value to give to the uniform
  75317. * @return the material itself allowing "fluent" like uniform updates
  75318. */
  75319. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  75320. /**
  75321. * Set a vec2 in the shader from a Vector2.
  75322. * @param name Define the name of the uniform as defined in the shader
  75323. * @param value Define the value to give to the uniform
  75324. * @return the material itself allowing "fluent" like uniform updates
  75325. */
  75326. setVector2(name: string, value: Vector2): ShaderMaterial;
  75327. /**
  75328. * Set a vec3 in the shader from a Vector3.
  75329. * @param name Define the name of the uniform as defined in the shader
  75330. * @param value Define the value to give to the uniform
  75331. * @return the material itself allowing "fluent" like uniform updates
  75332. */
  75333. setVector3(name: string, value: Vector3): ShaderMaterial;
  75334. /**
  75335. * Set a vec4 in the shader from a Vector4.
  75336. * @param name Define the name of the uniform as defined in the shader
  75337. * @param value Define the value to give to the uniform
  75338. * @return the material itself allowing "fluent" like uniform updates
  75339. */
  75340. setVector4(name: string, value: Vector4): ShaderMaterial;
  75341. /**
  75342. * Set a mat4 in the shader from a Matrix.
  75343. * @param name Define the name of the uniform as defined in the shader
  75344. * @param value Define the value to give to the uniform
  75345. * @return the material itself allowing "fluent" like uniform updates
  75346. */
  75347. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75348. /**
  75349. * Set a mat3 in the shader from a Float32Array.
  75350. * @param name Define the name of the uniform as defined in the shader
  75351. * @param value Define the value to give to the uniform
  75352. * @return the material itself allowing "fluent" like uniform updates
  75353. */
  75354. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75355. /**
  75356. * Set a mat2 in the shader from a Float32Array.
  75357. * @param name Define the name of the uniform as defined in the shader
  75358. * @param value Define the value to give to the uniform
  75359. * @return the material itself allowing "fluent" like uniform updates
  75360. */
  75361. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75362. /**
  75363. * Set a vec2 array in the shader from a number array.
  75364. * @param name Define the name of the uniform as defined in the shader
  75365. * @param value Define the value to give to the uniform
  75366. * @return the material itself allowing "fluent" like uniform updates
  75367. */
  75368. setArray2(name: string, value: number[]): ShaderMaterial;
  75369. /**
  75370. * Set a vec3 array in the shader from a number array.
  75371. * @param name Define the name of the uniform as defined in the shader
  75372. * @param value Define the value to give to the uniform
  75373. * @return the material itself allowing "fluent" like uniform updates
  75374. */
  75375. setArray3(name: string, value: number[]): ShaderMaterial;
  75376. /**
  75377. * Set a vec4 array in the shader from a number array.
  75378. * @param name Define the name of the uniform as defined in the shader
  75379. * @param value Define the value to give to the uniform
  75380. * @return the material itself allowing "fluent" like uniform updates
  75381. */
  75382. setArray4(name: string, value: number[]): ShaderMaterial;
  75383. private _checkCache;
  75384. /**
  75385. * Specifies that the submesh is ready to be used
  75386. * @param mesh defines the mesh to check
  75387. * @param subMesh defines which submesh to check
  75388. * @param useInstances specifies that instances should be used
  75389. * @returns a boolean indicating that the submesh is ready or not
  75390. */
  75391. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75392. /**
  75393. * Checks if the material is ready to render the requested mesh
  75394. * @param mesh Define the mesh to render
  75395. * @param useInstances Define whether or not the material is used with instances
  75396. * @returns true if ready, otherwise false
  75397. */
  75398. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75399. /**
  75400. * Binds the world matrix to the material
  75401. * @param world defines the world transformation matrix
  75402. */
  75403. bindOnlyWorldMatrix(world: Matrix): void;
  75404. /**
  75405. * Binds the material to the mesh
  75406. * @param world defines the world transformation matrix
  75407. * @param mesh defines the mesh to bind the material to
  75408. */
  75409. bind(world: Matrix, mesh?: Mesh): void;
  75410. /**
  75411. * Gets the active textures from the material
  75412. * @returns an array of textures
  75413. */
  75414. getActiveTextures(): BaseTexture[];
  75415. /**
  75416. * Specifies if the material uses a texture
  75417. * @param texture defines the texture to check against the material
  75418. * @returns a boolean specifying if the material uses the texture
  75419. */
  75420. hasTexture(texture: BaseTexture): boolean;
  75421. /**
  75422. * Makes a duplicate of the material, and gives it a new name
  75423. * @param name defines the new name for the duplicated material
  75424. * @returns the cloned material
  75425. */
  75426. clone(name: string): ShaderMaterial;
  75427. /**
  75428. * Disposes the material
  75429. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75430. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75431. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75432. */
  75433. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75434. /**
  75435. * Serializes this material in a JSON representation
  75436. * @returns the serialized material object
  75437. */
  75438. serialize(): any;
  75439. /**
  75440. * Creates a shader material from parsed shader material data
  75441. * @param source defines the JSON represnetation of the material
  75442. * @param scene defines the hosting scene
  75443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75444. * @returns a new material
  75445. */
  75446. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75447. }
  75448. }
  75449. declare module BABYLON {
  75450. /** @hidden */
  75451. export var clipPlaneFragmentDeclaration: {
  75452. name: string;
  75453. shader: string;
  75454. };
  75455. }
  75456. declare module BABYLON {
  75457. /** @hidden */
  75458. export var clipPlaneFragment: {
  75459. name: string;
  75460. shader: string;
  75461. };
  75462. }
  75463. declare module BABYLON {
  75464. /** @hidden */
  75465. export var colorPixelShader: {
  75466. name: string;
  75467. shader: string;
  75468. };
  75469. }
  75470. declare module BABYLON {
  75471. /** @hidden */
  75472. export var clipPlaneVertexDeclaration: {
  75473. name: string;
  75474. shader: string;
  75475. };
  75476. }
  75477. declare module BABYLON {
  75478. /** @hidden */
  75479. export var clipPlaneVertex: {
  75480. name: string;
  75481. shader: string;
  75482. };
  75483. }
  75484. declare module BABYLON {
  75485. /** @hidden */
  75486. export var colorVertexShader: {
  75487. name: string;
  75488. shader: string;
  75489. };
  75490. }
  75491. declare module BABYLON {
  75492. /**
  75493. * Line mesh
  75494. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75495. */
  75496. export class LinesMesh extends Mesh {
  75497. /**
  75498. * If vertex color should be applied to the mesh
  75499. */
  75500. readonly useVertexColor?: boolean | undefined;
  75501. /**
  75502. * If vertex alpha should be applied to the mesh
  75503. */
  75504. readonly useVertexAlpha?: boolean | undefined;
  75505. /**
  75506. * Color of the line (Default: White)
  75507. */
  75508. color: Color3;
  75509. /**
  75510. * Alpha of the line (Default: 1)
  75511. */
  75512. alpha: number;
  75513. /**
  75514. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75515. * This margin is expressed in world space coordinates, so its value may vary.
  75516. * Default value is 0.1
  75517. */
  75518. intersectionThreshold: number;
  75519. private _colorShader;
  75520. private color4;
  75521. /**
  75522. * Creates a new LinesMesh
  75523. * @param name defines the name
  75524. * @param scene defines the hosting scene
  75525. * @param parent defines the parent mesh if any
  75526. * @param source defines the optional source LinesMesh used to clone data from
  75527. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75528. * When false, achieved by calling a clone(), also passing False.
  75529. * This will make creation of children, recursive.
  75530. * @param useVertexColor defines if this LinesMesh supports vertex color
  75531. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75532. */
  75533. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75534. /**
  75535. * If vertex color should be applied to the mesh
  75536. */
  75537. useVertexColor?: boolean | undefined,
  75538. /**
  75539. * If vertex alpha should be applied to the mesh
  75540. */
  75541. useVertexAlpha?: boolean | undefined);
  75542. private _addClipPlaneDefine;
  75543. private _removeClipPlaneDefine;
  75544. isReady(): boolean;
  75545. /**
  75546. * Returns the string "LineMesh"
  75547. */
  75548. getClassName(): string;
  75549. /**
  75550. * @hidden
  75551. */
  75552. /**
  75553. * @hidden
  75554. */
  75555. material: Material;
  75556. /**
  75557. * @hidden
  75558. */
  75559. readonly checkCollisions: boolean;
  75560. /** @hidden */
  75561. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75562. /** @hidden */
  75563. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75564. /**
  75565. * Disposes of the line mesh
  75566. * @param doNotRecurse If children should be disposed
  75567. */
  75568. dispose(doNotRecurse?: boolean): void;
  75569. /**
  75570. * Returns a new LineMesh object cloned from the current one.
  75571. */
  75572. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75573. /**
  75574. * Creates a new InstancedLinesMesh object from the mesh model.
  75575. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75576. * @param name defines the name of the new instance
  75577. * @returns a new InstancedLinesMesh
  75578. */
  75579. createInstance(name: string): InstancedLinesMesh;
  75580. }
  75581. /**
  75582. * Creates an instance based on a source LinesMesh
  75583. */
  75584. export class InstancedLinesMesh extends InstancedMesh {
  75585. /**
  75586. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75587. * This margin is expressed in world space coordinates, so its value may vary.
  75588. * Initilized with the intersectionThreshold value of the source LinesMesh
  75589. */
  75590. intersectionThreshold: number;
  75591. constructor(name: string, source: LinesMesh);
  75592. /**
  75593. * Returns the string "InstancedLinesMesh".
  75594. */
  75595. getClassName(): string;
  75596. }
  75597. }
  75598. declare module BABYLON {
  75599. /**
  75600. * Mesh representing the gorund
  75601. */
  75602. export class GroundMesh extends Mesh {
  75603. /** If octree should be generated */
  75604. generateOctree: boolean;
  75605. private _heightQuads;
  75606. /** @hidden */
  75607. _subdivisionsX: number;
  75608. /** @hidden */
  75609. _subdivisionsY: number;
  75610. /** @hidden */
  75611. _width: number;
  75612. /** @hidden */
  75613. _height: number;
  75614. /** @hidden */
  75615. _minX: number;
  75616. /** @hidden */
  75617. _maxX: number;
  75618. /** @hidden */
  75619. _minZ: number;
  75620. /** @hidden */
  75621. _maxZ: number;
  75622. constructor(name: string, scene: Scene);
  75623. /**
  75624. * "GroundMesh"
  75625. * @returns "GroundMesh"
  75626. */
  75627. getClassName(): string;
  75628. /**
  75629. * The minimum of x and y subdivisions
  75630. */
  75631. readonly subdivisions: number;
  75632. /**
  75633. * X subdivisions
  75634. */
  75635. readonly subdivisionsX: number;
  75636. /**
  75637. * Y subdivisions
  75638. */
  75639. readonly subdivisionsY: number;
  75640. /**
  75641. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75642. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75643. * @param chunksCount the number of subdivisions for x and y
  75644. * @param octreeBlocksSize (Default: 32)
  75645. */
  75646. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75647. /**
  75648. * Returns a height (y) value in the Worl system :
  75649. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75650. * @param x x coordinate
  75651. * @param z z coordinate
  75652. * @returns the ground y position if (x, z) are outside the ground surface.
  75653. */
  75654. getHeightAtCoordinates(x: number, z: number): number;
  75655. /**
  75656. * Returns a normalized vector (Vector3) orthogonal to the ground
  75657. * at the ground coordinates (x, z) expressed in the World system.
  75658. * @param x x coordinate
  75659. * @param z z coordinate
  75660. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75661. */
  75662. getNormalAtCoordinates(x: number, z: number): Vector3;
  75663. /**
  75664. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75665. * at the ground coordinates (x, z) expressed in the World system.
  75666. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75667. * @param x x coordinate
  75668. * @param z z coordinate
  75669. * @param ref vector to store the result
  75670. * @returns the GroundMesh.
  75671. */
  75672. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75673. /**
  75674. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75675. * if the ground has been updated.
  75676. * This can be used in the render loop.
  75677. * @returns the GroundMesh.
  75678. */
  75679. updateCoordinateHeights(): GroundMesh;
  75680. private _getFacetAt;
  75681. private _initHeightQuads;
  75682. private _computeHeightQuads;
  75683. /**
  75684. * Serializes this ground mesh
  75685. * @param serializationObject object to write serialization to
  75686. */
  75687. serialize(serializationObject: any): void;
  75688. /**
  75689. * Parses a serialized ground mesh
  75690. * @param parsedMesh the serialized mesh
  75691. * @param scene the scene to create the ground mesh in
  75692. * @returns the created ground mesh
  75693. */
  75694. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75695. }
  75696. }
  75697. declare module BABYLON {
  75698. /**
  75699. * Interface for Physics-Joint data
  75700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75701. */
  75702. export interface PhysicsJointData {
  75703. /**
  75704. * The main pivot of the joint
  75705. */
  75706. mainPivot?: Vector3;
  75707. /**
  75708. * The connected pivot of the joint
  75709. */
  75710. connectedPivot?: Vector3;
  75711. /**
  75712. * The main axis of the joint
  75713. */
  75714. mainAxis?: Vector3;
  75715. /**
  75716. * The connected axis of the joint
  75717. */
  75718. connectedAxis?: Vector3;
  75719. /**
  75720. * The collision of the joint
  75721. */
  75722. collision?: boolean;
  75723. /**
  75724. * Native Oimo/Cannon/Energy data
  75725. */
  75726. nativeParams?: any;
  75727. }
  75728. /**
  75729. * This is a holder class for the physics joint created by the physics plugin
  75730. * It holds a set of functions to control the underlying joint
  75731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75732. */
  75733. export class PhysicsJoint {
  75734. /**
  75735. * The type of the physics joint
  75736. */
  75737. type: number;
  75738. /**
  75739. * The data for the physics joint
  75740. */
  75741. jointData: PhysicsJointData;
  75742. private _physicsJoint;
  75743. protected _physicsPlugin: IPhysicsEnginePlugin;
  75744. /**
  75745. * Initializes the physics joint
  75746. * @param type The type of the physics joint
  75747. * @param jointData The data for the physics joint
  75748. */
  75749. constructor(
  75750. /**
  75751. * The type of the physics joint
  75752. */
  75753. type: number,
  75754. /**
  75755. * The data for the physics joint
  75756. */
  75757. jointData: PhysicsJointData);
  75758. /**
  75759. * Gets the physics joint
  75760. */
  75761. /**
  75762. * Sets the physics joint
  75763. */
  75764. physicsJoint: any;
  75765. /**
  75766. * Sets the physics plugin
  75767. */
  75768. physicsPlugin: IPhysicsEnginePlugin;
  75769. /**
  75770. * Execute a function that is physics-plugin specific.
  75771. * @param {Function} func the function that will be executed.
  75772. * It accepts two parameters: the physics world and the physics joint
  75773. */
  75774. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75775. /**
  75776. * Distance-Joint type
  75777. */
  75778. static DistanceJoint: number;
  75779. /**
  75780. * Hinge-Joint type
  75781. */
  75782. static HingeJoint: number;
  75783. /**
  75784. * Ball-and-Socket joint type
  75785. */
  75786. static BallAndSocketJoint: number;
  75787. /**
  75788. * Wheel-Joint type
  75789. */
  75790. static WheelJoint: number;
  75791. /**
  75792. * Slider-Joint type
  75793. */
  75794. static SliderJoint: number;
  75795. /**
  75796. * Prismatic-Joint type
  75797. */
  75798. static PrismaticJoint: number;
  75799. /**
  75800. * Universal-Joint type
  75801. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75802. */
  75803. static UniversalJoint: number;
  75804. /**
  75805. * Hinge-Joint 2 type
  75806. */
  75807. static Hinge2Joint: number;
  75808. /**
  75809. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75810. */
  75811. static PointToPointJoint: number;
  75812. /**
  75813. * Spring-Joint type
  75814. */
  75815. static SpringJoint: number;
  75816. /**
  75817. * Lock-Joint type
  75818. */
  75819. static LockJoint: number;
  75820. }
  75821. /**
  75822. * A class representing a physics distance joint
  75823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75824. */
  75825. export class DistanceJoint extends PhysicsJoint {
  75826. /**
  75827. *
  75828. * @param jointData The data for the Distance-Joint
  75829. */
  75830. constructor(jointData: DistanceJointData);
  75831. /**
  75832. * Update the predefined distance.
  75833. * @param maxDistance The maximum preferred distance
  75834. * @param minDistance The minimum preferred distance
  75835. */
  75836. updateDistance(maxDistance: number, minDistance?: number): void;
  75837. }
  75838. /**
  75839. * Represents a Motor-Enabled Joint
  75840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75841. */
  75842. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75843. /**
  75844. * Initializes the Motor-Enabled Joint
  75845. * @param type The type of the joint
  75846. * @param jointData The physica joint data for the joint
  75847. */
  75848. constructor(type: number, jointData: PhysicsJointData);
  75849. /**
  75850. * Set the motor values.
  75851. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75852. * @param force the force to apply
  75853. * @param maxForce max force for this motor.
  75854. */
  75855. setMotor(force?: number, maxForce?: number): void;
  75856. /**
  75857. * Set the motor's limits.
  75858. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75859. * @param upperLimit The upper limit of the motor
  75860. * @param lowerLimit The lower limit of the motor
  75861. */
  75862. setLimit(upperLimit: number, lowerLimit?: number): void;
  75863. }
  75864. /**
  75865. * This class represents a single physics Hinge-Joint
  75866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75867. */
  75868. export class HingeJoint extends MotorEnabledJoint {
  75869. /**
  75870. * Initializes the Hinge-Joint
  75871. * @param jointData The joint data for the Hinge-Joint
  75872. */
  75873. constructor(jointData: PhysicsJointData);
  75874. /**
  75875. * Set the motor values.
  75876. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75877. * @param {number} force the force to apply
  75878. * @param {number} maxForce max force for this motor.
  75879. */
  75880. setMotor(force?: number, maxForce?: number): void;
  75881. /**
  75882. * Set the motor's limits.
  75883. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75884. * @param upperLimit The upper limit of the motor
  75885. * @param lowerLimit The lower limit of the motor
  75886. */
  75887. setLimit(upperLimit: number, lowerLimit?: number): void;
  75888. }
  75889. /**
  75890. * This class represents a dual hinge physics joint (same as wheel joint)
  75891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75892. */
  75893. export class Hinge2Joint extends MotorEnabledJoint {
  75894. /**
  75895. * Initializes the Hinge2-Joint
  75896. * @param jointData The joint data for the Hinge2-Joint
  75897. */
  75898. constructor(jointData: PhysicsJointData);
  75899. /**
  75900. * Set the motor values.
  75901. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75902. * @param {number} targetSpeed the speed the motor is to reach
  75903. * @param {number} maxForce max force for this motor.
  75904. * @param {motorIndex} the motor's index, 0 or 1.
  75905. */
  75906. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75907. /**
  75908. * Set the motor limits.
  75909. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75910. * @param {number} upperLimit the upper limit
  75911. * @param {number} lowerLimit lower limit
  75912. * @param {motorIndex} the motor's index, 0 or 1.
  75913. */
  75914. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75915. }
  75916. /**
  75917. * Interface for a motor enabled joint
  75918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75919. */
  75920. export interface IMotorEnabledJoint {
  75921. /**
  75922. * Physics joint
  75923. */
  75924. physicsJoint: any;
  75925. /**
  75926. * Sets the motor of the motor-enabled joint
  75927. * @param force The force of the motor
  75928. * @param maxForce The maximum force of the motor
  75929. * @param motorIndex The index of the motor
  75930. */
  75931. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75932. /**
  75933. * Sets the limit of the motor
  75934. * @param upperLimit The upper limit of the motor
  75935. * @param lowerLimit The lower limit of the motor
  75936. * @param motorIndex The index of the motor
  75937. */
  75938. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75939. }
  75940. /**
  75941. * Joint data for a Distance-Joint
  75942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75943. */
  75944. export interface DistanceJointData extends PhysicsJointData {
  75945. /**
  75946. * Max distance the 2 joint objects can be apart
  75947. */
  75948. maxDistance: number;
  75949. }
  75950. /**
  75951. * Joint data from a spring joint
  75952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75953. */
  75954. export interface SpringJointData extends PhysicsJointData {
  75955. /**
  75956. * Length of the spring
  75957. */
  75958. length: number;
  75959. /**
  75960. * Stiffness of the spring
  75961. */
  75962. stiffness: number;
  75963. /**
  75964. * Damping of the spring
  75965. */
  75966. damping: number;
  75967. /** this callback will be called when applying the force to the impostors. */
  75968. forceApplicationCallback: () => void;
  75969. }
  75970. }
  75971. declare module BABYLON {
  75972. /**
  75973. * Holds the data for the raycast result
  75974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75975. */
  75976. export class PhysicsRaycastResult {
  75977. private _hasHit;
  75978. private _hitDistance;
  75979. private _hitNormalWorld;
  75980. private _hitPointWorld;
  75981. private _rayFromWorld;
  75982. private _rayToWorld;
  75983. /**
  75984. * Gets if there was a hit
  75985. */
  75986. readonly hasHit: boolean;
  75987. /**
  75988. * Gets the distance from the hit
  75989. */
  75990. readonly hitDistance: number;
  75991. /**
  75992. * Gets the hit normal/direction in the world
  75993. */
  75994. readonly hitNormalWorld: Vector3;
  75995. /**
  75996. * Gets the hit point in the world
  75997. */
  75998. readonly hitPointWorld: Vector3;
  75999. /**
  76000. * Gets the ray "start point" of the ray in the world
  76001. */
  76002. readonly rayFromWorld: Vector3;
  76003. /**
  76004. * Gets the ray "end point" of the ray in the world
  76005. */
  76006. readonly rayToWorld: Vector3;
  76007. /**
  76008. * Sets the hit data (normal & point in world space)
  76009. * @param hitNormalWorld defines the normal in world space
  76010. * @param hitPointWorld defines the point in world space
  76011. */
  76012. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  76013. /**
  76014. * Sets the distance from the start point to the hit point
  76015. * @param distance
  76016. */
  76017. setHitDistance(distance: number): void;
  76018. /**
  76019. * Calculates the distance manually
  76020. */
  76021. calculateHitDistance(): void;
  76022. /**
  76023. * Resets all the values to default
  76024. * @param from The from point on world space
  76025. * @param to The to point on world space
  76026. */
  76027. reset(from?: Vector3, to?: Vector3): void;
  76028. }
  76029. /**
  76030. * Interface for the size containing width and height
  76031. */
  76032. interface IXYZ {
  76033. /**
  76034. * X
  76035. */
  76036. x: number;
  76037. /**
  76038. * Y
  76039. */
  76040. y: number;
  76041. /**
  76042. * Z
  76043. */
  76044. z: number;
  76045. }
  76046. }
  76047. declare module BABYLON {
  76048. /**
  76049. * Interface used to describe a physics joint
  76050. */
  76051. export interface PhysicsImpostorJoint {
  76052. /** Defines the main impostor to which the joint is linked */
  76053. mainImpostor: PhysicsImpostor;
  76054. /** Defines the impostor that is connected to the main impostor using this joint */
  76055. connectedImpostor: PhysicsImpostor;
  76056. /** Defines the joint itself */
  76057. joint: PhysicsJoint;
  76058. }
  76059. /** @hidden */
  76060. export interface IPhysicsEnginePlugin {
  76061. world: any;
  76062. name: string;
  76063. setGravity(gravity: Vector3): void;
  76064. setTimeStep(timeStep: number): void;
  76065. getTimeStep(): number;
  76066. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76067. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76068. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76069. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76070. removePhysicsBody(impostor: PhysicsImpostor): void;
  76071. generateJoint(joint: PhysicsImpostorJoint): void;
  76072. removeJoint(joint: PhysicsImpostorJoint): void;
  76073. isSupported(): boolean;
  76074. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76075. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76076. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76077. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76078. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76079. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76080. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76081. getBodyMass(impostor: PhysicsImpostor): number;
  76082. getBodyFriction(impostor: PhysicsImpostor): number;
  76083. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76084. getBodyRestitution(impostor: PhysicsImpostor): number;
  76085. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76086. getBodyPressure?(impostor: PhysicsImpostor): number;
  76087. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  76088. getBodyStiffness?(impostor: PhysicsImpostor): number;
  76089. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  76090. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  76091. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  76092. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  76093. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  76094. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76095. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76096. sleepBody(impostor: PhysicsImpostor): void;
  76097. wakeUpBody(impostor: PhysicsImpostor): void;
  76098. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76099. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76100. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76101. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76102. getRadius(impostor: PhysicsImpostor): number;
  76103. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76104. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76105. dispose(): void;
  76106. }
  76107. /**
  76108. * Interface used to define a physics engine
  76109. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76110. */
  76111. export interface IPhysicsEngine {
  76112. /**
  76113. * Gets the gravity vector used by the simulation
  76114. */
  76115. gravity: Vector3;
  76116. /**
  76117. * Sets the gravity vector used by the simulation
  76118. * @param gravity defines the gravity vector to use
  76119. */
  76120. setGravity(gravity: Vector3): void;
  76121. /**
  76122. * Set the time step of the physics engine.
  76123. * Default is 1/60.
  76124. * To slow it down, enter 1/600 for example.
  76125. * To speed it up, 1/30
  76126. * @param newTimeStep the new timestep to apply to this world.
  76127. */
  76128. setTimeStep(newTimeStep: number): void;
  76129. /**
  76130. * Get the time step of the physics engine.
  76131. * @returns the current time step
  76132. */
  76133. getTimeStep(): number;
  76134. /**
  76135. * Release all resources
  76136. */
  76137. dispose(): void;
  76138. /**
  76139. * Gets the name of the current physics plugin
  76140. * @returns the name of the plugin
  76141. */
  76142. getPhysicsPluginName(): string;
  76143. /**
  76144. * Adding a new impostor for the impostor tracking.
  76145. * This will be done by the impostor itself.
  76146. * @param impostor the impostor to add
  76147. */
  76148. addImpostor(impostor: PhysicsImpostor): void;
  76149. /**
  76150. * Remove an impostor from the engine.
  76151. * This impostor and its mesh will not longer be updated by the physics engine.
  76152. * @param impostor the impostor to remove
  76153. */
  76154. removeImpostor(impostor: PhysicsImpostor): void;
  76155. /**
  76156. * Add a joint to the physics engine
  76157. * @param mainImpostor defines the main impostor to which the joint is added.
  76158. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76159. * @param joint defines the joint that will connect both impostors.
  76160. */
  76161. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76162. /**
  76163. * Removes a joint from the simulation
  76164. * @param mainImpostor defines the impostor used with the joint
  76165. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76166. * @param joint defines the joint to remove
  76167. */
  76168. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76169. /**
  76170. * Gets the current plugin used to run the simulation
  76171. * @returns current plugin
  76172. */
  76173. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76174. /**
  76175. * Gets the list of physic impostors
  76176. * @returns an array of PhysicsImpostor
  76177. */
  76178. getImpostors(): Array<PhysicsImpostor>;
  76179. /**
  76180. * Gets the impostor for a physics enabled object
  76181. * @param object defines the object impersonated by the impostor
  76182. * @returns the PhysicsImpostor or null if not found
  76183. */
  76184. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76185. /**
  76186. * Gets the impostor for a physics body object
  76187. * @param body defines physics body used by the impostor
  76188. * @returns the PhysicsImpostor or null if not found
  76189. */
  76190. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76191. /**
  76192. * Does a raycast in the physics world
  76193. * @param from when should the ray start?
  76194. * @param to when should the ray end?
  76195. * @returns PhysicsRaycastResult
  76196. */
  76197. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76198. /**
  76199. * Called by the scene. No need to call it.
  76200. * @param delta defines the timespam between frames
  76201. */
  76202. _step(delta: number): void;
  76203. }
  76204. }
  76205. declare module BABYLON {
  76206. /**
  76207. * The interface for the physics imposter parameters
  76208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76209. */
  76210. export interface PhysicsImpostorParameters {
  76211. /**
  76212. * The mass of the physics imposter
  76213. */
  76214. mass: number;
  76215. /**
  76216. * The friction of the physics imposter
  76217. */
  76218. friction?: number;
  76219. /**
  76220. * The coefficient of restitution of the physics imposter
  76221. */
  76222. restitution?: number;
  76223. /**
  76224. * The native options of the physics imposter
  76225. */
  76226. nativeOptions?: any;
  76227. /**
  76228. * Specifies if the parent should be ignored
  76229. */
  76230. ignoreParent?: boolean;
  76231. /**
  76232. * Specifies if bi-directional transformations should be disabled
  76233. */
  76234. disableBidirectionalTransformation?: boolean;
  76235. /**
  76236. * The pressure inside the physics imposter, soft object only
  76237. */
  76238. pressure?: number;
  76239. /**
  76240. * The stiffness the physics imposter, soft object only
  76241. */
  76242. stiffness?: number;
  76243. /**
  76244. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  76245. */
  76246. velocityIterations?: number;
  76247. /**
  76248. * The number of iterations used in maintaining consistent vertex positions, soft object only
  76249. */
  76250. positionIterations?: number;
  76251. /**
  76252. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  76253. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  76254. * Add to fix multiple points
  76255. */
  76256. fixedPoints?: number;
  76257. /**
  76258. * The collision margin around a soft object
  76259. */
  76260. margin?: number;
  76261. /**
  76262. * The collision margin around a soft object
  76263. */
  76264. damping?: number;
  76265. /**
  76266. * The path for a rope based on an extrusion
  76267. */
  76268. path?: any;
  76269. /**
  76270. * The shape of an extrusion used for a rope based on an extrusion
  76271. */
  76272. shape?: any;
  76273. }
  76274. /**
  76275. * Interface for a physics-enabled object
  76276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76277. */
  76278. export interface IPhysicsEnabledObject {
  76279. /**
  76280. * The position of the physics-enabled object
  76281. */
  76282. position: Vector3;
  76283. /**
  76284. * The rotation of the physics-enabled object
  76285. */
  76286. rotationQuaternion: Nullable<Quaternion>;
  76287. /**
  76288. * The scale of the physics-enabled object
  76289. */
  76290. scaling: Vector3;
  76291. /**
  76292. * The rotation of the physics-enabled object
  76293. */
  76294. rotation?: Vector3;
  76295. /**
  76296. * The parent of the physics-enabled object
  76297. */
  76298. parent?: any;
  76299. /**
  76300. * The bounding info of the physics-enabled object
  76301. * @returns The bounding info of the physics-enabled object
  76302. */
  76303. getBoundingInfo(): BoundingInfo;
  76304. /**
  76305. * Computes the world matrix
  76306. * @param force Specifies if the world matrix should be computed by force
  76307. * @returns A world matrix
  76308. */
  76309. computeWorldMatrix(force: boolean): Matrix;
  76310. /**
  76311. * Gets the world matrix
  76312. * @returns A world matrix
  76313. */
  76314. getWorldMatrix?(): Matrix;
  76315. /**
  76316. * Gets the child meshes
  76317. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76318. * @returns An array of abstract meshes
  76319. */
  76320. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76321. /**
  76322. * Gets the vertex data
  76323. * @param kind The type of vertex data
  76324. * @returns A nullable array of numbers, or a float32 array
  76325. */
  76326. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76327. /**
  76328. * Gets the indices from the mesh
  76329. * @returns A nullable array of index arrays
  76330. */
  76331. getIndices?(): Nullable<IndicesArray>;
  76332. /**
  76333. * Gets the scene from the mesh
  76334. * @returns the indices array or null
  76335. */
  76336. getScene?(): Scene;
  76337. /**
  76338. * Gets the absolute position from the mesh
  76339. * @returns the absolute position
  76340. */
  76341. getAbsolutePosition(): Vector3;
  76342. /**
  76343. * Gets the absolute pivot point from the mesh
  76344. * @returns the absolute pivot point
  76345. */
  76346. getAbsolutePivotPoint(): Vector3;
  76347. /**
  76348. * Rotates the mesh
  76349. * @param axis The axis of rotation
  76350. * @param amount The amount of rotation
  76351. * @param space The space of the rotation
  76352. * @returns The rotation transform node
  76353. */
  76354. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76355. /**
  76356. * Translates the mesh
  76357. * @param axis The axis of translation
  76358. * @param distance The distance of translation
  76359. * @param space The space of the translation
  76360. * @returns The transform node
  76361. */
  76362. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76363. /**
  76364. * Sets the absolute position of the mesh
  76365. * @param absolutePosition The absolute position of the mesh
  76366. * @returns The transform node
  76367. */
  76368. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76369. /**
  76370. * Gets the class name of the mesh
  76371. * @returns The class name
  76372. */
  76373. getClassName(): string;
  76374. }
  76375. /**
  76376. * Represents a physics imposter
  76377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76378. */
  76379. export class PhysicsImpostor {
  76380. /**
  76381. * The physics-enabled object used as the physics imposter
  76382. */
  76383. object: IPhysicsEnabledObject;
  76384. /**
  76385. * The type of the physics imposter
  76386. */
  76387. type: number;
  76388. private _options;
  76389. private _scene?;
  76390. /**
  76391. * The default object size of the imposter
  76392. */
  76393. static DEFAULT_OBJECT_SIZE: Vector3;
  76394. /**
  76395. * The identity quaternion of the imposter
  76396. */
  76397. static IDENTITY_QUATERNION: Quaternion;
  76398. /** @hidden */
  76399. _pluginData: any;
  76400. private _physicsEngine;
  76401. private _physicsBody;
  76402. private _bodyUpdateRequired;
  76403. private _onBeforePhysicsStepCallbacks;
  76404. private _onAfterPhysicsStepCallbacks;
  76405. /** @hidden */
  76406. _onPhysicsCollideCallbacks: Array<{
  76407. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76408. otherImpostors: Array<PhysicsImpostor>;
  76409. }>;
  76410. private _deltaPosition;
  76411. private _deltaRotation;
  76412. private _deltaRotationConjugated;
  76413. /** @hidden */
  76414. _isFromLine: boolean;
  76415. private _parent;
  76416. private _isDisposed;
  76417. private static _tmpVecs;
  76418. private static _tmpQuat;
  76419. /**
  76420. * Specifies if the physics imposter is disposed
  76421. */
  76422. readonly isDisposed: boolean;
  76423. /**
  76424. * Gets the mass of the physics imposter
  76425. */
  76426. mass: number;
  76427. /**
  76428. * Gets the coefficient of friction
  76429. */
  76430. /**
  76431. * Sets the coefficient of friction
  76432. */
  76433. friction: number;
  76434. /**
  76435. * Gets the coefficient of restitution
  76436. */
  76437. /**
  76438. * Sets the coefficient of restitution
  76439. */
  76440. restitution: number;
  76441. /**
  76442. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76443. */
  76444. /**
  76445. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76446. */
  76447. pressure: number;
  76448. /**
  76449. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76450. */
  76451. /**
  76452. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76453. */
  76454. stiffness: number;
  76455. /**
  76456. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76457. */
  76458. /**
  76459. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76460. */
  76461. velocityIterations: number;
  76462. /**
  76463. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76464. */
  76465. /**
  76466. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76467. */
  76468. positionIterations: number;
  76469. /**
  76470. * The unique id of the physics imposter
  76471. * set by the physics engine when adding this impostor to the array
  76472. */
  76473. uniqueId: number;
  76474. /**
  76475. * @hidden
  76476. */
  76477. soft: boolean;
  76478. /**
  76479. * @hidden
  76480. */
  76481. segments: number;
  76482. private _joints;
  76483. /**
  76484. * Initializes the physics imposter
  76485. * @param object The physics-enabled object used as the physics imposter
  76486. * @param type The type of the physics imposter
  76487. * @param _options The options for the physics imposter
  76488. * @param _scene The Babylon scene
  76489. */
  76490. constructor(
  76491. /**
  76492. * The physics-enabled object used as the physics imposter
  76493. */
  76494. object: IPhysicsEnabledObject,
  76495. /**
  76496. * The type of the physics imposter
  76497. */
  76498. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76499. /**
  76500. * This function will completly initialize this impostor.
  76501. * It will create a new body - but only if this mesh has no parent.
  76502. * If it has, this impostor will not be used other than to define the impostor
  76503. * of the child mesh.
  76504. * @hidden
  76505. */
  76506. _init(): void;
  76507. private _getPhysicsParent;
  76508. /**
  76509. * Should a new body be generated.
  76510. * @returns boolean specifying if body initialization is required
  76511. */
  76512. isBodyInitRequired(): boolean;
  76513. /**
  76514. * Sets the updated scaling
  76515. * @param updated Specifies if the scaling is updated
  76516. */
  76517. setScalingUpdated(): void;
  76518. /**
  76519. * Force a regeneration of this or the parent's impostor's body.
  76520. * Use under cautious - This will remove all joints already implemented.
  76521. */
  76522. forceUpdate(): void;
  76523. /**
  76524. * Gets the body that holds this impostor. Either its own, or its parent.
  76525. */
  76526. /**
  76527. * Set the physics body. Used mainly by the physics engine/plugin
  76528. */
  76529. physicsBody: any;
  76530. /**
  76531. * Get the parent of the physics imposter
  76532. * @returns Physics imposter or null
  76533. */
  76534. /**
  76535. * Sets the parent of the physics imposter
  76536. */
  76537. parent: Nullable<PhysicsImpostor>;
  76538. /**
  76539. * Resets the update flags
  76540. */
  76541. resetUpdateFlags(): void;
  76542. /**
  76543. * Gets the object extend size
  76544. * @returns the object extend size
  76545. */
  76546. getObjectExtendSize(): Vector3;
  76547. /**
  76548. * Gets the object center
  76549. * @returns The object center
  76550. */
  76551. getObjectCenter(): Vector3;
  76552. /**
  76553. * Get a specific parametes from the options parameter
  76554. * @param paramName The object parameter name
  76555. * @returns The object parameter
  76556. */
  76557. getParam(paramName: string): any;
  76558. /**
  76559. * Sets a specific parameter in the options given to the physics plugin
  76560. * @param paramName The parameter name
  76561. * @param value The value of the parameter
  76562. */
  76563. setParam(paramName: string, value: number): void;
  76564. /**
  76565. * Specifically change the body's mass option. Won't recreate the physics body object
  76566. * @param mass The mass of the physics imposter
  76567. */
  76568. setMass(mass: number): void;
  76569. /**
  76570. * Gets the linear velocity
  76571. * @returns linear velocity or null
  76572. */
  76573. getLinearVelocity(): Nullable<Vector3>;
  76574. /**
  76575. * Sets the linear velocity
  76576. * @param velocity linear velocity or null
  76577. */
  76578. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76579. /**
  76580. * Gets the angular velocity
  76581. * @returns angular velocity or null
  76582. */
  76583. getAngularVelocity(): Nullable<Vector3>;
  76584. /**
  76585. * Sets the angular velocity
  76586. * @param velocity The velocity or null
  76587. */
  76588. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76589. /**
  76590. * Execute a function with the physics plugin native code
  76591. * Provide a function the will have two variables - the world object and the physics body object
  76592. * @param func The function to execute with the physics plugin native code
  76593. */
  76594. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76595. /**
  76596. * Register a function that will be executed before the physics world is stepping forward
  76597. * @param func The function to execute before the physics world is stepped forward
  76598. */
  76599. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76600. /**
  76601. * Unregister a function that will be executed before the physics world is stepping forward
  76602. * @param func The function to execute before the physics world is stepped forward
  76603. */
  76604. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76605. /**
  76606. * Register a function that will be executed after the physics step
  76607. * @param func The function to execute after physics step
  76608. */
  76609. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76610. /**
  76611. * Unregisters a function that will be executed after the physics step
  76612. * @param func The function to execute after physics step
  76613. */
  76614. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76615. /**
  76616. * register a function that will be executed when this impostor collides against a different body
  76617. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76618. * @param func Callback that is executed on collision
  76619. */
  76620. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76621. /**
  76622. * Unregisters the physics imposter on contact
  76623. * @param collideAgainst The physics object to collide against
  76624. * @param func Callback to execute on collision
  76625. */
  76626. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76627. private _tmpQuat;
  76628. private _tmpQuat2;
  76629. /**
  76630. * Get the parent rotation
  76631. * @returns The parent rotation
  76632. */
  76633. getParentsRotation(): Quaternion;
  76634. /**
  76635. * this function is executed by the physics engine.
  76636. */
  76637. beforeStep: () => void;
  76638. /**
  76639. * this function is executed by the physics engine
  76640. */
  76641. afterStep: () => void;
  76642. /**
  76643. * Legacy collision detection event support
  76644. */
  76645. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76646. /**
  76647. * event and body object due to cannon's event-based architecture.
  76648. */
  76649. onCollide: (e: {
  76650. body: any;
  76651. }) => void;
  76652. /**
  76653. * Apply a force
  76654. * @param force The force to apply
  76655. * @param contactPoint The contact point for the force
  76656. * @returns The physics imposter
  76657. */
  76658. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76659. /**
  76660. * Apply an impulse
  76661. * @param force The impulse force
  76662. * @param contactPoint The contact point for the impulse force
  76663. * @returns The physics imposter
  76664. */
  76665. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76666. /**
  76667. * A help function to create a joint
  76668. * @param otherImpostor A physics imposter used to create a joint
  76669. * @param jointType The type of joint
  76670. * @param jointData The data for the joint
  76671. * @returns The physics imposter
  76672. */
  76673. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76674. /**
  76675. * Add a joint to this impostor with a different impostor
  76676. * @param otherImpostor A physics imposter used to add a joint
  76677. * @param joint The joint to add
  76678. * @returns The physics imposter
  76679. */
  76680. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76681. /**
  76682. * Add an anchor to a cloth impostor
  76683. * @param otherImpostor rigid impostor to anchor to
  76684. * @param width ratio across width from 0 to 1
  76685. * @param height ratio up height from 0 to 1
  76686. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76687. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76688. * @returns impostor the soft imposter
  76689. */
  76690. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76691. /**
  76692. * Add a hook to a rope impostor
  76693. * @param otherImpostor rigid impostor to anchor to
  76694. * @param length ratio across rope from 0 to 1
  76695. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76696. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76697. * @returns impostor the rope imposter
  76698. */
  76699. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76700. /**
  76701. * Will keep this body still, in a sleep mode.
  76702. * @returns the physics imposter
  76703. */
  76704. sleep(): PhysicsImpostor;
  76705. /**
  76706. * Wake the body up.
  76707. * @returns The physics imposter
  76708. */
  76709. wakeUp(): PhysicsImpostor;
  76710. /**
  76711. * Clones the physics imposter
  76712. * @param newObject The physics imposter clones to this physics-enabled object
  76713. * @returns A nullable physics imposter
  76714. */
  76715. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76716. /**
  76717. * Disposes the physics imposter
  76718. */
  76719. dispose(): void;
  76720. /**
  76721. * Sets the delta position
  76722. * @param position The delta position amount
  76723. */
  76724. setDeltaPosition(position: Vector3): void;
  76725. /**
  76726. * Sets the delta rotation
  76727. * @param rotation The delta rotation amount
  76728. */
  76729. setDeltaRotation(rotation: Quaternion): void;
  76730. /**
  76731. * Gets the box size of the physics imposter and stores the result in the input parameter
  76732. * @param result Stores the box size
  76733. * @returns The physics imposter
  76734. */
  76735. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76736. /**
  76737. * Gets the radius of the physics imposter
  76738. * @returns Radius of the physics imposter
  76739. */
  76740. getRadius(): number;
  76741. /**
  76742. * Sync a bone with this impostor
  76743. * @param bone The bone to sync to the impostor.
  76744. * @param boneMesh The mesh that the bone is influencing.
  76745. * @param jointPivot The pivot of the joint / bone in local space.
  76746. * @param distToJoint Optional distance from the impostor to the joint.
  76747. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76748. */
  76749. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76750. /**
  76751. * Sync impostor to a bone
  76752. * @param bone The bone that the impostor will be synced to.
  76753. * @param boneMesh The mesh that the bone is influencing.
  76754. * @param jointPivot The pivot of the joint / bone in local space.
  76755. * @param distToJoint Optional distance from the impostor to the joint.
  76756. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76757. * @param boneAxis Optional vector3 axis the bone is aligned with
  76758. */
  76759. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76760. /**
  76761. * No-Imposter type
  76762. */
  76763. static NoImpostor: number;
  76764. /**
  76765. * Sphere-Imposter type
  76766. */
  76767. static SphereImpostor: number;
  76768. /**
  76769. * Box-Imposter type
  76770. */
  76771. static BoxImpostor: number;
  76772. /**
  76773. * Plane-Imposter type
  76774. */
  76775. static PlaneImpostor: number;
  76776. /**
  76777. * Mesh-imposter type
  76778. */
  76779. static MeshImpostor: number;
  76780. /**
  76781. * Capsule-Impostor type (Ammo.js plugin only)
  76782. */
  76783. static CapsuleImpostor: number;
  76784. /**
  76785. * Cylinder-Imposter type
  76786. */
  76787. static CylinderImpostor: number;
  76788. /**
  76789. * Particle-Imposter type
  76790. */
  76791. static ParticleImpostor: number;
  76792. /**
  76793. * Heightmap-Imposter type
  76794. */
  76795. static HeightmapImpostor: number;
  76796. /**
  76797. * ConvexHull-Impostor type (Ammo.js plugin only)
  76798. */
  76799. static ConvexHullImpostor: number;
  76800. /**
  76801. * Rope-Imposter type
  76802. */
  76803. static RopeImpostor: number;
  76804. /**
  76805. * Cloth-Imposter type
  76806. */
  76807. static ClothImpostor: number;
  76808. /**
  76809. * Softbody-Imposter type
  76810. */
  76811. static SoftbodyImpostor: number;
  76812. }
  76813. }
  76814. declare module BABYLON {
  76815. /**
  76816. * @hidden
  76817. **/
  76818. export class _CreationDataStorage {
  76819. closePath?: boolean;
  76820. closeArray?: boolean;
  76821. idx: number[];
  76822. dashSize: number;
  76823. gapSize: number;
  76824. path3D: Path3D;
  76825. pathArray: Vector3[][];
  76826. arc: number;
  76827. radius: number;
  76828. cap: number;
  76829. tessellation: number;
  76830. }
  76831. /**
  76832. * @hidden
  76833. **/
  76834. class _InstanceDataStorage {
  76835. visibleInstances: any;
  76836. batchCache: _InstancesBatch;
  76837. instancesBufferSize: number;
  76838. instancesBuffer: Nullable<Buffer>;
  76839. instancesData: Float32Array;
  76840. overridenInstanceCount: number;
  76841. isFrozen: boolean;
  76842. previousBatch: Nullable<_InstancesBatch>;
  76843. hardwareInstancedRendering: boolean;
  76844. sideOrientation: number;
  76845. }
  76846. /**
  76847. * @hidden
  76848. **/
  76849. export class _InstancesBatch {
  76850. mustReturn: boolean;
  76851. visibleInstances: Nullable<InstancedMesh[]>[];
  76852. renderSelf: boolean[];
  76853. hardwareInstancedRendering: boolean[];
  76854. }
  76855. /**
  76856. * Class used to represent renderable models
  76857. */
  76858. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76859. /**
  76860. * Mesh side orientation : usually the external or front surface
  76861. */
  76862. static readonly FRONTSIDE: number;
  76863. /**
  76864. * Mesh side orientation : usually the internal or back surface
  76865. */
  76866. static readonly BACKSIDE: number;
  76867. /**
  76868. * Mesh side orientation : both internal and external or front and back surfaces
  76869. */
  76870. static readonly DOUBLESIDE: number;
  76871. /**
  76872. * Mesh side orientation : by default, `FRONTSIDE`
  76873. */
  76874. static readonly DEFAULTSIDE: number;
  76875. /**
  76876. * Mesh cap setting : no cap
  76877. */
  76878. static readonly NO_CAP: number;
  76879. /**
  76880. * Mesh cap setting : one cap at the beginning of the mesh
  76881. */
  76882. static readonly CAP_START: number;
  76883. /**
  76884. * Mesh cap setting : one cap at the end of the mesh
  76885. */
  76886. static readonly CAP_END: number;
  76887. /**
  76888. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76889. */
  76890. static readonly CAP_ALL: number;
  76891. /**
  76892. * Mesh pattern setting : no flip or rotate
  76893. */
  76894. static readonly NO_FLIP: number;
  76895. /**
  76896. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76897. */
  76898. static readonly FLIP_TILE: number;
  76899. /**
  76900. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76901. */
  76902. static readonly ROTATE_TILE: number;
  76903. /**
  76904. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76905. */
  76906. static readonly FLIP_ROW: number;
  76907. /**
  76908. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76909. */
  76910. static readonly ROTATE_ROW: number;
  76911. /**
  76912. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76913. */
  76914. static readonly FLIP_N_ROTATE_TILE: number;
  76915. /**
  76916. * Mesh pattern setting : rotate pattern and rotate
  76917. */
  76918. static readonly FLIP_N_ROTATE_ROW: number;
  76919. /**
  76920. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76921. */
  76922. static readonly CENTER: number;
  76923. /**
  76924. * Mesh tile positioning : part tiles on left
  76925. */
  76926. static readonly LEFT: number;
  76927. /**
  76928. * Mesh tile positioning : part tiles on right
  76929. */
  76930. static readonly RIGHT: number;
  76931. /**
  76932. * Mesh tile positioning : part tiles on top
  76933. */
  76934. static readonly TOP: number;
  76935. /**
  76936. * Mesh tile positioning : part tiles on bottom
  76937. */
  76938. static readonly BOTTOM: number;
  76939. /**
  76940. * Gets the default side orientation.
  76941. * @param orientation the orientation to value to attempt to get
  76942. * @returns the default orientation
  76943. * @hidden
  76944. */
  76945. static _GetDefaultSideOrientation(orientation?: number): number;
  76946. private _internalMeshDataInfo;
  76947. /**
  76948. * An event triggered before rendering the mesh
  76949. */
  76950. readonly onBeforeRenderObservable: Observable<Mesh>;
  76951. /**
  76952. * An event triggered before binding the mesh
  76953. */
  76954. readonly onBeforeBindObservable: Observable<Mesh>;
  76955. /**
  76956. * An event triggered after rendering the mesh
  76957. */
  76958. readonly onAfterRenderObservable: Observable<Mesh>;
  76959. /**
  76960. * An event triggered before drawing the mesh
  76961. */
  76962. readonly onBeforeDrawObservable: Observable<Mesh>;
  76963. private _onBeforeDrawObserver;
  76964. /**
  76965. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76966. */
  76967. onBeforeDraw: () => void;
  76968. /**
  76969. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76970. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76971. */
  76972. delayLoadState: number;
  76973. /**
  76974. * Gets the list of instances created from this mesh
  76975. * it is not supposed to be modified manually.
  76976. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76977. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76978. */
  76979. instances: InstancedMesh[];
  76980. /**
  76981. * Gets the file containing delay loading data for this mesh
  76982. */
  76983. delayLoadingFile: string;
  76984. /** @hidden */
  76985. _binaryInfo: any;
  76986. /**
  76987. * User defined function used to change how LOD level selection is done
  76988. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76989. */
  76990. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76991. /**
  76992. * Gets or sets the morph target manager
  76993. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76994. */
  76995. morphTargetManager: Nullable<MorphTargetManager>;
  76996. /** @hidden */
  76997. _creationDataStorage: Nullable<_CreationDataStorage>;
  76998. /** @hidden */
  76999. _geometry: Nullable<Geometry>;
  77000. /** @hidden */
  77001. _delayInfo: Array<string>;
  77002. /** @hidden */
  77003. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77004. /** @hidden */
  77005. _instanceDataStorage: _InstanceDataStorage;
  77006. private _effectiveMaterial;
  77007. /** @hidden */
  77008. _shouldGenerateFlatShading: boolean;
  77009. /** @hidden */
  77010. _originalBuilderSideOrientation: number;
  77011. /**
  77012. * Use this property to change the original side orientation defined at construction time
  77013. */
  77014. overrideMaterialSideOrientation: Nullable<number>;
  77015. /**
  77016. * Gets the source mesh (the one used to clone this one from)
  77017. */
  77018. readonly source: Nullable<Mesh>;
  77019. /**
  77020. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77021. */
  77022. isUnIndexed: boolean;
  77023. /**
  77024. * @constructor
  77025. * @param name The value used by scene.getMeshByName() to do a lookup.
  77026. * @param scene The scene to add this mesh to.
  77027. * @param parent The parent of this mesh, if it has one
  77028. * @param source An optional Mesh from which geometry is shared, cloned.
  77029. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77030. * When false, achieved by calling a clone(), also passing False.
  77031. * This will make creation of children, recursive.
  77032. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77033. */
  77034. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77035. /**
  77036. * Gets the class name
  77037. * @returns the string "Mesh".
  77038. */
  77039. getClassName(): string;
  77040. /** @hidden */
  77041. readonly _isMesh: boolean;
  77042. /**
  77043. * Returns a description of this mesh
  77044. * @param fullDetails define if full details about this mesh must be used
  77045. * @returns a descriptive string representing this mesh
  77046. */
  77047. toString(fullDetails?: boolean): string;
  77048. /** @hidden */
  77049. _unBindEffect(): void;
  77050. /**
  77051. * Gets a boolean indicating if this mesh has LOD
  77052. */
  77053. readonly hasLODLevels: boolean;
  77054. /**
  77055. * Gets the list of MeshLODLevel associated with the current mesh
  77056. * @returns an array of MeshLODLevel
  77057. */
  77058. getLODLevels(): MeshLODLevel[];
  77059. private _sortLODLevels;
  77060. /**
  77061. * Add a mesh as LOD level triggered at the given distance.
  77062. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77063. * @param distance The distance from the center of the object to show this level
  77064. * @param mesh The mesh to be added as LOD level (can be null)
  77065. * @return This mesh (for chaining)
  77066. */
  77067. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77068. /**
  77069. * Returns the LOD level mesh at the passed distance or null if not found.
  77070. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77071. * @param distance The distance from the center of the object to show this level
  77072. * @returns a Mesh or `null`
  77073. */
  77074. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77075. /**
  77076. * Remove a mesh from the LOD array
  77077. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77078. * @param mesh defines the mesh to be removed
  77079. * @return This mesh (for chaining)
  77080. */
  77081. removeLODLevel(mesh: Mesh): Mesh;
  77082. /**
  77083. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77084. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77085. * @param camera defines the camera to use to compute distance
  77086. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77087. * @return This mesh (for chaining)
  77088. */
  77089. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77090. /**
  77091. * Gets the mesh internal Geometry object
  77092. */
  77093. readonly geometry: Nullable<Geometry>;
  77094. /**
  77095. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77096. * @returns the total number of vertices
  77097. */
  77098. getTotalVertices(): number;
  77099. /**
  77100. * Returns the content of an associated vertex buffer
  77101. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77102. * - VertexBuffer.PositionKind
  77103. * - VertexBuffer.UVKind
  77104. * - VertexBuffer.UV2Kind
  77105. * - VertexBuffer.UV3Kind
  77106. * - VertexBuffer.UV4Kind
  77107. * - VertexBuffer.UV5Kind
  77108. * - VertexBuffer.UV6Kind
  77109. * - VertexBuffer.ColorKind
  77110. * - VertexBuffer.MatricesIndicesKind
  77111. * - VertexBuffer.MatricesIndicesExtraKind
  77112. * - VertexBuffer.MatricesWeightsKind
  77113. * - VertexBuffer.MatricesWeightsExtraKind
  77114. * @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
  77115. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77116. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77117. */
  77118. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77119. /**
  77120. * Returns the mesh VertexBuffer object from the requested `kind`
  77121. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77122. * - VertexBuffer.PositionKind
  77123. * - VertexBuffer.NormalKind
  77124. * - VertexBuffer.UVKind
  77125. * - VertexBuffer.UV2Kind
  77126. * - VertexBuffer.UV3Kind
  77127. * - VertexBuffer.UV4Kind
  77128. * - VertexBuffer.UV5Kind
  77129. * - VertexBuffer.UV6Kind
  77130. * - VertexBuffer.ColorKind
  77131. * - VertexBuffer.MatricesIndicesKind
  77132. * - VertexBuffer.MatricesIndicesExtraKind
  77133. * - VertexBuffer.MatricesWeightsKind
  77134. * - VertexBuffer.MatricesWeightsExtraKind
  77135. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77136. */
  77137. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77138. /**
  77139. * Tests if a specific vertex buffer is associated with this mesh
  77140. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77141. * - VertexBuffer.PositionKind
  77142. * - VertexBuffer.NormalKind
  77143. * - VertexBuffer.UVKind
  77144. * - VertexBuffer.UV2Kind
  77145. * - VertexBuffer.UV3Kind
  77146. * - VertexBuffer.UV4Kind
  77147. * - VertexBuffer.UV5Kind
  77148. * - VertexBuffer.UV6Kind
  77149. * - VertexBuffer.ColorKind
  77150. * - VertexBuffer.MatricesIndicesKind
  77151. * - VertexBuffer.MatricesIndicesExtraKind
  77152. * - VertexBuffer.MatricesWeightsKind
  77153. * - VertexBuffer.MatricesWeightsExtraKind
  77154. * @returns a boolean
  77155. */
  77156. isVerticesDataPresent(kind: string): boolean;
  77157. /**
  77158. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77159. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77160. * - VertexBuffer.PositionKind
  77161. * - VertexBuffer.UVKind
  77162. * - VertexBuffer.UV2Kind
  77163. * - VertexBuffer.UV3Kind
  77164. * - VertexBuffer.UV4Kind
  77165. * - VertexBuffer.UV5Kind
  77166. * - VertexBuffer.UV6Kind
  77167. * - VertexBuffer.ColorKind
  77168. * - VertexBuffer.MatricesIndicesKind
  77169. * - VertexBuffer.MatricesIndicesExtraKind
  77170. * - VertexBuffer.MatricesWeightsKind
  77171. * - VertexBuffer.MatricesWeightsExtraKind
  77172. * @returns a boolean
  77173. */
  77174. isVertexBufferUpdatable(kind: string): boolean;
  77175. /**
  77176. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77177. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77178. * - VertexBuffer.PositionKind
  77179. * - VertexBuffer.NormalKind
  77180. * - VertexBuffer.UVKind
  77181. * - VertexBuffer.UV2Kind
  77182. * - VertexBuffer.UV3Kind
  77183. * - VertexBuffer.UV4Kind
  77184. * - VertexBuffer.UV5Kind
  77185. * - VertexBuffer.UV6Kind
  77186. * - VertexBuffer.ColorKind
  77187. * - VertexBuffer.MatricesIndicesKind
  77188. * - VertexBuffer.MatricesIndicesExtraKind
  77189. * - VertexBuffer.MatricesWeightsKind
  77190. * - VertexBuffer.MatricesWeightsExtraKind
  77191. * @returns an array of strings
  77192. */
  77193. getVerticesDataKinds(): string[];
  77194. /**
  77195. * Returns a positive integer : the total number of indices in this mesh geometry.
  77196. * @returns the numner of indices or zero if the mesh has no geometry.
  77197. */
  77198. getTotalIndices(): number;
  77199. /**
  77200. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77201. * @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.
  77202. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77203. * @returns the indices array or an empty array if the mesh has no geometry
  77204. */
  77205. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77206. readonly isBlocked: boolean;
  77207. /**
  77208. * Determine if the current mesh is ready to be rendered
  77209. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77210. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77211. * @returns true if all associated assets are ready (material, textures, shaders)
  77212. */
  77213. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77214. /**
  77215. * 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.
  77216. */
  77217. readonly areNormalsFrozen: boolean;
  77218. /**
  77219. * 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.
  77220. * @returns the current mesh
  77221. */
  77222. freezeNormals(): Mesh;
  77223. /**
  77224. * 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
  77225. * @returns the current mesh
  77226. */
  77227. unfreezeNormals(): Mesh;
  77228. /**
  77229. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77230. */
  77231. overridenInstanceCount: number;
  77232. /** @hidden */
  77233. _preActivate(): Mesh;
  77234. /** @hidden */
  77235. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77236. /** @hidden */
  77237. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77238. /**
  77239. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77240. * This means the mesh underlying bounding box and sphere are recomputed.
  77241. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77242. * @returns the current mesh
  77243. */
  77244. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77245. /** @hidden */
  77246. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77247. /**
  77248. * This function will subdivide the mesh into multiple submeshes
  77249. * @param count defines the expected number of submeshes
  77250. */
  77251. subdivide(count: number): void;
  77252. /**
  77253. * Copy a FloatArray into a specific associated vertex buffer
  77254. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77255. * - VertexBuffer.PositionKind
  77256. * - VertexBuffer.UVKind
  77257. * - VertexBuffer.UV2Kind
  77258. * - VertexBuffer.UV3Kind
  77259. * - VertexBuffer.UV4Kind
  77260. * - VertexBuffer.UV5Kind
  77261. * - VertexBuffer.UV6Kind
  77262. * - VertexBuffer.ColorKind
  77263. * - VertexBuffer.MatricesIndicesKind
  77264. * - VertexBuffer.MatricesIndicesExtraKind
  77265. * - VertexBuffer.MatricesWeightsKind
  77266. * - VertexBuffer.MatricesWeightsExtraKind
  77267. * @param data defines the data source
  77268. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77269. * @param stride defines the data stride size (can be null)
  77270. * @returns the current mesh
  77271. */
  77272. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77273. /**
  77274. * Flags an associated vertex buffer as updatable
  77275. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77276. * - VertexBuffer.PositionKind
  77277. * - VertexBuffer.UVKind
  77278. * - VertexBuffer.UV2Kind
  77279. * - VertexBuffer.UV3Kind
  77280. * - VertexBuffer.UV4Kind
  77281. * - VertexBuffer.UV5Kind
  77282. * - VertexBuffer.UV6Kind
  77283. * - VertexBuffer.ColorKind
  77284. * - VertexBuffer.MatricesIndicesKind
  77285. * - VertexBuffer.MatricesIndicesExtraKind
  77286. * - VertexBuffer.MatricesWeightsKind
  77287. * - VertexBuffer.MatricesWeightsExtraKind
  77288. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77289. */
  77290. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77291. /**
  77292. * Sets the mesh global Vertex Buffer
  77293. * @param buffer defines the buffer to use
  77294. * @returns the current mesh
  77295. */
  77296. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77297. /**
  77298. * Update a specific associated vertex buffer
  77299. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77300. * - VertexBuffer.PositionKind
  77301. * - VertexBuffer.UVKind
  77302. * - VertexBuffer.UV2Kind
  77303. * - VertexBuffer.UV3Kind
  77304. * - VertexBuffer.UV4Kind
  77305. * - VertexBuffer.UV5Kind
  77306. * - VertexBuffer.UV6Kind
  77307. * - VertexBuffer.ColorKind
  77308. * - VertexBuffer.MatricesIndicesKind
  77309. * - VertexBuffer.MatricesIndicesExtraKind
  77310. * - VertexBuffer.MatricesWeightsKind
  77311. * - VertexBuffer.MatricesWeightsExtraKind
  77312. * @param data defines the data source
  77313. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77314. * @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)
  77315. * @returns the current mesh
  77316. */
  77317. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77318. /**
  77319. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77320. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77321. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77322. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77323. * @returns the current mesh
  77324. */
  77325. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77326. /**
  77327. * Creates a un-shared specific occurence of the geometry for the mesh.
  77328. * @returns the current mesh
  77329. */
  77330. makeGeometryUnique(): Mesh;
  77331. /**
  77332. * Set the index buffer of this mesh
  77333. * @param indices defines the source data
  77334. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77335. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77336. * @returns the current mesh
  77337. */
  77338. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77339. /**
  77340. * Update the current index buffer
  77341. * @param indices defines the source data
  77342. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77343. * @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)
  77344. * @returns the current mesh
  77345. */
  77346. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77347. /**
  77348. * Invert the geometry to move from a right handed system to a left handed one.
  77349. * @returns the current mesh
  77350. */
  77351. toLeftHanded(): Mesh;
  77352. /** @hidden */
  77353. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77354. /** @hidden */
  77355. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  77356. /**
  77357. * Registers for this mesh a javascript function called just before the rendering process
  77358. * @param func defines the function to call before rendering this mesh
  77359. * @returns the current mesh
  77360. */
  77361. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77362. /**
  77363. * Disposes a previously registered javascript function called before the rendering
  77364. * @param func defines the function to remove
  77365. * @returns the current mesh
  77366. */
  77367. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77368. /**
  77369. * Registers for this mesh a javascript function called just after the rendering is complete
  77370. * @param func defines the function to call after rendering this mesh
  77371. * @returns the current mesh
  77372. */
  77373. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77374. /**
  77375. * Disposes a previously registered javascript function called after the rendering.
  77376. * @param func defines the function to remove
  77377. * @returns the current mesh
  77378. */
  77379. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77380. /** @hidden */
  77381. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77382. /** @hidden */
  77383. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77384. /** @hidden */
  77385. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77386. /** @hidden */
  77387. _rebuild(): void;
  77388. /** @hidden */
  77389. _freeze(): void;
  77390. /** @hidden */
  77391. _unFreeze(): void;
  77392. /**
  77393. * 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
  77394. * @param subMesh defines the subMesh to render
  77395. * @param enableAlphaMode defines if alpha mode can be changed
  77396. * @returns the current mesh
  77397. */
  77398. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77399. private _onBeforeDraw;
  77400. /**
  77401. * Renormalize the mesh and patch it up if there are no weights
  77402. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77403. * However in the case of zero weights then we set just a single influence to 1.
  77404. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77405. */
  77406. cleanMatrixWeights(): void;
  77407. private normalizeSkinFourWeights;
  77408. private normalizeSkinWeightsAndExtra;
  77409. /**
  77410. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77411. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77412. * the user know there was an issue with importing the mesh
  77413. * @returns a validation object with skinned, valid and report string
  77414. */
  77415. validateSkinning(): {
  77416. skinned: boolean;
  77417. valid: boolean;
  77418. report: string;
  77419. };
  77420. /** @hidden */
  77421. _checkDelayState(): Mesh;
  77422. private _queueLoad;
  77423. /**
  77424. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77425. * A mesh is in the frustum if its bounding box intersects the frustum
  77426. * @param frustumPlanes defines the frustum to test
  77427. * @returns true if the mesh is in the frustum planes
  77428. */
  77429. isInFrustum(frustumPlanes: Plane[]): boolean;
  77430. /**
  77431. * Sets the mesh material by the material or multiMaterial `id` property
  77432. * @param id is a string identifying the material or the multiMaterial
  77433. * @returns the current mesh
  77434. */
  77435. setMaterialByID(id: string): Mesh;
  77436. /**
  77437. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77438. * @returns an array of IAnimatable
  77439. */
  77440. getAnimatables(): IAnimatable[];
  77441. /**
  77442. * Modifies the mesh geometry according to the passed transformation matrix.
  77443. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77444. * The mesh normals are modified using the same transformation.
  77445. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77446. * @param transform defines the transform matrix to use
  77447. * @see http://doc.babylonjs.com/resources/baking_transformations
  77448. * @returns the current mesh
  77449. */
  77450. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77451. /**
  77452. * Modifies the mesh geometry according to its own current World Matrix.
  77453. * The mesh World Matrix is then reset.
  77454. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77455. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77456. * @see http://doc.babylonjs.com/resources/baking_transformations
  77457. * @returns the current mesh
  77458. */
  77459. bakeCurrentTransformIntoVertices(): Mesh;
  77460. /** @hidden */
  77461. readonly _positions: Nullable<Vector3[]>;
  77462. /** @hidden */
  77463. _resetPointsArrayCache(): Mesh;
  77464. /** @hidden */
  77465. _generatePointsArray(): boolean;
  77466. /**
  77467. * Returns a new Mesh object generated from the current mesh properties.
  77468. * This method must not get confused with createInstance()
  77469. * @param name is a string, the name given to the new mesh
  77470. * @param newParent can be any Node object (default `null`)
  77471. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77472. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77473. * @returns a new mesh
  77474. */
  77475. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77476. /**
  77477. * Releases resources associated with this mesh.
  77478. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77479. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77480. */
  77481. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77482. /**
  77483. * Modifies the mesh geometry according to a displacement map.
  77484. * 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.
  77485. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77486. * @param url is a string, the URL from the image file is to be downloaded.
  77487. * @param minHeight is the lower limit of the displacement.
  77488. * @param maxHeight is the upper limit of the displacement.
  77489. * @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.
  77490. * @param uvOffset is an optional vector2 used to offset UV.
  77491. * @param uvScale is an optional vector2 used to scale UV.
  77492. * @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.
  77493. * @returns the Mesh.
  77494. */
  77495. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77496. /**
  77497. * Modifies the mesh geometry according to a displacementMap buffer.
  77498. * 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.
  77499. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77500. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77501. * @param heightMapWidth is the width of the buffer image.
  77502. * @param heightMapHeight is the height of the buffer image.
  77503. * @param minHeight is the lower limit of the displacement.
  77504. * @param maxHeight is the upper limit of the displacement.
  77505. * @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.
  77506. * @param uvOffset is an optional vector2 used to offset UV.
  77507. * @param uvScale is an optional vector2 used to scale UV.
  77508. * @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.
  77509. * @returns the Mesh.
  77510. */
  77511. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77512. /**
  77513. * Modify the mesh to get a flat shading rendering.
  77514. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77515. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77516. * @returns current mesh
  77517. */
  77518. convertToFlatShadedMesh(): Mesh;
  77519. /**
  77520. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77521. * In other words, more vertices, no more indices and a single bigger VBO.
  77522. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77523. * @returns current mesh
  77524. */
  77525. convertToUnIndexedMesh(): Mesh;
  77526. /**
  77527. * Inverses facet orientations.
  77528. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77529. * @param flipNormals will also inverts the normals
  77530. * @returns current mesh
  77531. */
  77532. flipFaces(flipNormals?: boolean): Mesh;
  77533. /**
  77534. * Increase the number of facets and hence vertices in a mesh
  77535. * Vertex normals are interpolated from existing vertex normals
  77536. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77537. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77538. */
  77539. increaseVertices(numberPerEdge: number): void;
  77540. /**
  77541. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77542. * This will undo any application of covertToFlatShadedMesh
  77543. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77544. */
  77545. forceSharedVertices(): void;
  77546. /** @hidden */
  77547. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77548. /** @hidden */
  77549. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77550. /**
  77551. * Creates a new InstancedMesh object from the mesh model.
  77552. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77553. * @param name defines the name of the new instance
  77554. * @returns a new InstancedMesh
  77555. */
  77556. createInstance(name: string): InstancedMesh;
  77557. /**
  77558. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77559. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77560. * @returns the current mesh
  77561. */
  77562. synchronizeInstances(): Mesh;
  77563. /**
  77564. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77565. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77566. * This should be used together with the simplification to avoid disappearing triangles.
  77567. * @param successCallback an optional success callback to be called after the optimization finished.
  77568. * @returns the current mesh
  77569. */
  77570. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77571. /**
  77572. * Serialize current mesh
  77573. * @param serializationObject defines the object which will receive the serialization data
  77574. */
  77575. serialize(serializationObject: any): void;
  77576. /** @hidden */
  77577. _syncGeometryWithMorphTargetManager(): void;
  77578. /** @hidden */
  77579. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77580. /**
  77581. * Returns a new Mesh object parsed from the source provided.
  77582. * @param parsedMesh is the source
  77583. * @param scene defines the hosting scene
  77584. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77585. * @returns a new Mesh
  77586. */
  77587. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77588. /**
  77589. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77590. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77591. * @param name defines the name of the mesh to create
  77592. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77593. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77594. * @param closePath creates a seam between the first and the last points of each path of the path array
  77595. * @param offset is taken in account only if the `pathArray` is containing a single path
  77596. * @param scene defines the hosting scene
  77597. * @param updatable defines if the mesh must be flagged as updatable
  77598. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77599. * @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)
  77600. * @returns a new Mesh
  77601. */
  77602. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77603. /**
  77604. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77605. * @param name defines the name of the mesh to create
  77606. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77607. * @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
  77608. * @param scene defines the hosting scene
  77609. * @param updatable defines if the mesh must be flagged as updatable
  77610. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77611. * @returns a new Mesh
  77612. */
  77613. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77614. /**
  77615. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77616. * @param name defines the name of the mesh to create
  77617. * @param size sets the size (float) of each box side (default 1)
  77618. * @param scene defines the hosting scene
  77619. * @param updatable defines if the mesh must be flagged as updatable
  77620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77621. * @returns a new Mesh
  77622. */
  77623. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77624. /**
  77625. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77626. * @param name defines the name of the mesh to create
  77627. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77628. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77629. * @param scene defines the hosting scene
  77630. * @param updatable defines if the mesh must be flagged as updatable
  77631. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77632. * @returns a new Mesh
  77633. */
  77634. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77635. /**
  77636. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77637. * @param name defines the name of the mesh to create
  77638. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77639. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77640. * @param scene defines the hosting scene
  77641. * @returns a new Mesh
  77642. */
  77643. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77644. /**
  77645. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77646. * @param name defines the name of the mesh to create
  77647. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77648. * @param diameterTop set the top cap diameter (floats, default 1)
  77649. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77650. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77651. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77652. * @param scene defines the hosting scene
  77653. * @param updatable defines if the mesh must be flagged as updatable
  77654. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77655. * @returns a new Mesh
  77656. */
  77657. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77658. /**
  77659. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77660. * @param name defines the name of the mesh to create
  77661. * @param diameter sets the diameter size (float) of the torus (default 1)
  77662. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77663. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77664. * @param scene defines the hosting scene
  77665. * @param updatable defines if the mesh must be flagged as updatable
  77666. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77667. * @returns a new Mesh
  77668. */
  77669. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77670. /**
  77671. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77672. * @param name defines the name of the mesh to create
  77673. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77674. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77675. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77676. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77677. * @param p the number of windings on X axis (positive integers, default 2)
  77678. * @param q the number of windings on Y axis (positive integers, default 3)
  77679. * @param scene defines the hosting scene
  77680. * @param updatable defines if the mesh must be flagged as updatable
  77681. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77682. * @returns a new Mesh
  77683. */
  77684. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77685. /**
  77686. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77687. * @param name defines the name of the mesh to create
  77688. * @param points is an array successive Vector3
  77689. * @param scene defines the hosting scene
  77690. * @param updatable defines if the mesh must be flagged as updatable
  77691. * @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).
  77692. * @returns a new Mesh
  77693. */
  77694. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77695. /**
  77696. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77697. * @param name defines the name of the mesh to create
  77698. * @param points is an array successive Vector3
  77699. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77700. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77701. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77702. * @param scene defines the hosting scene
  77703. * @param updatable defines if the mesh must be flagged as updatable
  77704. * @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)
  77705. * @returns a new Mesh
  77706. */
  77707. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77708. /**
  77709. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77710. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77711. * 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.
  77712. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77713. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77714. * Remember you can only change the shape positions, not their number when updating a polygon.
  77715. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77716. * @param name defines the name of the mesh to create
  77717. * @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
  77718. * @param scene defines the hosting scene
  77719. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77720. * @param updatable defines if the mesh must be flagged as updatable
  77721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77722. * @param earcutInjection can be used to inject your own earcut reference
  77723. * @returns a new Mesh
  77724. */
  77725. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77726. /**
  77727. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77728. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77729. * @param name defines the name of the mesh to create
  77730. * @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
  77731. * @param depth defines the height of extrusion
  77732. * @param scene defines the hosting scene
  77733. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77734. * @param updatable defines if the mesh must be flagged as updatable
  77735. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77736. * @param earcutInjection can be used to inject your own earcut reference
  77737. * @returns a new Mesh
  77738. */
  77739. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77740. /**
  77741. * Creates an extruded shape mesh.
  77742. * 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
  77743. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77744. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77745. * @param name defines the name of the mesh to create
  77746. * @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
  77747. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77748. * @param scale is the value to scale the shape
  77749. * @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
  77750. * @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
  77751. * @param scene defines the hosting scene
  77752. * @param updatable defines if the mesh must be flagged as updatable
  77753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77754. * @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)
  77755. * @returns a new Mesh
  77756. */
  77757. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77758. /**
  77759. * Creates an custom extruded shape mesh.
  77760. * The custom extrusion is a parametric shape.
  77761. * It has no predefined shape. Its final shape will depend on the input parameters.
  77762. * Please consider using the same method from the MeshBuilder class instead
  77763. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77764. * @param name defines the name of the mesh to create
  77765. * @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
  77766. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77767. * @param scaleFunction is a custom Javascript function called on each path point
  77768. * @param rotationFunction is a custom Javascript function called on each path point
  77769. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77770. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77771. * @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
  77772. * @param scene defines the hosting scene
  77773. * @param updatable defines if the mesh must be flagged as updatable
  77774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77775. * @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)
  77776. * @returns a new Mesh
  77777. */
  77778. 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;
  77779. /**
  77780. * Creates lathe mesh.
  77781. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77782. * Please consider using the same method from the MeshBuilder class instead
  77783. * @param name defines the name of the mesh to create
  77784. * @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
  77785. * @param radius is the radius value of the lathe
  77786. * @param tessellation is the side number of the lathe.
  77787. * @param scene defines the hosting scene
  77788. * @param updatable defines if the mesh must be flagged as updatable
  77789. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77790. * @returns a new Mesh
  77791. */
  77792. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77793. /**
  77794. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77795. * @param name defines the name of the mesh to create
  77796. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77797. * @param scene defines the hosting scene
  77798. * @param updatable defines if the mesh must be flagged as updatable
  77799. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77800. * @returns a new Mesh
  77801. */
  77802. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77803. /**
  77804. * Creates a ground mesh.
  77805. * Please consider using the same method from the MeshBuilder class instead
  77806. * @param name defines the name of the mesh to create
  77807. * @param width set the width of the ground
  77808. * @param height set the height of the ground
  77809. * @param subdivisions sets the number of subdivisions per side
  77810. * @param scene defines the hosting scene
  77811. * @param updatable defines if the mesh must be flagged as updatable
  77812. * @returns a new Mesh
  77813. */
  77814. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77815. /**
  77816. * Creates a tiled ground mesh.
  77817. * Please consider using the same method from the MeshBuilder class instead
  77818. * @param name defines the name of the mesh to create
  77819. * @param xmin set the ground minimum X coordinate
  77820. * @param zmin set the ground minimum Y coordinate
  77821. * @param xmax set the ground maximum X coordinate
  77822. * @param zmax set the ground maximum Z coordinate
  77823. * @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
  77824. * @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
  77825. * @param scene defines the hosting scene
  77826. * @param updatable defines if the mesh must be flagged as updatable
  77827. * @returns a new Mesh
  77828. */
  77829. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77830. w: number;
  77831. h: number;
  77832. }, precision: {
  77833. w: number;
  77834. h: number;
  77835. }, scene: Scene, updatable?: boolean): Mesh;
  77836. /**
  77837. * Creates a ground mesh from a height map.
  77838. * Please consider using the same method from the MeshBuilder class instead
  77839. * @see http://doc.babylonjs.com/babylon101/height_map
  77840. * @param name defines the name of the mesh to create
  77841. * @param url sets the URL of the height map image resource
  77842. * @param width set the ground width size
  77843. * @param height set the ground height size
  77844. * @param subdivisions sets the number of subdivision per side
  77845. * @param minHeight is the minimum altitude on the ground
  77846. * @param maxHeight is the maximum altitude on the ground
  77847. * @param scene defines the hosting scene
  77848. * @param updatable defines if the mesh must be flagged as updatable
  77849. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77850. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77851. * @returns a new Mesh
  77852. */
  77853. 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;
  77854. /**
  77855. * Creates a tube mesh.
  77856. * The tube is a parametric shape.
  77857. * It has no predefined shape. Its final shape will depend on the input parameters.
  77858. * Please consider using the same method from the MeshBuilder class instead
  77859. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77860. * @param name defines the name of the mesh to create
  77861. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77862. * @param radius sets the tube radius size
  77863. * @param tessellation is the number of sides on the tubular surface
  77864. * @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
  77865. * @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
  77866. * @param scene defines the hosting scene
  77867. * @param updatable defines if the mesh must be flagged as updatable
  77868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77869. * @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)
  77870. * @returns a new Mesh
  77871. */
  77872. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77873. (i: number, distance: number): number;
  77874. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77875. /**
  77876. * Creates a polyhedron mesh.
  77877. * Please consider using the same method from the MeshBuilder class instead.
  77878. * * 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
  77879. * * The parameter `size` (positive float, default 1) sets the polygon size
  77880. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77881. * * 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`
  77882. * * 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
  77883. * * 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)`)
  77884. * * 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
  77885. * * 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
  77886. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77887. * * If you create a double-sided mesh, you can choose what parts of 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
  77888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77889. * @param name defines the name of the mesh to create
  77890. * @param options defines the options used to create the mesh
  77891. * @param scene defines the hosting scene
  77892. * @returns a new Mesh
  77893. */
  77894. static CreatePolyhedron(name: string, options: {
  77895. type?: number;
  77896. size?: number;
  77897. sizeX?: number;
  77898. sizeY?: number;
  77899. sizeZ?: number;
  77900. custom?: any;
  77901. faceUV?: Vector4[];
  77902. faceColors?: Color4[];
  77903. updatable?: boolean;
  77904. sideOrientation?: number;
  77905. }, scene: Scene): Mesh;
  77906. /**
  77907. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77908. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77909. * * 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`)
  77910. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77911. * * 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
  77912. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77913. * * If you create a double-sided mesh, you can choose what parts of 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
  77914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77915. * @param name defines the name of the mesh
  77916. * @param options defines the options used to create the mesh
  77917. * @param scene defines the hosting scene
  77918. * @returns a new Mesh
  77919. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77920. */
  77921. static CreateIcoSphere(name: string, options: {
  77922. radius?: number;
  77923. flat?: boolean;
  77924. subdivisions?: number;
  77925. sideOrientation?: number;
  77926. updatable?: boolean;
  77927. }, scene: Scene): Mesh;
  77928. /**
  77929. * Creates a decal mesh.
  77930. * Please consider using the same method from the MeshBuilder class instead.
  77931. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77932. * @param name defines the name of the mesh
  77933. * @param sourceMesh defines the mesh receiving the decal
  77934. * @param position sets the position of the decal in world coordinates
  77935. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77936. * @param size sets the decal scaling
  77937. * @param angle sets the angle to rotate the decal
  77938. * @returns a new Mesh
  77939. */
  77940. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77941. /**
  77942. * Prepare internal position array for software CPU skinning
  77943. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77944. */
  77945. setPositionsForCPUSkinning(): Float32Array;
  77946. /**
  77947. * Prepare internal normal array for software CPU skinning
  77948. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77949. */
  77950. setNormalsForCPUSkinning(): Float32Array;
  77951. /**
  77952. * Updates the vertex buffer by applying transformation from the bones
  77953. * @param skeleton defines the skeleton to apply to current mesh
  77954. * @returns the current mesh
  77955. */
  77956. applySkeleton(skeleton: Skeleton): Mesh;
  77957. /**
  77958. * 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
  77959. * @param meshes defines the list of meshes to scan
  77960. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77961. */
  77962. static MinMax(meshes: AbstractMesh[]): {
  77963. min: Vector3;
  77964. max: Vector3;
  77965. };
  77966. /**
  77967. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77968. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77969. * @returns a vector3
  77970. */
  77971. static Center(meshesOrMinMaxVector: {
  77972. min: Vector3;
  77973. max: Vector3;
  77974. } | AbstractMesh[]): Vector3;
  77975. /**
  77976. * Merge the array of meshes into a single mesh for performance reasons.
  77977. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77978. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77979. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77980. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77981. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77982. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77983. * @returns a new mesh
  77984. */
  77985. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77986. /** @hidden */
  77987. addInstance(instance: InstancedMesh): void;
  77988. /** @hidden */
  77989. removeInstance(instance: InstancedMesh): void;
  77990. }
  77991. }
  77992. declare module BABYLON {
  77993. /**
  77994. * Interface used to define Action
  77995. */
  77996. export interface IAction {
  77997. /**
  77998. * Trigger for the action
  77999. */
  78000. trigger: number;
  78001. /** Options of the trigger */
  78002. triggerOptions: any;
  78003. /**
  78004. * Gets the trigger parameters
  78005. * @returns the trigger parameters
  78006. */
  78007. getTriggerParameter(): any;
  78008. /**
  78009. * Internal only - executes current action event
  78010. * @hidden
  78011. */
  78012. _executeCurrent(evt?: ActionEvent): void;
  78013. /**
  78014. * Serialize placeholder for child classes
  78015. * @param parent of child
  78016. * @returns the serialized object
  78017. */
  78018. serialize(parent: any): any;
  78019. /**
  78020. * Internal only
  78021. * @hidden
  78022. */
  78023. _prepare(): void;
  78024. /**
  78025. * Internal only - manager for action
  78026. * @hidden
  78027. */
  78028. _actionManager: AbstractActionManager;
  78029. /**
  78030. * Adds action to chain of actions, may be a DoNothingAction
  78031. * @param action defines the next action to execute
  78032. * @returns The action passed in
  78033. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78034. */
  78035. then(action: IAction): IAction;
  78036. }
  78037. /**
  78038. * The action to be carried out following a trigger
  78039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78040. */
  78041. export class Action implements IAction {
  78042. /** the trigger, with or without parameters, for the action */
  78043. triggerOptions: any;
  78044. /**
  78045. * Trigger for the action
  78046. */
  78047. trigger: number;
  78048. /**
  78049. * Internal only - manager for action
  78050. * @hidden
  78051. */
  78052. _actionManager: ActionManager;
  78053. private _nextActiveAction;
  78054. private _child;
  78055. private _condition?;
  78056. private _triggerParameter;
  78057. /**
  78058. * An event triggered prior to action being executed.
  78059. */
  78060. onBeforeExecuteObservable: Observable<Action>;
  78061. /**
  78062. * Creates a new Action
  78063. * @param triggerOptions the trigger, with or without parameters, for the action
  78064. * @param condition an optional determinant of action
  78065. */
  78066. constructor(
  78067. /** the trigger, with or without parameters, for the action */
  78068. triggerOptions: any, condition?: Condition);
  78069. /**
  78070. * Internal only
  78071. * @hidden
  78072. */
  78073. _prepare(): void;
  78074. /**
  78075. * Gets the trigger parameters
  78076. * @returns the trigger parameters
  78077. */
  78078. getTriggerParameter(): any;
  78079. /**
  78080. * Internal only - executes current action event
  78081. * @hidden
  78082. */
  78083. _executeCurrent(evt?: ActionEvent): void;
  78084. /**
  78085. * Execute placeholder for child classes
  78086. * @param evt optional action event
  78087. */
  78088. execute(evt?: ActionEvent): void;
  78089. /**
  78090. * Skips to next active action
  78091. */
  78092. skipToNextActiveAction(): void;
  78093. /**
  78094. * Adds action to chain of actions, may be a DoNothingAction
  78095. * @param action defines the next action to execute
  78096. * @returns The action passed in
  78097. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78098. */
  78099. then(action: Action): Action;
  78100. /**
  78101. * Internal only
  78102. * @hidden
  78103. */
  78104. _getProperty(propertyPath: string): string;
  78105. /**
  78106. * Internal only
  78107. * @hidden
  78108. */
  78109. _getEffectiveTarget(target: any, propertyPath: string): any;
  78110. /**
  78111. * Serialize placeholder for child classes
  78112. * @param parent of child
  78113. * @returns the serialized object
  78114. */
  78115. serialize(parent: any): any;
  78116. /**
  78117. * Internal only called by serialize
  78118. * @hidden
  78119. */
  78120. protected _serialize(serializedAction: any, parent?: any): any;
  78121. /**
  78122. * Internal only
  78123. * @hidden
  78124. */
  78125. static _SerializeValueAsString: (value: any) => string;
  78126. /**
  78127. * Internal only
  78128. * @hidden
  78129. */
  78130. static _GetTargetProperty: (target: Scene | Node) => {
  78131. name: string;
  78132. targetType: string;
  78133. value: string;
  78134. };
  78135. }
  78136. }
  78137. declare module BABYLON {
  78138. /**
  78139. * A Condition applied to an Action
  78140. */
  78141. export class Condition {
  78142. /**
  78143. * Internal only - manager for action
  78144. * @hidden
  78145. */
  78146. _actionManager: ActionManager;
  78147. /**
  78148. * Internal only
  78149. * @hidden
  78150. */
  78151. _evaluationId: number;
  78152. /**
  78153. * Internal only
  78154. * @hidden
  78155. */
  78156. _currentResult: boolean;
  78157. /**
  78158. * Creates a new Condition
  78159. * @param actionManager the manager of the action the condition is applied to
  78160. */
  78161. constructor(actionManager: ActionManager);
  78162. /**
  78163. * Check if the current condition is valid
  78164. * @returns a boolean
  78165. */
  78166. isValid(): boolean;
  78167. /**
  78168. * Internal only
  78169. * @hidden
  78170. */
  78171. _getProperty(propertyPath: string): string;
  78172. /**
  78173. * Internal only
  78174. * @hidden
  78175. */
  78176. _getEffectiveTarget(target: any, propertyPath: string): any;
  78177. /**
  78178. * Serialize placeholder for child classes
  78179. * @returns the serialized object
  78180. */
  78181. serialize(): any;
  78182. /**
  78183. * Internal only
  78184. * @hidden
  78185. */
  78186. protected _serialize(serializedCondition: any): any;
  78187. }
  78188. /**
  78189. * Defines specific conditional operators as extensions of Condition
  78190. */
  78191. export class ValueCondition extends Condition {
  78192. /** path to specify the property of the target the conditional operator uses */
  78193. propertyPath: string;
  78194. /** the value compared by the conditional operator against the current value of the property */
  78195. value: any;
  78196. /** the conditional operator, default ValueCondition.IsEqual */
  78197. operator: number;
  78198. /**
  78199. * Internal only
  78200. * @hidden
  78201. */
  78202. private static _IsEqual;
  78203. /**
  78204. * Internal only
  78205. * @hidden
  78206. */
  78207. private static _IsDifferent;
  78208. /**
  78209. * Internal only
  78210. * @hidden
  78211. */
  78212. private static _IsGreater;
  78213. /**
  78214. * Internal only
  78215. * @hidden
  78216. */
  78217. private static _IsLesser;
  78218. /**
  78219. * returns the number for IsEqual
  78220. */
  78221. static readonly IsEqual: number;
  78222. /**
  78223. * Returns the number for IsDifferent
  78224. */
  78225. static readonly IsDifferent: number;
  78226. /**
  78227. * Returns the number for IsGreater
  78228. */
  78229. static readonly IsGreater: number;
  78230. /**
  78231. * Returns the number for IsLesser
  78232. */
  78233. static readonly IsLesser: number;
  78234. /**
  78235. * Internal only The action manager for the condition
  78236. * @hidden
  78237. */
  78238. _actionManager: ActionManager;
  78239. /**
  78240. * Internal only
  78241. * @hidden
  78242. */
  78243. private _target;
  78244. /**
  78245. * Internal only
  78246. * @hidden
  78247. */
  78248. private _effectiveTarget;
  78249. /**
  78250. * Internal only
  78251. * @hidden
  78252. */
  78253. private _property;
  78254. /**
  78255. * Creates a new ValueCondition
  78256. * @param actionManager manager for the action the condition applies to
  78257. * @param target for the action
  78258. * @param propertyPath path to specify the property of the target the conditional operator uses
  78259. * @param value the value compared by the conditional operator against the current value of the property
  78260. * @param operator the conditional operator, default ValueCondition.IsEqual
  78261. */
  78262. constructor(actionManager: ActionManager, target: any,
  78263. /** path to specify the property of the target the conditional operator uses */
  78264. propertyPath: string,
  78265. /** the value compared by the conditional operator against the current value of the property */
  78266. value: any,
  78267. /** the conditional operator, default ValueCondition.IsEqual */
  78268. operator?: number);
  78269. /**
  78270. * Compares the given value with the property value for the specified conditional operator
  78271. * @returns the result of the comparison
  78272. */
  78273. isValid(): boolean;
  78274. /**
  78275. * Serialize the ValueCondition into a JSON compatible object
  78276. * @returns serialization object
  78277. */
  78278. serialize(): any;
  78279. /**
  78280. * Gets the name of the conditional operator for the ValueCondition
  78281. * @param operator the conditional operator
  78282. * @returns the name
  78283. */
  78284. static GetOperatorName(operator: number): string;
  78285. }
  78286. /**
  78287. * Defines a predicate condition as an extension of Condition
  78288. */
  78289. export class PredicateCondition extends Condition {
  78290. /** defines the predicate function used to validate the condition */
  78291. predicate: () => boolean;
  78292. /**
  78293. * Internal only - manager for action
  78294. * @hidden
  78295. */
  78296. _actionManager: ActionManager;
  78297. /**
  78298. * Creates a new PredicateCondition
  78299. * @param actionManager manager for the action the condition applies to
  78300. * @param predicate defines the predicate function used to validate the condition
  78301. */
  78302. constructor(actionManager: ActionManager,
  78303. /** defines the predicate function used to validate the condition */
  78304. predicate: () => boolean);
  78305. /**
  78306. * @returns the validity of the predicate condition
  78307. */
  78308. isValid(): boolean;
  78309. }
  78310. /**
  78311. * Defines a state condition as an extension of Condition
  78312. */
  78313. export class StateCondition extends Condition {
  78314. /** Value to compare with target state */
  78315. value: string;
  78316. /**
  78317. * Internal only - manager for action
  78318. * @hidden
  78319. */
  78320. _actionManager: ActionManager;
  78321. /**
  78322. * Internal only
  78323. * @hidden
  78324. */
  78325. private _target;
  78326. /**
  78327. * Creates a new StateCondition
  78328. * @param actionManager manager for the action the condition applies to
  78329. * @param target of the condition
  78330. * @param value to compare with target state
  78331. */
  78332. constructor(actionManager: ActionManager, target: any,
  78333. /** Value to compare with target state */
  78334. value: string);
  78335. /**
  78336. * Gets a boolean indicating if the current condition is met
  78337. * @returns the validity of the state
  78338. */
  78339. isValid(): boolean;
  78340. /**
  78341. * Serialize the StateCondition into a JSON compatible object
  78342. * @returns serialization object
  78343. */
  78344. serialize(): any;
  78345. }
  78346. }
  78347. declare module BABYLON {
  78348. /**
  78349. * This defines an action responsible to toggle a boolean once triggered.
  78350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78351. */
  78352. export class SwitchBooleanAction extends Action {
  78353. /**
  78354. * The path to the boolean property in the target object
  78355. */
  78356. propertyPath: string;
  78357. private _target;
  78358. private _effectiveTarget;
  78359. private _property;
  78360. /**
  78361. * Instantiate the action
  78362. * @param triggerOptions defines the trigger options
  78363. * @param target defines the object containing the boolean
  78364. * @param propertyPath defines the path to the boolean property in the target object
  78365. * @param condition defines the trigger related conditions
  78366. */
  78367. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78368. /** @hidden */
  78369. _prepare(): void;
  78370. /**
  78371. * Execute the action toggle the boolean value.
  78372. */
  78373. execute(): void;
  78374. /**
  78375. * Serializes the actions and its related information.
  78376. * @param parent defines the object to serialize in
  78377. * @returns the serialized object
  78378. */
  78379. serialize(parent: any): any;
  78380. }
  78381. /**
  78382. * This defines an action responsible to set a the state field of the target
  78383. * to a desired value once triggered.
  78384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78385. */
  78386. export class SetStateAction extends Action {
  78387. /**
  78388. * The value to store in the state field.
  78389. */
  78390. value: string;
  78391. private _target;
  78392. /**
  78393. * Instantiate the action
  78394. * @param triggerOptions defines the trigger options
  78395. * @param target defines the object containing the state property
  78396. * @param value defines the value to store in the state field
  78397. * @param condition defines the trigger related conditions
  78398. */
  78399. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78400. /**
  78401. * Execute the action and store the value on the target state property.
  78402. */
  78403. execute(): void;
  78404. /**
  78405. * Serializes the actions and its related information.
  78406. * @param parent defines the object to serialize in
  78407. * @returns the serialized object
  78408. */
  78409. serialize(parent: any): any;
  78410. }
  78411. /**
  78412. * This defines an action responsible to set a property of the target
  78413. * to a desired value once triggered.
  78414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78415. */
  78416. export class SetValueAction extends Action {
  78417. /**
  78418. * The path of the property to set in the target.
  78419. */
  78420. propertyPath: string;
  78421. /**
  78422. * The value to set in the property
  78423. */
  78424. value: any;
  78425. private _target;
  78426. private _effectiveTarget;
  78427. private _property;
  78428. /**
  78429. * Instantiate the action
  78430. * @param triggerOptions defines the trigger options
  78431. * @param target defines the object containing the property
  78432. * @param propertyPath defines the path of the property to set in the target
  78433. * @param value defines the value to set in the property
  78434. * @param condition defines the trigger related conditions
  78435. */
  78436. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78437. /** @hidden */
  78438. _prepare(): void;
  78439. /**
  78440. * Execute the action and set the targetted property to the desired value.
  78441. */
  78442. execute(): void;
  78443. /**
  78444. * Serializes the actions and its related information.
  78445. * @param parent defines the object to serialize in
  78446. * @returns the serialized object
  78447. */
  78448. serialize(parent: any): any;
  78449. }
  78450. /**
  78451. * This defines an action responsible to increment the target value
  78452. * to a desired value once triggered.
  78453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78454. */
  78455. export class IncrementValueAction extends Action {
  78456. /**
  78457. * The path of the property to increment in the target.
  78458. */
  78459. propertyPath: string;
  78460. /**
  78461. * The value we should increment the property by.
  78462. */
  78463. value: any;
  78464. private _target;
  78465. private _effectiveTarget;
  78466. private _property;
  78467. /**
  78468. * Instantiate the action
  78469. * @param triggerOptions defines the trigger options
  78470. * @param target defines the object containing the property
  78471. * @param propertyPath defines the path of the property to increment in the target
  78472. * @param value defines the value value we should increment the property by
  78473. * @param condition defines the trigger related conditions
  78474. */
  78475. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78476. /** @hidden */
  78477. _prepare(): void;
  78478. /**
  78479. * Execute the action and increment the target of the value amount.
  78480. */
  78481. execute(): void;
  78482. /**
  78483. * Serializes the actions and its related information.
  78484. * @param parent defines the object to serialize in
  78485. * @returns the serialized object
  78486. */
  78487. serialize(parent: any): any;
  78488. }
  78489. /**
  78490. * This defines an action responsible to start an animation once triggered.
  78491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78492. */
  78493. export class PlayAnimationAction extends Action {
  78494. /**
  78495. * Where the animation should start (animation frame)
  78496. */
  78497. from: number;
  78498. /**
  78499. * Where the animation should stop (animation frame)
  78500. */
  78501. to: number;
  78502. /**
  78503. * Define if the animation should loop or stop after the first play.
  78504. */
  78505. loop?: boolean;
  78506. private _target;
  78507. /**
  78508. * Instantiate the action
  78509. * @param triggerOptions defines the trigger options
  78510. * @param target defines the target animation or animation name
  78511. * @param from defines from where the animation should start (animation frame)
  78512. * @param end defines where the animation should stop (animation frame)
  78513. * @param loop defines if the animation should loop or stop after the first play
  78514. * @param condition defines the trigger related conditions
  78515. */
  78516. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78517. /** @hidden */
  78518. _prepare(): void;
  78519. /**
  78520. * Execute the action and play the animation.
  78521. */
  78522. execute(): void;
  78523. /**
  78524. * Serializes the actions and its related information.
  78525. * @param parent defines the object to serialize in
  78526. * @returns the serialized object
  78527. */
  78528. serialize(parent: any): any;
  78529. }
  78530. /**
  78531. * This defines an action responsible to stop an animation once triggered.
  78532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78533. */
  78534. export class StopAnimationAction extends Action {
  78535. private _target;
  78536. /**
  78537. * Instantiate the action
  78538. * @param triggerOptions defines the trigger options
  78539. * @param target defines the target animation or animation name
  78540. * @param condition defines the trigger related conditions
  78541. */
  78542. constructor(triggerOptions: any, target: any, condition?: Condition);
  78543. /** @hidden */
  78544. _prepare(): void;
  78545. /**
  78546. * Execute the action and stop the animation.
  78547. */
  78548. execute(): void;
  78549. /**
  78550. * Serializes the actions and its related information.
  78551. * @param parent defines the object to serialize in
  78552. * @returns the serialized object
  78553. */
  78554. serialize(parent: any): any;
  78555. }
  78556. /**
  78557. * This defines an action responsible that does nothing once triggered.
  78558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78559. */
  78560. export class DoNothingAction extends Action {
  78561. /**
  78562. * Instantiate the action
  78563. * @param triggerOptions defines the trigger options
  78564. * @param condition defines the trigger related conditions
  78565. */
  78566. constructor(triggerOptions?: any, condition?: Condition);
  78567. /**
  78568. * Execute the action and do nothing.
  78569. */
  78570. execute(): void;
  78571. /**
  78572. * Serializes the actions and its related information.
  78573. * @param parent defines the object to serialize in
  78574. * @returns the serialized object
  78575. */
  78576. serialize(parent: any): any;
  78577. }
  78578. /**
  78579. * This defines an action responsible to trigger several actions once triggered.
  78580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78581. */
  78582. export class CombineAction extends Action {
  78583. /**
  78584. * The list of aggregated animations to run.
  78585. */
  78586. children: Action[];
  78587. /**
  78588. * Instantiate the action
  78589. * @param triggerOptions defines the trigger options
  78590. * @param children defines the list of aggregated animations to run
  78591. * @param condition defines the trigger related conditions
  78592. */
  78593. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78594. /** @hidden */
  78595. _prepare(): void;
  78596. /**
  78597. * Execute the action and executes all the aggregated actions.
  78598. */
  78599. execute(evt: ActionEvent): void;
  78600. /**
  78601. * Serializes the actions and its related information.
  78602. * @param parent defines the object to serialize in
  78603. * @returns the serialized object
  78604. */
  78605. serialize(parent: any): any;
  78606. }
  78607. /**
  78608. * This defines an action responsible to run code (external event) once triggered.
  78609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78610. */
  78611. export class ExecuteCodeAction extends Action {
  78612. /**
  78613. * The callback function to run.
  78614. */
  78615. func: (evt: ActionEvent) => void;
  78616. /**
  78617. * Instantiate the action
  78618. * @param triggerOptions defines the trigger options
  78619. * @param func defines the callback function to run
  78620. * @param condition defines the trigger related conditions
  78621. */
  78622. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78623. /**
  78624. * Execute the action and run the attached code.
  78625. */
  78626. execute(evt: ActionEvent): void;
  78627. }
  78628. /**
  78629. * This defines an action responsible to set the parent property of the target once triggered.
  78630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78631. */
  78632. export class SetParentAction extends Action {
  78633. private _parent;
  78634. private _target;
  78635. /**
  78636. * Instantiate the action
  78637. * @param triggerOptions defines the trigger options
  78638. * @param target defines the target containing the parent property
  78639. * @param parent defines from where the animation should start (animation frame)
  78640. * @param condition defines the trigger related conditions
  78641. */
  78642. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78643. /** @hidden */
  78644. _prepare(): void;
  78645. /**
  78646. * Execute the action and set the parent property.
  78647. */
  78648. execute(): void;
  78649. /**
  78650. * Serializes the actions and its related information.
  78651. * @param parent defines the object to serialize in
  78652. * @returns the serialized object
  78653. */
  78654. serialize(parent: any): any;
  78655. }
  78656. }
  78657. declare module BABYLON {
  78658. /**
  78659. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78660. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78662. */
  78663. export class ActionManager extends AbstractActionManager {
  78664. /**
  78665. * Nothing
  78666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78667. */
  78668. static readonly NothingTrigger: number;
  78669. /**
  78670. * On pick
  78671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78672. */
  78673. static readonly OnPickTrigger: number;
  78674. /**
  78675. * On left pick
  78676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78677. */
  78678. static readonly OnLeftPickTrigger: number;
  78679. /**
  78680. * On right pick
  78681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78682. */
  78683. static readonly OnRightPickTrigger: number;
  78684. /**
  78685. * On center pick
  78686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78687. */
  78688. static readonly OnCenterPickTrigger: number;
  78689. /**
  78690. * On pick down
  78691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78692. */
  78693. static readonly OnPickDownTrigger: number;
  78694. /**
  78695. * On double pick
  78696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78697. */
  78698. static readonly OnDoublePickTrigger: number;
  78699. /**
  78700. * On pick up
  78701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78702. */
  78703. static readonly OnPickUpTrigger: number;
  78704. /**
  78705. * On pick out.
  78706. * This trigger will only be raised if you also declared a OnPickDown
  78707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78708. */
  78709. static readonly OnPickOutTrigger: number;
  78710. /**
  78711. * On long press
  78712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78713. */
  78714. static readonly OnLongPressTrigger: number;
  78715. /**
  78716. * On pointer over
  78717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78718. */
  78719. static readonly OnPointerOverTrigger: number;
  78720. /**
  78721. * On pointer out
  78722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78723. */
  78724. static readonly OnPointerOutTrigger: number;
  78725. /**
  78726. * On every frame
  78727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78728. */
  78729. static readonly OnEveryFrameTrigger: number;
  78730. /**
  78731. * On intersection enter
  78732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78733. */
  78734. static readonly OnIntersectionEnterTrigger: number;
  78735. /**
  78736. * On intersection exit
  78737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78738. */
  78739. static readonly OnIntersectionExitTrigger: number;
  78740. /**
  78741. * On key down
  78742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78743. */
  78744. static readonly OnKeyDownTrigger: number;
  78745. /**
  78746. * On key up
  78747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78748. */
  78749. static readonly OnKeyUpTrigger: number;
  78750. private _scene;
  78751. /**
  78752. * Creates a new action manager
  78753. * @param scene defines the hosting scene
  78754. */
  78755. constructor(scene: Scene);
  78756. /**
  78757. * Releases all associated resources
  78758. */
  78759. dispose(): void;
  78760. /**
  78761. * Gets hosting scene
  78762. * @returns the hosting scene
  78763. */
  78764. getScene(): Scene;
  78765. /**
  78766. * Does this action manager handles actions of any of the given triggers
  78767. * @param triggers defines the triggers to be tested
  78768. * @return a boolean indicating whether one (or more) of the triggers is handled
  78769. */
  78770. hasSpecificTriggers(triggers: number[]): boolean;
  78771. /**
  78772. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78773. * speed.
  78774. * @param triggerA defines the trigger to be tested
  78775. * @param triggerB defines the trigger to be tested
  78776. * @return a boolean indicating whether one (or more) of the triggers is handled
  78777. */
  78778. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78779. /**
  78780. * Does this action manager handles actions of a given trigger
  78781. * @param trigger defines the trigger to be tested
  78782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78783. * @return whether the trigger is handled
  78784. */
  78785. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78786. /**
  78787. * Does this action manager has pointer triggers
  78788. */
  78789. readonly hasPointerTriggers: boolean;
  78790. /**
  78791. * Does this action manager has pick triggers
  78792. */
  78793. readonly hasPickTriggers: boolean;
  78794. /**
  78795. * Registers an action to this action manager
  78796. * @param action defines the action to be registered
  78797. * @return the action amended (prepared) after registration
  78798. */
  78799. registerAction(action: IAction): Nullable<IAction>;
  78800. /**
  78801. * Unregisters an action to this action manager
  78802. * @param action defines the action to be unregistered
  78803. * @return a boolean indicating whether the action has been unregistered
  78804. */
  78805. unregisterAction(action: IAction): Boolean;
  78806. /**
  78807. * Process a specific trigger
  78808. * @param trigger defines the trigger to process
  78809. * @param evt defines the event details to be processed
  78810. */
  78811. processTrigger(trigger: number, evt?: IActionEvent): void;
  78812. /** @hidden */
  78813. _getEffectiveTarget(target: any, propertyPath: string): any;
  78814. /** @hidden */
  78815. _getProperty(propertyPath: string): string;
  78816. /**
  78817. * Serialize this manager to a JSON object
  78818. * @param name defines the property name to store this manager
  78819. * @returns a JSON representation of this manager
  78820. */
  78821. serialize(name: string): any;
  78822. /**
  78823. * Creates a new ActionManager from a JSON data
  78824. * @param parsedActions defines the JSON data to read from
  78825. * @param object defines the hosting mesh
  78826. * @param scene defines the hosting scene
  78827. */
  78828. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78829. /**
  78830. * Get a trigger name by index
  78831. * @param trigger defines the trigger index
  78832. * @returns a trigger name
  78833. */
  78834. static GetTriggerName(trigger: number): string;
  78835. }
  78836. }
  78837. declare module BABYLON {
  78838. /**
  78839. * Class representing a ray with position and direction
  78840. */
  78841. export class Ray {
  78842. /** origin point */
  78843. origin: Vector3;
  78844. /** direction */
  78845. direction: Vector3;
  78846. /** length of the ray */
  78847. length: number;
  78848. private static readonly TmpVector3;
  78849. private _tmpRay;
  78850. /**
  78851. * Creates a new ray
  78852. * @param origin origin point
  78853. * @param direction direction
  78854. * @param length length of the ray
  78855. */
  78856. constructor(
  78857. /** origin point */
  78858. origin: Vector3,
  78859. /** direction */
  78860. direction: Vector3,
  78861. /** length of the ray */
  78862. length?: number);
  78863. /**
  78864. * Checks if the ray intersects a box
  78865. * @param minimum bound of the box
  78866. * @param maximum bound of the box
  78867. * @param intersectionTreshold extra extend to be added to the box in all direction
  78868. * @returns if the box was hit
  78869. */
  78870. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78871. /**
  78872. * Checks if the ray intersects a box
  78873. * @param box the bounding box to check
  78874. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78875. * @returns if the box was hit
  78876. */
  78877. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78878. /**
  78879. * If the ray hits a sphere
  78880. * @param sphere the bounding sphere to check
  78881. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78882. * @returns true if it hits the sphere
  78883. */
  78884. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78885. /**
  78886. * If the ray hits a triange
  78887. * @param vertex0 triangle vertex
  78888. * @param vertex1 triangle vertex
  78889. * @param vertex2 triangle vertex
  78890. * @returns intersection information if hit
  78891. */
  78892. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78893. /**
  78894. * Checks if ray intersects a plane
  78895. * @param plane the plane to check
  78896. * @returns the distance away it was hit
  78897. */
  78898. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78899. /**
  78900. * Checks if ray intersects a mesh
  78901. * @param mesh the mesh to check
  78902. * @param fastCheck if only the bounding box should checked
  78903. * @returns picking info of the intersecton
  78904. */
  78905. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78906. /**
  78907. * Checks if ray intersects a mesh
  78908. * @param meshes the meshes to check
  78909. * @param fastCheck if only the bounding box should checked
  78910. * @param results array to store result in
  78911. * @returns Array of picking infos
  78912. */
  78913. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78914. private _comparePickingInfo;
  78915. private static smallnum;
  78916. private static rayl;
  78917. /**
  78918. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78919. * @param sega the first point of the segment to test the intersection against
  78920. * @param segb the second point of the segment to test the intersection against
  78921. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78922. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78923. */
  78924. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78925. /**
  78926. * Update the ray from viewport position
  78927. * @param x position
  78928. * @param y y position
  78929. * @param viewportWidth viewport width
  78930. * @param viewportHeight viewport height
  78931. * @param world world matrix
  78932. * @param view view matrix
  78933. * @param projection projection matrix
  78934. * @returns this ray updated
  78935. */
  78936. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78937. /**
  78938. * Creates a ray with origin and direction of 0,0,0
  78939. * @returns the new ray
  78940. */
  78941. static Zero(): Ray;
  78942. /**
  78943. * Creates a new ray from screen space and viewport
  78944. * @param x position
  78945. * @param y y position
  78946. * @param viewportWidth viewport width
  78947. * @param viewportHeight viewport height
  78948. * @param world world matrix
  78949. * @param view view matrix
  78950. * @param projection projection matrix
  78951. * @returns new ray
  78952. */
  78953. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78954. /**
  78955. * 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
  78956. * transformed to the given world matrix.
  78957. * @param origin The origin point
  78958. * @param end The end point
  78959. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78960. * @returns the new ray
  78961. */
  78962. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78963. /**
  78964. * Transforms a ray by a matrix
  78965. * @param ray ray to transform
  78966. * @param matrix matrix to apply
  78967. * @returns the resulting new ray
  78968. */
  78969. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78970. /**
  78971. * Transforms a ray by a matrix
  78972. * @param ray ray to transform
  78973. * @param matrix matrix to apply
  78974. * @param result ray to store result in
  78975. */
  78976. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78977. /**
  78978. * Unproject a ray from screen space to object space
  78979. * @param sourceX defines the screen space x coordinate to use
  78980. * @param sourceY defines the screen space y coordinate to use
  78981. * @param viewportWidth defines the current width of the viewport
  78982. * @param viewportHeight defines the current height of the viewport
  78983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78984. * @param view defines the view matrix to use
  78985. * @param projection defines the projection matrix to use
  78986. */
  78987. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78988. }
  78989. /**
  78990. * Type used to define predicate used to select faces when a mesh intersection is detected
  78991. */
  78992. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78993. interface Scene {
  78994. /** @hidden */
  78995. _tempPickingRay: Nullable<Ray>;
  78996. /** @hidden */
  78997. _cachedRayForTransform: Ray;
  78998. /** @hidden */
  78999. _pickWithRayInverseMatrix: Matrix;
  79000. /** @hidden */
  79001. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79002. /** @hidden */
  79003. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79004. }
  79005. }
  79006. declare module BABYLON {
  79007. interface Scene {
  79008. /** @hidden */
  79009. _pointerOverSprite: Nullable<Sprite>;
  79010. /** @hidden */
  79011. _pickedDownSprite: Nullable<Sprite>;
  79012. /** @hidden */
  79013. _tempSpritePickingRay: Nullable<Ray>;
  79014. /**
  79015. * All of the sprite managers added to this scene
  79016. * @see http://doc.babylonjs.com/babylon101/sprites
  79017. */
  79018. spriteManagers: Array<ISpriteManager>;
  79019. /**
  79020. * An event triggered when sprites rendering is about to start
  79021. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79022. */
  79023. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79024. /**
  79025. * An event triggered when sprites rendering is done
  79026. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79027. */
  79028. onAfterSpritesRenderingObservable: Observable<Scene>;
  79029. /** @hidden */
  79030. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79031. /** Launch a ray to try to pick a sprite in the scene
  79032. * @param x position on screen
  79033. * @param y position on screen
  79034. * @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
  79035. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79036. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79037. * @returns a PickingInfo
  79038. */
  79039. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79040. /** Use the given ray to pick a sprite in the scene
  79041. * @param ray The ray (in world space) to use to pick meshes
  79042. * @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
  79043. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79044. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79045. * @returns a PickingInfo
  79046. */
  79047. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79048. /**
  79049. * Force the sprite under the pointer
  79050. * @param sprite defines the sprite to use
  79051. */
  79052. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79053. /**
  79054. * Gets the sprite under the pointer
  79055. * @returns a Sprite or null if no sprite is under the pointer
  79056. */
  79057. getPointerOverSprite(): Nullable<Sprite>;
  79058. }
  79059. /**
  79060. * Defines the sprite scene component responsible to manage sprites
  79061. * in a given scene.
  79062. */
  79063. export class SpriteSceneComponent implements ISceneComponent {
  79064. /**
  79065. * The component name helpfull to identify the component in the list of scene components.
  79066. */
  79067. readonly name: string;
  79068. /**
  79069. * The scene the component belongs to.
  79070. */
  79071. scene: Scene;
  79072. /** @hidden */
  79073. private _spritePredicate;
  79074. /**
  79075. * Creates a new instance of the component for the given scene
  79076. * @param scene Defines the scene to register the component in
  79077. */
  79078. constructor(scene: Scene);
  79079. /**
  79080. * Registers the component in a given scene
  79081. */
  79082. register(): void;
  79083. /**
  79084. * Rebuilds the elements related to this component in case of
  79085. * context lost for instance.
  79086. */
  79087. rebuild(): void;
  79088. /**
  79089. * Disposes the component and the associated ressources.
  79090. */
  79091. dispose(): void;
  79092. private _pickSpriteButKeepRay;
  79093. private _pointerMove;
  79094. private _pointerDown;
  79095. private _pointerUp;
  79096. }
  79097. }
  79098. declare module BABYLON {
  79099. /** @hidden */
  79100. export var fogFragmentDeclaration: {
  79101. name: string;
  79102. shader: string;
  79103. };
  79104. }
  79105. declare module BABYLON {
  79106. /** @hidden */
  79107. export var fogFragment: {
  79108. name: string;
  79109. shader: string;
  79110. };
  79111. }
  79112. declare module BABYLON {
  79113. /** @hidden */
  79114. export var spritesPixelShader: {
  79115. name: string;
  79116. shader: string;
  79117. };
  79118. }
  79119. declare module BABYLON {
  79120. /** @hidden */
  79121. export var fogVertexDeclaration: {
  79122. name: string;
  79123. shader: string;
  79124. };
  79125. }
  79126. declare module BABYLON {
  79127. /** @hidden */
  79128. export var spritesVertexShader: {
  79129. name: string;
  79130. shader: string;
  79131. };
  79132. }
  79133. declare module BABYLON {
  79134. /**
  79135. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79136. */
  79137. export interface ISpriteManager extends IDisposable {
  79138. /**
  79139. * Restricts the camera to viewing objects with the same layerMask.
  79140. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79141. */
  79142. layerMask: number;
  79143. /**
  79144. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79145. */
  79146. isPickable: boolean;
  79147. /**
  79148. * Specifies the rendering group id for this mesh (0 by default)
  79149. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79150. */
  79151. renderingGroupId: number;
  79152. /**
  79153. * Defines the list of sprites managed by the manager.
  79154. */
  79155. sprites: Array<Sprite>;
  79156. /**
  79157. * Tests the intersection of a sprite with a specific ray.
  79158. * @param ray The ray we are sending to test the collision
  79159. * @param camera The camera space we are sending rays in
  79160. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79161. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79162. * @returns picking info or null.
  79163. */
  79164. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79165. /**
  79166. * Renders the list of sprites on screen.
  79167. */
  79168. render(): void;
  79169. }
  79170. /**
  79171. * Class used to manage multiple sprites on the same spritesheet
  79172. * @see http://doc.babylonjs.com/babylon101/sprites
  79173. */
  79174. export class SpriteManager implements ISpriteManager {
  79175. /** defines the manager's name */
  79176. name: string;
  79177. /** Gets the list of sprites */
  79178. sprites: Sprite[];
  79179. /** Gets or sets the rendering group id (0 by default) */
  79180. renderingGroupId: number;
  79181. /** Gets or sets camera layer mask */
  79182. layerMask: number;
  79183. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79184. fogEnabled: boolean;
  79185. /** Gets or sets a boolean indicating if the sprites are pickable */
  79186. isPickable: boolean;
  79187. /** Defines the default width of a cell in the spritesheet */
  79188. cellWidth: number;
  79189. /** Defines the default height of a cell in the spritesheet */
  79190. cellHeight: number;
  79191. /**
  79192. * An event triggered when the manager is disposed.
  79193. */
  79194. onDisposeObservable: Observable<SpriteManager>;
  79195. private _onDisposeObserver;
  79196. /**
  79197. * Callback called when the manager is disposed
  79198. */
  79199. onDispose: () => void;
  79200. private _capacity;
  79201. private _spriteTexture;
  79202. private _epsilon;
  79203. private _scene;
  79204. private _vertexData;
  79205. private _buffer;
  79206. private _vertexBuffers;
  79207. private _indexBuffer;
  79208. private _effectBase;
  79209. private _effectFog;
  79210. /**
  79211. * Gets or sets the spritesheet texture
  79212. */
  79213. texture: Texture;
  79214. /**
  79215. * Creates a new sprite manager
  79216. * @param name defines the manager's name
  79217. * @param imgUrl defines the sprite sheet url
  79218. * @param capacity defines the maximum allowed number of sprites
  79219. * @param cellSize defines the size of a sprite cell
  79220. * @param scene defines the hosting scene
  79221. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79222. * @param samplingMode defines the smapling mode to use with spritesheet
  79223. */
  79224. constructor(
  79225. /** defines the manager's name */
  79226. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  79227. private _appendSpriteVertex;
  79228. /**
  79229. * Intersects the sprites with a ray
  79230. * @param ray defines the ray to intersect with
  79231. * @param camera defines the current active camera
  79232. * @param predicate defines a predicate used to select candidate sprites
  79233. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79234. * @returns null if no hit or a PickingInfo
  79235. */
  79236. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79237. /**
  79238. * Render all child sprites
  79239. */
  79240. render(): void;
  79241. /**
  79242. * Release associated resources
  79243. */
  79244. dispose(): void;
  79245. }
  79246. }
  79247. declare module BABYLON {
  79248. /**
  79249. * Class used to represent a sprite
  79250. * @see http://doc.babylonjs.com/babylon101/sprites
  79251. */
  79252. export class Sprite {
  79253. /** defines the name */
  79254. name: string;
  79255. /** Gets or sets the current world position */
  79256. position: Vector3;
  79257. /** Gets or sets the main color */
  79258. color: Color4;
  79259. /** Gets or sets the width */
  79260. width: number;
  79261. /** Gets or sets the height */
  79262. height: number;
  79263. /** Gets or sets rotation angle */
  79264. angle: number;
  79265. /** Gets or sets the cell index in the sprite sheet */
  79266. cellIndex: number;
  79267. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79268. invertU: number;
  79269. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79270. invertV: number;
  79271. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79272. disposeWhenFinishedAnimating: boolean;
  79273. /** Gets the list of attached animations */
  79274. animations: Animation[];
  79275. /** Gets or sets a boolean indicating if the sprite can be picked */
  79276. isPickable: boolean;
  79277. /**
  79278. * Gets or sets the associated action manager
  79279. */
  79280. actionManager: Nullable<ActionManager>;
  79281. private _animationStarted;
  79282. private _loopAnimation;
  79283. private _fromIndex;
  79284. private _toIndex;
  79285. private _delay;
  79286. private _direction;
  79287. private _manager;
  79288. private _time;
  79289. private _onAnimationEnd;
  79290. /**
  79291. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79292. */
  79293. isVisible: boolean;
  79294. /**
  79295. * Gets or sets the sprite size
  79296. */
  79297. size: number;
  79298. /**
  79299. * Creates a new Sprite
  79300. * @param name defines the name
  79301. * @param manager defines the manager
  79302. */
  79303. constructor(
  79304. /** defines the name */
  79305. name: string, manager: ISpriteManager);
  79306. /**
  79307. * Starts an animation
  79308. * @param from defines the initial key
  79309. * @param to defines the end key
  79310. * @param loop defines if the animation must loop
  79311. * @param delay defines the start delay (in ms)
  79312. * @param onAnimationEnd defines a callback to call when animation ends
  79313. */
  79314. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79315. /** Stops current animation (if any) */
  79316. stopAnimation(): void;
  79317. /** @hidden */
  79318. _animate(deltaTime: number): void;
  79319. /** Release associated resources */
  79320. dispose(): void;
  79321. }
  79322. }
  79323. declare module BABYLON {
  79324. /**
  79325. * Information about the result of picking within a scene
  79326. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79327. */
  79328. export class PickingInfo {
  79329. /** @hidden */
  79330. _pickingUnavailable: boolean;
  79331. /**
  79332. * If the pick collided with an object
  79333. */
  79334. hit: boolean;
  79335. /**
  79336. * Distance away where the pick collided
  79337. */
  79338. distance: number;
  79339. /**
  79340. * The location of pick collision
  79341. */
  79342. pickedPoint: Nullable<Vector3>;
  79343. /**
  79344. * The mesh corresponding the the pick collision
  79345. */
  79346. pickedMesh: Nullable<AbstractMesh>;
  79347. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79348. bu: number;
  79349. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79350. bv: number;
  79351. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79352. faceId: number;
  79353. /** Id of the the submesh that was picked */
  79354. subMeshId: number;
  79355. /** If a sprite was picked, this will be the sprite the pick collided with */
  79356. pickedSprite: Nullable<Sprite>;
  79357. /**
  79358. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79359. */
  79360. originMesh: Nullable<AbstractMesh>;
  79361. /**
  79362. * The ray that was used to perform the picking.
  79363. */
  79364. ray: Nullable<Ray>;
  79365. /**
  79366. * Gets the normal correspodning to the face the pick collided with
  79367. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79368. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79369. * @returns The normal correspodning to the face the pick collided with
  79370. */
  79371. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79372. /**
  79373. * Gets the texture coordinates of where the pick occured
  79374. * @returns the vector containing the coordnates of the texture
  79375. */
  79376. getTextureCoordinates(): Nullable<Vector2>;
  79377. }
  79378. }
  79379. declare module BABYLON {
  79380. /**
  79381. * Gather the list of pointer event types as constants.
  79382. */
  79383. export class PointerEventTypes {
  79384. /**
  79385. * 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.
  79386. */
  79387. static readonly POINTERDOWN: number;
  79388. /**
  79389. * The pointerup event is fired when a pointer is no longer active.
  79390. */
  79391. static readonly POINTERUP: number;
  79392. /**
  79393. * The pointermove event is fired when a pointer changes coordinates.
  79394. */
  79395. static readonly POINTERMOVE: number;
  79396. /**
  79397. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79398. */
  79399. static readonly POINTERWHEEL: number;
  79400. /**
  79401. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79402. */
  79403. static readonly POINTERPICK: number;
  79404. /**
  79405. * The pointertap event is fired when a the object has been touched and released without drag.
  79406. */
  79407. static readonly POINTERTAP: number;
  79408. /**
  79409. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79410. */
  79411. static readonly POINTERDOUBLETAP: number;
  79412. }
  79413. /**
  79414. * Base class of pointer info types.
  79415. */
  79416. export class PointerInfoBase {
  79417. /**
  79418. * Defines the type of event (PointerEventTypes)
  79419. */
  79420. type: number;
  79421. /**
  79422. * Defines the related dom event
  79423. */
  79424. event: PointerEvent | MouseWheelEvent;
  79425. /**
  79426. * Instantiates the base class of pointers info.
  79427. * @param type Defines the type of event (PointerEventTypes)
  79428. * @param event Defines the related dom event
  79429. */
  79430. constructor(
  79431. /**
  79432. * Defines the type of event (PointerEventTypes)
  79433. */
  79434. type: number,
  79435. /**
  79436. * Defines the related dom event
  79437. */
  79438. event: PointerEvent | MouseWheelEvent);
  79439. }
  79440. /**
  79441. * This class is used to store pointer related info for the onPrePointerObservable event.
  79442. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79443. */
  79444. export class PointerInfoPre extends PointerInfoBase {
  79445. /**
  79446. * Ray from a pointer if availible (eg. 6dof controller)
  79447. */
  79448. ray: Nullable<Ray>;
  79449. /**
  79450. * Defines the local position of the pointer on the canvas.
  79451. */
  79452. localPosition: Vector2;
  79453. /**
  79454. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79455. */
  79456. skipOnPointerObservable: boolean;
  79457. /**
  79458. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79459. * @param type Defines the type of event (PointerEventTypes)
  79460. * @param event Defines the related dom event
  79461. * @param localX Defines the local x coordinates of the pointer when the event occured
  79462. * @param localY Defines the local y coordinates of the pointer when the event occured
  79463. */
  79464. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79465. }
  79466. /**
  79467. * This type contains all the data related to a pointer event in Babylon.js.
  79468. * 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.
  79469. */
  79470. export class PointerInfo extends PointerInfoBase {
  79471. /**
  79472. * Defines the picking info associated to the info (if any)\
  79473. */
  79474. pickInfo: Nullable<PickingInfo>;
  79475. /**
  79476. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79477. * @param type Defines the type of event (PointerEventTypes)
  79478. * @param event Defines the related dom event
  79479. * @param pickInfo Defines the picking info associated to the info (if any)\
  79480. */
  79481. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79482. /**
  79483. * Defines the picking info associated to the info (if any)\
  79484. */
  79485. pickInfo: Nullable<PickingInfo>);
  79486. }
  79487. /**
  79488. * Data relating to a touch event on the screen.
  79489. */
  79490. export interface PointerTouch {
  79491. /**
  79492. * X coordinate of touch.
  79493. */
  79494. x: number;
  79495. /**
  79496. * Y coordinate of touch.
  79497. */
  79498. y: number;
  79499. /**
  79500. * Id of touch. Unique for each finger.
  79501. */
  79502. pointerId: number;
  79503. /**
  79504. * Event type passed from DOM.
  79505. */
  79506. type: any;
  79507. }
  79508. }
  79509. declare module BABYLON {
  79510. /**
  79511. * Manage the mouse inputs to control the movement of a free camera.
  79512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79513. */
  79514. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79515. /**
  79516. * Define if touch is enabled in the mouse input
  79517. */
  79518. touchEnabled: boolean;
  79519. /**
  79520. * Defines the camera the input is attached to.
  79521. */
  79522. camera: FreeCamera;
  79523. /**
  79524. * Defines the buttons associated with the input to handle camera move.
  79525. */
  79526. buttons: number[];
  79527. /**
  79528. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79529. */
  79530. angularSensibility: number;
  79531. private _pointerInput;
  79532. private _onMouseMove;
  79533. private _observer;
  79534. private previousPosition;
  79535. /**
  79536. * Observable for when a pointer move event occurs containing the move offset
  79537. */
  79538. onPointerMovedObservable: Observable<{
  79539. offsetX: number;
  79540. offsetY: number;
  79541. }>;
  79542. /**
  79543. * @hidden
  79544. * If the camera should be rotated automatically based on pointer movement
  79545. */
  79546. _allowCameraRotation: boolean;
  79547. /**
  79548. * Manage the mouse inputs to control the movement of a free camera.
  79549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79550. * @param touchEnabled Defines if touch is enabled or not
  79551. */
  79552. constructor(
  79553. /**
  79554. * Define if touch is enabled in the mouse input
  79555. */
  79556. touchEnabled?: boolean);
  79557. /**
  79558. * Attach the input controls to a specific dom element to get the input from.
  79559. * @param element Defines the element the controls should be listened from
  79560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79561. */
  79562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79563. /**
  79564. * Called on JS contextmenu event.
  79565. * Override this method to provide functionality.
  79566. */
  79567. protected onContextMenu(evt: PointerEvent): void;
  79568. /**
  79569. * Detach the current controls from the specified dom element.
  79570. * @param element Defines the element to stop listening the inputs from
  79571. */
  79572. detachControl(element: Nullable<HTMLElement>): void;
  79573. /**
  79574. * Gets the class name of the current intput.
  79575. * @returns the class name
  79576. */
  79577. getClassName(): string;
  79578. /**
  79579. * Get the friendly name associated with the input class.
  79580. * @returns the input friendly name
  79581. */
  79582. getSimpleName(): string;
  79583. }
  79584. }
  79585. declare module BABYLON {
  79586. /**
  79587. * Manage the touch inputs to control the movement of a free camera.
  79588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79589. */
  79590. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79591. /**
  79592. * Defines the camera the input is attached to.
  79593. */
  79594. camera: FreeCamera;
  79595. /**
  79596. * Defines the touch sensibility for rotation.
  79597. * The higher the faster.
  79598. */
  79599. touchAngularSensibility: number;
  79600. /**
  79601. * Defines the touch sensibility for move.
  79602. * The higher the faster.
  79603. */
  79604. touchMoveSensibility: number;
  79605. private _offsetX;
  79606. private _offsetY;
  79607. private _pointerPressed;
  79608. private _pointerInput;
  79609. private _observer;
  79610. private _onLostFocus;
  79611. /**
  79612. * Attach the input controls to a specific dom element to get the input from.
  79613. * @param element Defines the element the controls should be listened from
  79614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79615. */
  79616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79617. /**
  79618. * Detach the current controls from the specified dom element.
  79619. * @param element Defines the element to stop listening the inputs from
  79620. */
  79621. detachControl(element: Nullable<HTMLElement>): void;
  79622. /**
  79623. * Update the current camera state depending on the inputs that have been used this frame.
  79624. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79625. */
  79626. checkInputs(): void;
  79627. /**
  79628. * Gets the class name of the current intput.
  79629. * @returns the class name
  79630. */
  79631. getClassName(): string;
  79632. /**
  79633. * Get the friendly name associated with the input class.
  79634. * @returns the input friendly name
  79635. */
  79636. getSimpleName(): string;
  79637. }
  79638. }
  79639. declare module BABYLON {
  79640. /**
  79641. * Default Inputs manager for the FreeCamera.
  79642. * It groups all the default supported inputs for ease of use.
  79643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79644. */
  79645. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79646. /**
  79647. * @hidden
  79648. */
  79649. _mouseInput: Nullable<FreeCameraMouseInput>;
  79650. /**
  79651. * Instantiates a new FreeCameraInputsManager.
  79652. * @param camera Defines the camera the inputs belong to
  79653. */
  79654. constructor(camera: FreeCamera);
  79655. /**
  79656. * Add keyboard input support to the input manager.
  79657. * @returns the current input manager
  79658. */
  79659. addKeyboard(): FreeCameraInputsManager;
  79660. /**
  79661. * Add mouse input support to the input manager.
  79662. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79663. * @returns the current input manager
  79664. */
  79665. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79666. /**
  79667. * Removes the mouse input support from the manager
  79668. * @returns the current input manager
  79669. */
  79670. removeMouse(): FreeCameraInputsManager;
  79671. /**
  79672. * Add touch input support to the input manager.
  79673. * @returns the current input manager
  79674. */
  79675. addTouch(): FreeCameraInputsManager;
  79676. /**
  79677. * Remove all attached input methods from a camera
  79678. */
  79679. clear(): void;
  79680. }
  79681. }
  79682. declare module BABYLON {
  79683. /**
  79684. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79685. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79686. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79687. */
  79688. export class FreeCamera extends TargetCamera {
  79689. /**
  79690. * Define the collision ellipsoid of the camera.
  79691. * This is helpful to simulate a camera body like the player body around the camera
  79692. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79693. */
  79694. ellipsoid: Vector3;
  79695. /**
  79696. * Define an offset for the position of the ellipsoid around the camera.
  79697. * This can be helpful to determine the center of the body near the gravity center of the body
  79698. * instead of its head.
  79699. */
  79700. ellipsoidOffset: Vector3;
  79701. /**
  79702. * Enable or disable collisions of the camera with the rest of the scene objects.
  79703. */
  79704. checkCollisions: boolean;
  79705. /**
  79706. * Enable or disable gravity on the camera.
  79707. */
  79708. applyGravity: boolean;
  79709. /**
  79710. * Define the input manager associated to the camera.
  79711. */
  79712. inputs: FreeCameraInputsManager;
  79713. /**
  79714. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79715. * Higher values reduce sensitivity.
  79716. */
  79717. /**
  79718. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79719. * Higher values reduce sensitivity.
  79720. */
  79721. angularSensibility: number;
  79722. /**
  79723. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79724. */
  79725. keysUp: number[];
  79726. /**
  79727. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79728. */
  79729. keysDown: number[];
  79730. /**
  79731. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79732. */
  79733. keysLeft: number[];
  79734. /**
  79735. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79736. */
  79737. keysRight: number[];
  79738. /**
  79739. * Event raised when the camera collide with a mesh in the scene.
  79740. */
  79741. onCollide: (collidedMesh: AbstractMesh) => void;
  79742. private _collider;
  79743. private _needMoveForGravity;
  79744. private _oldPosition;
  79745. private _diffPosition;
  79746. private _newPosition;
  79747. /** @hidden */
  79748. _localDirection: Vector3;
  79749. /** @hidden */
  79750. _transformedDirection: Vector3;
  79751. /**
  79752. * Instantiates a Free Camera.
  79753. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79754. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79755. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79756. * @param name Define the name of the camera in the scene
  79757. * @param position Define the start position of the camera in the scene
  79758. * @param scene Define the scene the camera belongs to
  79759. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79760. */
  79761. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79762. /**
  79763. * Attached controls to the current camera.
  79764. * @param element Defines the element the controls should be listened from
  79765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79766. */
  79767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79768. /**
  79769. * Detach the current controls from the camera.
  79770. * The camera will stop reacting to inputs.
  79771. * @param element Defines the element to stop listening the inputs from
  79772. */
  79773. detachControl(element: HTMLElement): void;
  79774. private _collisionMask;
  79775. /**
  79776. * Define a collision mask to limit the list of object the camera can collide with
  79777. */
  79778. collisionMask: number;
  79779. /** @hidden */
  79780. _collideWithWorld(displacement: Vector3): void;
  79781. private _onCollisionPositionChange;
  79782. /** @hidden */
  79783. _checkInputs(): void;
  79784. /** @hidden */
  79785. _decideIfNeedsToMove(): boolean;
  79786. /** @hidden */
  79787. _updatePosition(): void;
  79788. /**
  79789. * Destroy the camera and release the current resources hold by it.
  79790. */
  79791. dispose(): void;
  79792. /**
  79793. * Gets the current object class name.
  79794. * @return the class name
  79795. */
  79796. getClassName(): string;
  79797. }
  79798. }
  79799. declare module BABYLON {
  79800. /**
  79801. * Represents a gamepad control stick position
  79802. */
  79803. export class StickValues {
  79804. /**
  79805. * The x component of the control stick
  79806. */
  79807. x: number;
  79808. /**
  79809. * The y component of the control stick
  79810. */
  79811. y: number;
  79812. /**
  79813. * Initializes the gamepad x and y control stick values
  79814. * @param x The x component of the gamepad control stick value
  79815. * @param y The y component of the gamepad control stick value
  79816. */
  79817. constructor(
  79818. /**
  79819. * The x component of the control stick
  79820. */
  79821. x: number,
  79822. /**
  79823. * The y component of the control stick
  79824. */
  79825. y: number);
  79826. }
  79827. /**
  79828. * An interface which manages callbacks for gamepad button changes
  79829. */
  79830. export interface GamepadButtonChanges {
  79831. /**
  79832. * Called when a gamepad has been changed
  79833. */
  79834. changed: boolean;
  79835. /**
  79836. * Called when a gamepad press event has been triggered
  79837. */
  79838. pressChanged: boolean;
  79839. /**
  79840. * Called when a touch event has been triggered
  79841. */
  79842. touchChanged: boolean;
  79843. /**
  79844. * Called when a value has changed
  79845. */
  79846. valueChanged: boolean;
  79847. }
  79848. /**
  79849. * Represents a gamepad
  79850. */
  79851. export class Gamepad {
  79852. /**
  79853. * The id of the gamepad
  79854. */
  79855. id: string;
  79856. /**
  79857. * The index of the gamepad
  79858. */
  79859. index: number;
  79860. /**
  79861. * The browser gamepad
  79862. */
  79863. browserGamepad: any;
  79864. /**
  79865. * Specifies what type of gamepad this represents
  79866. */
  79867. type: number;
  79868. private _leftStick;
  79869. private _rightStick;
  79870. /** @hidden */
  79871. _isConnected: boolean;
  79872. private _leftStickAxisX;
  79873. private _leftStickAxisY;
  79874. private _rightStickAxisX;
  79875. private _rightStickAxisY;
  79876. /**
  79877. * Triggered when the left control stick has been changed
  79878. */
  79879. private _onleftstickchanged;
  79880. /**
  79881. * Triggered when the right control stick has been changed
  79882. */
  79883. private _onrightstickchanged;
  79884. /**
  79885. * Represents a gamepad controller
  79886. */
  79887. static GAMEPAD: number;
  79888. /**
  79889. * Represents a generic controller
  79890. */
  79891. static GENERIC: number;
  79892. /**
  79893. * Represents an XBox controller
  79894. */
  79895. static XBOX: number;
  79896. /**
  79897. * Represents a pose-enabled controller
  79898. */
  79899. static POSE_ENABLED: number;
  79900. /**
  79901. * Specifies whether the left control stick should be Y-inverted
  79902. */
  79903. protected _invertLeftStickY: boolean;
  79904. /**
  79905. * Specifies if the gamepad has been connected
  79906. */
  79907. readonly isConnected: boolean;
  79908. /**
  79909. * Initializes the gamepad
  79910. * @param id The id of the gamepad
  79911. * @param index The index of the gamepad
  79912. * @param browserGamepad The browser gamepad
  79913. * @param leftStickX The x component of the left joystick
  79914. * @param leftStickY The y component of the left joystick
  79915. * @param rightStickX The x component of the right joystick
  79916. * @param rightStickY The y component of the right joystick
  79917. */
  79918. constructor(
  79919. /**
  79920. * The id of the gamepad
  79921. */
  79922. id: string,
  79923. /**
  79924. * The index of the gamepad
  79925. */
  79926. index: number,
  79927. /**
  79928. * The browser gamepad
  79929. */
  79930. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79931. /**
  79932. * Callback triggered when the left joystick has changed
  79933. * @param callback
  79934. */
  79935. onleftstickchanged(callback: (values: StickValues) => void): void;
  79936. /**
  79937. * Callback triggered when the right joystick has changed
  79938. * @param callback
  79939. */
  79940. onrightstickchanged(callback: (values: StickValues) => void): void;
  79941. /**
  79942. * Gets the left joystick
  79943. */
  79944. /**
  79945. * Sets the left joystick values
  79946. */
  79947. leftStick: StickValues;
  79948. /**
  79949. * Gets the right joystick
  79950. */
  79951. /**
  79952. * Sets the right joystick value
  79953. */
  79954. rightStick: StickValues;
  79955. /**
  79956. * Updates the gamepad joystick positions
  79957. */
  79958. update(): void;
  79959. /**
  79960. * Disposes the gamepad
  79961. */
  79962. dispose(): void;
  79963. }
  79964. /**
  79965. * Represents a generic gamepad
  79966. */
  79967. export class GenericPad extends Gamepad {
  79968. private _buttons;
  79969. private _onbuttondown;
  79970. private _onbuttonup;
  79971. /**
  79972. * Observable triggered when a button has been pressed
  79973. */
  79974. onButtonDownObservable: Observable<number>;
  79975. /**
  79976. * Observable triggered when a button has been released
  79977. */
  79978. onButtonUpObservable: Observable<number>;
  79979. /**
  79980. * Callback triggered when a button has been pressed
  79981. * @param callback Called when a button has been pressed
  79982. */
  79983. onbuttondown(callback: (buttonPressed: number) => void): void;
  79984. /**
  79985. * Callback triggered when a button has been released
  79986. * @param callback Called when a button has been released
  79987. */
  79988. onbuttonup(callback: (buttonReleased: number) => void): void;
  79989. /**
  79990. * Initializes the generic gamepad
  79991. * @param id The id of the generic gamepad
  79992. * @param index The index of the generic gamepad
  79993. * @param browserGamepad The browser gamepad
  79994. */
  79995. constructor(id: string, index: number, browserGamepad: any);
  79996. private _setButtonValue;
  79997. /**
  79998. * Updates the generic gamepad
  79999. */
  80000. update(): void;
  80001. /**
  80002. * Disposes the generic gamepad
  80003. */
  80004. dispose(): void;
  80005. }
  80006. }
  80007. declare module BABYLON {
  80008. /**
  80009. * Defines the types of pose enabled controllers that are supported
  80010. */
  80011. export enum PoseEnabledControllerType {
  80012. /**
  80013. * HTC Vive
  80014. */
  80015. VIVE = 0,
  80016. /**
  80017. * Oculus Rift
  80018. */
  80019. OCULUS = 1,
  80020. /**
  80021. * Windows mixed reality
  80022. */
  80023. WINDOWS = 2,
  80024. /**
  80025. * Samsung gear VR
  80026. */
  80027. GEAR_VR = 3,
  80028. /**
  80029. * Google Daydream
  80030. */
  80031. DAYDREAM = 4,
  80032. /**
  80033. * Generic
  80034. */
  80035. GENERIC = 5
  80036. }
  80037. /**
  80038. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80039. */
  80040. export interface MutableGamepadButton {
  80041. /**
  80042. * Value of the button/trigger
  80043. */
  80044. value: number;
  80045. /**
  80046. * If the button/trigger is currently touched
  80047. */
  80048. touched: boolean;
  80049. /**
  80050. * If the button/trigger is currently pressed
  80051. */
  80052. pressed: boolean;
  80053. }
  80054. /**
  80055. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80056. * @hidden
  80057. */
  80058. export interface ExtendedGamepadButton extends GamepadButton {
  80059. /**
  80060. * If the button/trigger is currently pressed
  80061. */
  80062. readonly pressed: boolean;
  80063. /**
  80064. * If the button/trigger is currently touched
  80065. */
  80066. readonly touched: boolean;
  80067. /**
  80068. * Value of the button/trigger
  80069. */
  80070. readonly value: number;
  80071. }
  80072. /** @hidden */
  80073. export interface _GamePadFactory {
  80074. /**
  80075. * Returns wether or not the current gamepad can be created for this type of controller.
  80076. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80077. * @returns true if it can be created, otherwise false
  80078. */
  80079. canCreate(gamepadInfo: any): boolean;
  80080. /**
  80081. * Creates a new instance of the Gamepad.
  80082. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80083. * @returns the new gamepad instance
  80084. */
  80085. create(gamepadInfo: any): Gamepad;
  80086. }
  80087. /**
  80088. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80089. */
  80090. export class PoseEnabledControllerHelper {
  80091. /** @hidden */
  80092. static _ControllerFactories: _GamePadFactory[];
  80093. /** @hidden */
  80094. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80095. /**
  80096. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80097. * @param vrGamepad the gamepad to initialized
  80098. * @returns a vr controller of the type the gamepad identified as
  80099. */
  80100. static InitiateController(vrGamepad: any): Gamepad;
  80101. }
  80102. /**
  80103. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80104. */
  80105. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80106. private _deviceRoomPosition;
  80107. private _deviceRoomRotationQuaternion;
  80108. /**
  80109. * The device position in babylon space
  80110. */
  80111. devicePosition: Vector3;
  80112. /**
  80113. * The device rotation in babylon space
  80114. */
  80115. deviceRotationQuaternion: Quaternion;
  80116. /**
  80117. * The scale factor of the device in babylon space
  80118. */
  80119. deviceScaleFactor: number;
  80120. /**
  80121. * (Likely devicePosition should be used instead) The device position in its room space
  80122. */
  80123. position: Vector3;
  80124. /**
  80125. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80126. */
  80127. rotationQuaternion: Quaternion;
  80128. /**
  80129. * The type of controller (Eg. Windows mixed reality)
  80130. */
  80131. controllerType: PoseEnabledControllerType;
  80132. protected _calculatedPosition: Vector3;
  80133. private _calculatedRotation;
  80134. /**
  80135. * The raw pose from the device
  80136. */
  80137. rawPose: DevicePose;
  80138. private _trackPosition;
  80139. private _maxRotationDistFromHeadset;
  80140. private _draggedRoomRotation;
  80141. /**
  80142. * @hidden
  80143. */
  80144. _disableTrackPosition(fixedPosition: Vector3): void;
  80145. /**
  80146. * Internal, the mesh attached to the controller
  80147. * @hidden
  80148. */
  80149. _mesh: Nullable<AbstractMesh>;
  80150. private _poseControlledCamera;
  80151. private _leftHandSystemQuaternion;
  80152. /**
  80153. * Internal, matrix used to convert room space to babylon space
  80154. * @hidden
  80155. */
  80156. _deviceToWorld: Matrix;
  80157. /**
  80158. * Node to be used when casting a ray from the controller
  80159. * @hidden
  80160. */
  80161. _pointingPoseNode: Nullable<TransformNode>;
  80162. /**
  80163. * Name of the child mesh that can be used to cast a ray from the controller
  80164. */
  80165. static readonly POINTING_POSE: string;
  80166. /**
  80167. * Creates a new PoseEnabledController from a gamepad
  80168. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80169. */
  80170. constructor(browserGamepad: any);
  80171. private _workingMatrix;
  80172. /**
  80173. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80174. */
  80175. update(): void;
  80176. /**
  80177. * Updates only the pose device and mesh without doing any button event checking
  80178. */
  80179. protected _updatePoseAndMesh(): void;
  80180. /**
  80181. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80182. * @param poseData raw pose fromthe device
  80183. */
  80184. updateFromDevice(poseData: DevicePose): void;
  80185. /**
  80186. * @hidden
  80187. */
  80188. _meshAttachedObservable: Observable<AbstractMesh>;
  80189. /**
  80190. * Attaches a mesh to the controller
  80191. * @param mesh the mesh to be attached
  80192. */
  80193. attachToMesh(mesh: AbstractMesh): void;
  80194. /**
  80195. * Attaches the controllers mesh to a camera
  80196. * @param camera the camera the mesh should be attached to
  80197. */
  80198. attachToPoseControlledCamera(camera: TargetCamera): void;
  80199. /**
  80200. * Disposes of the controller
  80201. */
  80202. dispose(): void;
  80203. /**
  80204. * The mesh that is attached to the controller
  80205. */
  80206. readonly mesh: Nullable<AbstractMesh>;
  80207. /**
  80208. * Gets the ray of the controller in the direction the controller is pointing
  80209. * @param length the length the resulting ray should be
  80210. * @returns a ray in the direction the controller is pointing
  80211. */
  80212. getForwardRay(length?: number): Ray;
  80213. }
  80214. }
  80215. declare module BABYLON {
  80216. /**
  80217. * Defines the WebVRController object that represents controllers tracked in 3D space
  80218. */
  80219. export abstract class WebVRController extends PoseEnabledController {
  80220. /**
  80221. * Internal, the default controller model for the controller
  80222. */
  80223. protected _defaultModel: AbstractMesh;
  80224. /**
  80225. * Fired when the trigger state has changed
  80226. */
  80227. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80228. /**
  80229. * Fired when the main button state has changed
  80230. */
  80231. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80232. /**
  80233. * Fired when the secondary button state has changed
  80234. */
  80235. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80236. /**
  80237. * Fired when the pad state has changed
  80238. */
  80239. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80240. /**
  80241. * Fired when controllers stick values have changed
  80242. */
  80243. onPadValuesChangedObservable: Observable<StickValues>;
  80244. /**
  80245. * Array of button availible on the controller
  80246. */
  80247. protected _buttons: Array<MutableGamepadButton>;
  80248. private _onButtonStateChange;
  80249. /**
  80250. * Fired when a controller button's state has changed
  80251. * @param callback the callback containing the button that was modified
  80252. */
  80253. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80254. /**
  80255. * X and Y axis corresponding to the controllers joystick
  80256. */
  80257. pad: StickValues;
  80258. /**
  80259. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80260. */
  80261. hand: string;
  80262. /**
  80263. * The default controller model for the controller
  80264. */
  80265. readonly defaultModel: AbstractMesh;
  80266. /**
  80267. * Creates a new WebVRController from a gamepad
  80268. * @param vrGamepad the gamepad that the WebVRController should be created from
  80269. */
  80270. constructor(vrGamepad: any);
  80271. /**
  80272. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80273. */
  80274. update(): void;
  80275. /**
  80276. * Function to be called when a button is modified
  80277. */
  80278. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80279. /**
  80280. * Loads a mesh and attaches it to the controller
  80281. * @param scene the scene the mesh should be added to
  80282. * @param meshLoaded callback for when the mesh has been loaded
  80283. */
  80284. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80285. private _setButtonValue;
  80286. private _changes;
  80287. private _checkChanges;
  80288. /**
  80289. * Disposes of th webVRCOntroller
  80290. */
  80291. dispose(): void;
  80292. }
  80293. }
  80294. declare module BABYLON {
  80295. /**
  80296. * The HemisphericLight simulates the ambient environment light,
  80297. * so the passed direction is the light reflection direction, not the incoming direction.
  80298. */
  80299. export class HemisphericLight extends Light {
  80300. /**
  80301. * The groundColor is the light in the opposite direction to the one specified during creation.
  80302. * 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.
  80303. */
  80304. groundColor: Color3;
  80305. /**
  80306. * The light reflection direction, not the incoming direction.
  80307. */
  80308. direction: Vector3;
  80309. /**
  80310. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80311. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80312. * The HemisphericLight can't cast shadows.
  80313. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80314. * @param name The friendly name of the light
  80315. * @param direction The direction of the light reflection
  80316. * @param scene The scene the light belongs to
  80317. */
  80318. constructor(name: string, direction: Vector3, scene: Scene);
  80319. protected _buildUniformLayout(): void;
  80320. /**
  80321. * Returns the string "HemisphericLight".
  80322. * @return The class name
  80323. */
  80324. getClassName(): string;
  80325. /**
  80326. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80327. * Returns the updated direction.
  80328. * @param target The target the direction should point to
  80329. * @return The computed direction
  80330. */
  80331. setDirectionToTarget(target: Vector3): Vector3;
  80332. /**
  80333. * Returns the shadow generator associated to the light.
  80334. * @returns Always null for hemispheric lights because it does not support shadows.
  80335. */
  80336. getShadowGenerator(): Nullable<IShadowGenerator>;
  80337. /**
  80338. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80339. * @param effect The effect to update
  80340. * @param lightIndex The index of the light in the effect to update
  80341. * @returns The hemispheric light
  80342. */
  80343. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80344. /**
  80345. * Computes the world matrix of the node
  80346. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80347. * @param useWasUpdatedFlag defines a reserved property
  80348. * @returns the world matrix
  80349. */
  80350. computeWorldMatrix(): Matrix;
  80351. /**
  80352. * Returns the integer 3.
  80353. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80354. */
  80355. getTypeID(): number;
  80356. /**
  80357. * Prepares the list of defines specific to the light type.
  80358. * @param defines the list of defines
  80359. * @param lightIndex defines the index of the light for the effect
  80360. */
  80361. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80362. }
  80363. }
  80364. declare module BABYLON {
  80365. /** @hidden */
  80366. export var vrMultiviewToSingleviewPixelShader: {
  80367. name: string;
  80368. shader: string;
  80369. };
  80370. }
  80371. declare module BABYLON {
  80372. /**
  80373. * Renders to multiple views with a single draw call
  80374. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80375. */
  80376. export class MultiviewRenderTarget extends RenderTargetTexture {
  80377. /**
  80378. * Creates a multiview render target
  80379. * @param scene scene used with the render target
  80380. * @param size the size of the render target (used for each view)
  80381. */
  80382. constructor(scene: Scene, size?: number | {
  80383. width: number;
  80384. height: number;
  80385. } | {
  80386. ratio: number;
  80387. });
  80388. /**
  80389. * @hidden
  80390. * @param faceIndex the face index, if its a cube texture
  80391. */
  80392. _bindFrameBuffer(faceIndex?: number): void;
  80393. /**
  80394. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80395. * @returns the view count
  80396. */
  80397. getViewCount(): number;
  80398. }
  80399. }
  80400. declare module BABYLON {
  80401. interface Engine {
  80402. /**
  80403. * Creates a new multiview render target
  80404. * @param width defines the width of the texture
  80405. * @param height defines the height of the texture
  80406. * @returns the created multiview texture
  80407. */
  80408. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80409. /**
  80410. * Binds a multiview framebuffer to be drawn to
  80411. * @param multiviewTexture texture to bind
  80412. */
  80413. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80414. }
  80415. interface Camera {
  80416. /**
  80417. * @hidden
  80418. * 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)
  80419. */
  80420. _useMultiviewToSingleView: boolean;
  80421. /**
  80422. * @hidden
  80423. * 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)
  80424. */
  80425. _multiviewTexture: Nullable<RenderTargetTexture>;
  80426. /**
  80427. * @hidden
  80428. * ensures the multiview texture of the camera exists and has the specified width/height
  80429. * @param width height to set on the multiview texture
  80430. * @param height width to set on the multiview texture
  80431. */
  80432. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80433. }
  80434. interface Scene {
  80435. /** @hidden */
  80436. _transformMatrixR: Matrix;
  80437. /** @hidden */
  80438. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80439. /** @hidden */
  80440. _createMultiviewUbo(): void;
  80441. /** @hidden */
  80442. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80443. /** @hidden */
  80444. _renderMultiviewToSingleView(camera: Camera): void;
  80445. }
  80446. }
  80447. declare module BABYLON {
  80448. /**
  80449. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80450. * This will not be used for webXR as it supports displaying texture arrays directly
  80451. */
  80452. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80453. /**
  80454. * Initializes a VRMultiviewToSingleview
  80455. * @param name name of the post process
  80456. * @param camera camera to be applied to
  80457. * @param scaleFactor scaling factor to the size of the output texture
  80458. */
  80459. constructor(name: string, camera: Camera, scaleFactor: number);
  80460. }
  80461. }
  80462. declare module BABYLON {
  80463. interface Engine {
  80464. /** @hidden */
  80465. _vrDisplay: any;
  80466. /** @hidden */
  80467. _vrSupported: boolean;
  80468. /** @hidden */
  80469. _oldSize: Size;
  80470. /** @hidden */
  80471. _oldHardwareScaleFactor: number;
  80472. /** @hidden */
  80473. _vrExclusivePointerMode: boolean;
  80474. /** @hidden */
  80475. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80476. /** @hidden */
  80477. _onVRDisplayPointerRestricted: () => void;
  80478. /** @hidden */
  80479. _onVRDisplayPointerUnrestricted: () => void;
  80480. /** @hidden */
  80481. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80482. /** @hidden */
  80483. _onVrDisplayDisconnect: Nullable<() => void>;
  80484. /** @hidden */
  80485. _onVrDisplayPresentChange: Nullable<() => void>;
  80486. /**
  80487. * Observable signaled when VR display mode changes
  80488. */
  80489. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80490. /**
  80491. * Observable signaled when VR request present is complete
  80492. */
  80493. onVRRequestPresentComplete: Observable<boolean>;
  80494. /**
  80495. * Observable signaled when VR request present starts
  80496. */
  80497. onVRRequestPresentStart: Observable<Engine>;
  80498. /**
  80499. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80500. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80501. */
  80502. isInVRExclusivePointerMode: boolean;
  80503. /**
  80504. * Gets a boolean indicating if a webVR device was detected
  80505. * @returns true if a webVR device was detected
  80506. */
  80507. isVRDevicePresent(): boolean;
  80508. /**
  80509. * Gets the current webVR device
  80510. * @returns the current webVR device (or null)
  80511. */
  80512. getVRDevice(): any;
  80513. /**
  80514. * Initializes a webVR display and starts listening to display change events
  80515. * The onVRDisplayChangedObservable will be notified upon these changes
  80516. * @returns A promise containing a VRDisplay and if vr is supported
  80517. */
  80518. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80519. /** @hidden */
  80520. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80521. /**
  80522. * Call this function to switch to webVR mode
  80523. * Will do nothing if webVR is not supported or if there is no webVR device
  80524. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80525. */
  80526. enableVR(): void;
  80527. /** @hidden */
  80528. _onVRFullScreenTriggered(): void;
  80529. }
  80530. }
  80531. declare module BABYLON {
  80532. /**
  80533. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80534. * IMPORTANT!! The data is right-hand data.
  80535. * @export
  80536. * @interface DevicePose
  80537. */
  80538. export interface DevicePose {
  80539. /**
  80540. * The position of the device, values in array are [x,y,z].
  80541. */
  80542. readonly position: Nullable<Float32Array>;
  80543. /**
  80544. * The linearVelocity of the device, values in array are [x,y,z].
  80545. */
  80546. readonly linearVelocity: Nullable<Float32Array>;
  80547. /**
  80548. * The linearAcceleration of the device, values in array are [x,y,z].
  80549. */
  80550. readonly linearAcceleration: Nullable<Float32Array>;
  80551. /**
  80552. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80553. */
  80554. readonly orientation: Nullable<Float32Array>;
  80555. /**
  80556. * The angularVelocity of the device, values in array are [x,y,z].
  80557. */
  80558. readonly angularVelocity: Nullable<Float32Array>;
  80559. /**
  80560. * The angularAcceleration of the device, values in array are [x,y,z].
  80561. */
  80562. readonly angularAcceleration: Nullable<Float32Array>;
  80563. }
  80564. /**
  80565. * Interface representing a pose controlled object in Babylon.
  80566. * A pose controlled object has both regular pose values as well as pose values
  80567. * from an external device such as a VR head mounted display
  80568. */
  80569. export interface PoseControlled {
  80570. /**
  80571. * The position of the object in babylon space.
  80572. */
  80573. position: Vector3;
  80574. /**
  80575. * The rotation quaternion of the object in babylon space.
  80576. */
  80577. rotationQuaternion: Quaternion;
  80578. /**
  80579. * The position of the device in babylon space.
  80580. */
  80581. devicePosition?: Vector3;
  80582. /**
  80583. * The rotation quaternion of the device in babylon space.
  80584. */
  80585. deviceRotationQuaternion: Quaternion;
  80586. /**
  80587. * The raw pose coming from the device.
  80588. */
  80589. rawPose: Nullable<DevicePose>;
  80590. /**
  80591. * The scale of the device to be used when translating from device space to babylon space.
  80592. */
  80593. deviceScaleFactor: number;
  80594. /**
  80595. * Updates the poseControlled values based on the input device pose.
  80596. * @param poseData the pose data to update the object with
  80597. */
  80598. updateFromDevice(poseData: DevicePose): void;
  80599. }
  80600. /**
  80601. * Set of options to customize the webVRCamera
  80602. */
  80603. export interface WebVROptions {
  80604. /**
  80605. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80606. */
  80607. trackPosition?: boolean;
  80608. /**
  80609. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80610. */
  80611. positionScale?: number;
  80612. /**
  80613. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80614. */
  80615. displayName?: string;
  80616. /**
  80617. * Should the native controller meshes be initialized. (default: true)
  80618. */
  80619. controllerMeshes?: boolean;
  80620. /**
  80621. * Creating a default HemiLight only on controllers. (default: true)
  80622. */
  80623. defaultLightingOnControllers?: boolean;
  80624. /**
  80625. * If you don't want to use the default VR button of the helper. (default: false)
  80626. */
  80627. useCustomVRButton?: boolean;
  80628. /**
  80629. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80630. */
  80631. customVRButton?: HTMLButtonElement;
  80632. /**
  80633. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80634. */
  80635. rayLength?: number;
  80636. /**
  80637. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80638. */
  80639. defaultHeight?: number;
  80640. /**
  80641. * If multiview should be used if availible (default: false)
  80642. */
  80643. useMultiview?: boolean;
  80644. }
  80645. /**
  80646. * This represents a WebVR camera.
  80647. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80648. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80649. */
  80650. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80651. private webVROptions;
  80652. /**
  80653. * @hidden
  80654. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80655. */
  80656. _vrDevice: any;
  80657. /**
  80658. * The rawPose of the vrDevice.
  80659. */
  80660. rawPose: Nullable<DevicePose>;
  80661. private _onVREnabled;
  80662. private _specsVersion;
  80663. private _attached;
  80664. private _frameData;
  80665. protected _descendants: Array<Node>;
  80666. private _deviceRoomPosition;
  80667. /** @hidden */
  80668. _deviceRoomRotationQuaternion: Quaternion;
  80669. private _standingMatrix;
  80670. /**
  80671. * Represents device position in babylon space.
  80672. */
  80673. devicePosition: Vector3;
  80674. /**
  80675. * Represents device rotation in babylon space.
  80676. */
  80677. deviceRotationQuaternion: Quaternion;
  80678. /**
  80679. * The scale of the device to be used when translating from device space to babylon space.
  80680. */
  80681. deviceScaleFactor: number;
  80682. private _deviceToWorld;
  80683. private _worldToDevice;
  80684. /**
  80685. * References to the webVR controllers for the vrDevice.
  80686. */
  80687. controllers: Array<WebVRController>;
  80688. /**
  80689. * Emits an event when a controller is attached.
  80690. */
  80691. onControllersAttachedObservable: Observable<WebVRController[]>;
  80692. /**
  80693. * Emits an event when a controller's mesh has been loaded;
  80694. */
  80695. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80696. /**
  80697. * Emits an event when the HMD's pose has been updated.
  80698. */
  80699. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80700. private _poseSet;
  80701. /**
  80702. * If the rig cameras be used as parent instead of this camera.
  80703. */
  80704. rigParenting: boolean;
  80705. private _lightOnControllers;
  80706. private _defaultHeight?;
  80707. /**
  80708. * Instantiates a WebVRFreeCamera.
  80709. * @param name The name of the WebVRFreeCamera
  80710. * @param position The starting anchor position for the camera
  80711. * @param scene The scene the camera belongs to
  80712. * @param webVROptions a set of customizable options for the webVRCamera
  80713. */
  80714. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80715. /**
  80716. * Gets the device distance from the ground in meters.
  80717. * @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.
  80718. */
  80719. deviceDistanceToRoomGround(): number;
  80720. /**
  80721. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80722. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80723. */
  80724. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80725. /**
  80726. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80727. * @returns A promise with a boolean set to if the standing matrix is supported.
  80728. */
  80729. useStandingMatrixAsync(): Promise<boolean>;
  80730. /**
  80731. * Disposes the camera
  80732. */
  80733. dispose(): void;
  80734. /**
  80735. * Gets a vrController by name.
  80736. * @param name The name of the controller to retreive
  80737. * @returns the controller matching the name specified or null if not found
  80738. */
  80739. getControllerByName(name: string): Nullable<WebVRController>;
  80740. private _leftController;
  80741. /**
  80742. * The controller corresponding to the users left hand.
  80743. */
  80744. readonly leftController: Nullable<WebVRController>;
  80745. private _rightController;
  80746. /**
  80747. * The controller corresponding to the users right hand.
  80748. */
  80749. readonly rightController: Nullable<WebVRController>;
  80750. /**
  80751. * Casts a ray forward from the vrCamera's gaze.
  80752. * @param length Length of the ray (default: 100)
  80753. * @returns the ray corresponding to the gaze
  80754. */
  80755. getForwardRay(length?: number): Ray;
  80756. /**
  80757. * @hidden
  80758. * Updates the camera based on device's frame data
  80759. */
  80760. _checkInputs(): void;
  80761. /**
  80762. * Updates the poseControlled values based on the input device pose.
  80763. * @param poseData Pose coming from the device
  80764. */
  80765. updateFromDevice(poseData: DevicePose): void;
  80766. private _htmlElementAttached;
  80767. private _detachIfAttached;
  80768. /**
  80769. * WebVR's attach control will start broadcasting frames to the device.
  80770. * Note that in certain browsers (chrome for example) this function must be called
  80771. * within a user-interaction callback. Example:
  80772. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80773. *
  80774. * @param element html element to attach the vrDevice to
  80775. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80776. */
  80777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80778. /**
  80779. * Detaches the camera from the html element and disables VR
  80780. *
  80781. * @param element html element to detach from
  80782. */
  80783. detachControl(element: HTMLElement): void;
  80784. /**
  80785. * @returns the name of this class
  80786. */
  80787. getClassName(): string;
  80788. /**
  80789. * Calls resetPose on the vrDisplay
  80790. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80791. */
  80792. resetToCurrentRotation(): void;
  80793. /**
  80794. * @hidden
  80795. * Updates the rig cameras (left and right eye)
  80796. */
  80797. _updateRigCameras(): void;
  80798. private _workingVector;
  80799. private _oneVector;
  80800. private _workingMatrix;
  80801. private updateCacheCalled;
  80802. private _correctPositionIfNotTrackPosition;
  80803. /**
  80804. * @hidden
  80805. * Updates the cached values of the camera
  80806. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80807. */
  80808. _updateCache(ignoreParentClass?: boolean): void;
  80809. /**
  80810. * @hidden
  80811. * Get current device position in babylon world
  80812. */
  80813. _computeDevicePosition(): void;
  80814. /**
  80815. * Updates the current device position and rotation in the babylon world
  80816. */
  80817. update(): void;
  80818. /**
  80819. * @hidden
  80820. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80821. * @returns an identity matrix
  80822. */
  80823. _getViewMatrix(): Matrix;
  80824. private _tmpMatrix;
  80825. /**
  80826. * This function is called by the two RIG cameras.
  80827. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80828. * @hidden
  80829. */
  80830. _getWebVRViewMatrix(): Matrix;
  80831. /** @hidden */
  80832. _getWebVRProjectionMatrix(): Matrix;
  80833. private _onGamepadConnectedObserver;
  80834. private _onGamepadDisconnectedObserver;
  80835. private _updateCacheWhenTrackingDisabledObserver;
  80836. /**
  80837. * Initializes the controllers and their meshes
  80838. */
  80839. initControllers(): void;
  80840. }
  80841. }
  80842. declare module BABYLON {
  80843. /**
  80844. * Size options for a post process
  80845. */
  80846. export type PostProcessOptions = {
  80847. width: number;
  80848. height: number;
  80849. };
  80850. /**
  80851. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80852. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80853. */
  80854. export class PostProcess {
  80855. /** Name of the PostProcess. */
  80856. name: string;
  80857. /**
  80858. * Gets or sets the unique id of the post process
  80859. */
  80860. uniqueId: number;
  80861. /**
  80862. * Width of the texture to apply the post process on
  80863. */
  80864. width: number;
  80865. /**
  80866. * Height of the texture to apply the post process on
  80867. */
  80868. height: number;
  80869. /**
  80870. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80871. * @hidden
  80872. */
  80873. _outputTexture: Nullable<InternalTexture>;
  80874. /**
  80875. * Sampling mode used by the shader
  80876. * See https://doc.babylonjs.com/classes/3.1/texture
  80877. */
  80878. renderTargetSamplingMode: number;
  80879. /**
  80880. * Clear color to use when screen clearing
  80881. */
  80882. clearColor: Color4;
  80883. /**
  80884. * If the buffer needs to be cleared before applying the post process. (default: true)
  80885. * Should be set to false if shader will overwrite all previous pixels.
  80886. */
  80887. autoClear: boolean;
  80888. /**
  80889. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80890. */
  80891. alphaMode: number;
  80892. /**
  80893. * Sets the setAlphaBlendConstants of the babylon engine
  80894. */
  80895. alphaConstants: Color4;
  80896. /**
  80897. * Animations to be used for the post processing
  80898. */
  80899. animations: Animation[];
  80900. /**
  80901. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80902. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80903. */
  80904. enablePixelPerfectMode: boolean;
  80905. /**
  80906. * Force the postprocess to be applied without taking in account viewport
  80907. */
  80908. forceFullscreenViewport: boolean;
  80909. /**
  80910. * List of inspectable custom properties (used by the Inspector)
  80911. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80912. */
  80913. inspectableCustomProperties: IInspectable[];
  80914. /**
  80915. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80916. *
  80917. * | Value | Type | Description |
  80918. * | ----- | ----------------------------------- | ----------- |
  80919. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80920. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80921. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80922. *
  80923. */
  80924. scaleMode: number;
  80925. /**
  80926. * Force textures to be a power of two (default: false)
  80927. */
  80928. alwaysForcePOT: boolean;
  80929. private _samples;
  80930. /**
  80931. * Number of sample textures (default: 1)
  80932. */
  80933. samples: number;
  80934. /**
  80935. * Modify the scale of the post process to be the same as the viewport (default: false)
  80936. */
  80937. adaptScaleToCurrentViewport: boolean;
  80938. private _camera;
  80939. private _scene;
  80940. private _engine;
  80941. private _options;
  80942. private _reusable;
  80943. private _textureType;
  80944. /**
  80945. * Smart array of input and output textures for the post process.
  80946. * @hidden
  80947. */
  80948. _textures: SmartArray<InternalTexture>;
  80949. /**
  80950. * The index in _textures that corresponds to the output texture.
  80951. * @hidden
  80952. */
  80953. _currentRenderTextureInd: number;
  80954. private _effect;
  80955. private _samplers;
  80956. private _fragmentUrl;
  80957. private _vertexUrl;
  80958. private _parameters;
  80959. private _scaleRatio;
  80960. protected _indexParameters: any;
  80961. private _shareOutputWithPostProcess;
  80962. private _texelSize;
  80963. private _forcedOutputTexture;
  80964. /**
  80965. * Returns the fragment url or shader name used in the post process.
  80966. * @returns the fragment url or name in the shader store.
  80967. */
  80968. getEffectName(): string;
  80969. /**
  80970. * An event triggered when the postprocess is activated.
  80971. */
  80972. onActivateObservable: Observable<Camera>;
  80973. private _onActivateObserver;
  80974. /**
  80975. * A function that is added to the onActivateObservable
  80976. */
  80977. onActivate: Nullable<(camera: Camera) => void>;
  80978. /**
  80979. * An event triggered when the postprocess changes its size.
  80980. */
  80981. onSizeChangedObservable: Observable<PostProcess>;
  80982. private _onSizeChangedObserver;
  80983. /**
  80984. * A function that is added to the onSizeChangedObservable
  80985. */
  80986. onSizeChanged: (postProcess: PostProcess) => void;
  80987. /**
  80988. * An event triggered when the postprocess applies its effect.
  80989. */
  80990. onApplyObservable: Observable<Effect>;
  80991. private _onApplyObserver;
  80992. /**
  80993. * A function that is added to the onApplyObservable
  80994. */
  80995. onApply: (effect: Effect) => void;
  80996. /**
  80997. * An event triggered before rendering the postprocess
  80998. */
  80999. onBeforeRenderObservable: Observable<Effect>;
  81000. private _onBeforeRenderObserver;
  81001. /**
  81002. * A function that is added to the onBeforeRenderObservable
  81003. */
  81004. onBeforeRender: (effect: Effect) => void;
  81005. /**
  81006. * An event triggered after rendering the postprocess
  81007. */
  81008. onAfterRenderObservable: Observable<Effect>;
  81009. private _onAfterRenderObserver;
  81010. /**
  81011. * A function that is added to the onAfterRenderObservable
  81012. */
  81013. onAfterRender: (efect: Effect) => void;
  81014. /**
  81015. * 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
  81016. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81017. */
  81018. inputTexture: InternalTexture;
  81019. /**
  81020. * Gets the camera which post process is applied to.
  81021. * @returns The camera the post process is applied to.
  81022. */
  81023. getCamera(): Camera;
  81024. /**
  81025. * Gets the texel size of the postprocess.
  81026. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81027. */
  81028. readonly texelSize: Vector2;
  81029. /**
  81030. * Creates a new instance PostProcess
  81031. * @param name The name of the PostProcess.
  81032. * @param fragmentUrl The url of the fragment shader to be used.
  81033. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81034. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81035. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81036. * @param camera The camera to apply the render pass to.
  81037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81038. * @param engine The engine which the post process will be applied. (default: current engine)
  81039. * @param reusable If the post process can be reused on the same frame. (default: false)
  81040. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81041. * @param textureType Type of textures used when performing the post process. (default: 0)
  81042. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81043. * @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
  81044. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81045. */
  81046. constructor(
  81047. /** Name of the PostProcess. */
  81048. 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);
  81049. /**
  81050. * Gets a string idenfifying the name of the class
  81051. * @returns "PostProcess" string
  81052. */
  81053. getClassName(): string;
  81054. /**
  81055. * Gets the engine which this post process belongs to.
  81056. * @returns The engine the post process was enabled with.
  81057. */
  81058. getEngine(): Engine;
  81059. /**
  81060. * The effect that is created when initializing the post process.
  81061. * @returns The created effect corresponding the the postprocess.
  81062. */
  81063. getEffect(): Effect;
  81064. /**
  81065. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81066. * @param postProcess The post process to share the output with.
  81067. * @returns This post process.
  81068. */
  81069. shareOutputWith(postProcess: PostProcess): PostProcess;
  81070. /**
  81071. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81072. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81073. */
  81074. useOwnOutput(): void;
  81075. /**
  81076. * Updates the effect with the current post process compile time values and recompiles the shader.
  81077. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81078. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81079. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81080. * @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
  81081. * @param onCompiled Called when the shader has been compiled.
  81082. * @param onError Called if there is an error when compiling a shader.
  81083. */
  81084. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81085. /**
  81086. * The post process is reusable if it can be used multiple times within one frame.
  81087. * @returns If the post process is reusable
  81088. */
  81089. isReusable(): boolean;
  81090. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81091. markTextureDirty(): void;
  81092. /**
  81093. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81094. * 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.
  81095. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81096. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81097. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81098. * @returns The target texture that was bound to be written to.
  81099. */
  81100. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81101. /**
  81102. * If the post process is supported.
  81103. */
  81104. readonly isSupported: boolean;
  81105. /**
  81106. * The aspect ratio of the output texture.
  81107. */
  81108. readonly aspectRatio: number;
  81109. /**
  81110. * Get a value indicating if the post-process is ready to be used
  81111. * @returns true if the post-process is ready (shader is compiled)
  81112. */
  81113. isReady(): boolean;
  81114. /**
  81115. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81116. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81117. */
  81118. apply(): Nullable<Effect>;
  81119. private _disposeTextures;
  81120. /**
  81121. * Disposes the post process.
  81122. * @param camera The camera to dispose the post process on.
  81123. */
  81124. dispose(camera?: Camera): void;
  81125. }
  81126. }
  81127. declare module BABYLON {
  81128. /** @hidden */
  81129. export var kernelBlurVaryingDeclaration: {
  81130. name: string;
  81131. shader: string;
  81132. };
  81133. }
  81134. declare module BABYLON {
  81135. /** @hidden */
  81136. export var kernelBlurFragment: {
  81137. name: string;
  81138. shader: string;
  81139. };
  81140. }
  81141. declare module BABYLON {
  81142. /** @hidden */
  81143. export var kernelBlurFragment2: {
  81144. name: string;
  81145. shader: string;
  81146. };
  81147. }
  81148. declare module BABYLON {
  81149. /** @hidden */
  81150. export var kernelBlurPixelShader: {
  81151. name: string;
  81152. shader: string;
  81153. };
  81154. }
  81155. declare module BABYLON {
  81156. /** @hidden */
  81157. export var kernelBlurVertex: {
  81158. name: string;
  81159. shader: string;
  81160. };
  81161. }
  81162. declare module BABYLON {
  81163. /** @hidden */
  81164. export var kernelBlurVertexShader: {
  81165. name: string;
  81166. shader: string;
  81167. };
  81168. }
  81169. declare module BABYLON {
  81170. /**
  81171. * The Blur Post Process which blurs an image based on a kernel and direction.
  81172. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81173. */
  81174. export class BlurPostProcess extends PostProcess {
  81175. /** The direction in which to blur the image. */
  81176. direction: Vector2;
  81177. private blockCompilation;
  81178. protected _kernel: number;
  81179. protected _idealKernel: number;
  81180. protected _packedFloat: boolean;
  81181. private _staticDefines;
  81182. /**
  81183. * Sets the length in pixels of the blur sample region
  81184. */
  81185. /**
  81186. * Gets the length in pixels of the blur sample region
  81187. */
  81188. kernel: number;
  81189. /**
  81190. * Sets wether or not the blur needs to unpack/repack floats
  81191. */
  81192. /**
  81193. * Gets wether or not the blur is unpacking/repacking floats
  81194. */
  81195. packedFloat: boolean;
  81196. /**
  81197. * Creates a new instance BlurPostProcess
  81198. * @param name The name of the effect.
  81199. * @param direction The direction in which to blur the image.
  81200. * @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.
  81201. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81202. * @param camera The camera to apply the render pass to.
  81203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81204. * @param engine The engine which the post process will be applied. (default: current engine)
  81205. * @param reusable If the post process can be reused on the same frame. (default: false)
  81206. * @param textureType Type of textures used when performing the post process. (default: 0)
  81207. * @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)
  81208. */
  81209. constructor(name: string,
  81210. /** The direction in which to blur the image. */
  81211. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81212. /**
  81213. * Updates the effect with the current post process compile time values and recompiles the shader.
  81214. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81215. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81216. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81217. * @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
  81218. * @param onCompiled Called when the shader has been compiled.
  81219. * @param onError Called if there is an error when compiling a shader.
  81220. */
  81221. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81222. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81223. /**
  81224. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81225. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81226. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81227. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81228. * The gaps between physical kernels are compensated for in the weighting of the samples
  81229. * @param idealKernel Ideal blur kernel.
  81230. * @return Nearest best kernel.
  81231. */
  81232. protected _nearestBestKernel(idealKernel: number): number;
  81233. /**
  81234. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81235. * @param x The point on the Gaussian distribution to sample.
  81236. * @return the value of the Gaussian function at x.
  81237. */
  81238. protected _gaussianWeight(x: number): number;
  81239. /**
  81240. * Generates a string that can be used as a floating point number in GLSL.
  81241. * @param x Value to print.
  81242. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81243. * @return GLSL float string.
  81244. */
  81245. protected _glslFloat(x: number, decimalFigures?: number): string;
  81246. }
  81247. }
  81248. declare module BABYLON {
  81249. /**
  81250. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81251. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81252. * You can then easily use it as a reflectionTexture on a flat surface.
  81253. * In case the surface is not a plane, please consider relying on reflection probes.
  81254. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81255. */
  81256. export class MirrorTexture extends RenderTargetTexture {
  81257. private scene;
  81258. /**
  81259. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81260. * 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.
  81261. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81262. */
  81263. mirrorPlane: Plane;
  81264. /**
  81265. * Define the blur ratio used to blur the reflection if needed.
  81266. */
  81267. blurRatio: number;
  81268. /**
  81269. * Define the adaptive blur kernel used to blur the reflection if needed.
  81270. * This will autocompute the closest best match for the `blurKernel`
  81271. */
  81272. adaptiveBlurKernel: number;
  81273. /**
  81274. * Define the blur kernel used to blur the reflection if needed.
  81275. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81276. */
  81277. blurKernel: number;
  81278. /**
  81279. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81280. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81281. */
  81282. blurKernelX: number;
  81283. /**
  81284. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81285. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81286. */
  81287. blurKernelY: number;
  81288. private _autoComputeBlurKernel;
  81289. protected _onRatioRescale(): void;
  81290. private _updateGammaSpace;
  81291. private _imageProcessingConfigChangeObserver;
  81292. private _transformMatrix;
  81293. private _mirrorMatrix;
  81294. private _savedViewMatrix;
  81295. private _blurX;
  81296. private _blurY;
  81297. private _adaptiveBlurKernel;
  81298. private _blurKernelX;
  81299. private _blurKernelY;
  81300. private _blurRatio;
  81301. /**
  81302. * Instantiates a Mirror Texture.
  81303. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81304. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81305. * You can then easily use it as a reflectionTexture on a flat surface.
  81306. * In case the surface is not a plane, please consider relying on reflection probes.
  81307. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81308. * @param name
  81309. * @param size
  81310. * @param scene
  81311. * @param generateMipMaps
  81312. * @param type
  81313. * @param samplingMode
  81314. * @param generateDepthBuffer
  81315. */
  81316. constructor(name: string, size: number | {
  81317. width: number;
  81318. height: number;
  81319. } | {
  81320. ratio: number;
  81321. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81322. private _preparePostProcesses;
  81323. /**
  81324. * Clone the mirror texture.
  81325. * @returns the cloned texture
  81326. */
  81327. clone(): MirrorTexture;
  81328. /**
  81329. * Serialize the texture to a JSON representation you could use in Parse later on
  81330. * @returns the serialized JSON representation
  81331. */
  81332. serialize(): any;
  81333. /**
  81334. * Dispose the texture and release its associated resources.
  81335. */
  81336. dispose(): void;
  81337. }
  81338. }
  81339. declare module BABYLON {
  81340. /**
  81341. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81342. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81343. */
  81344. export class Texture extends BaseTexture {
  81345. /** @hidden */
  81346. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81347. /** @hidden */
  81348. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81349. /** @hidden */
  81350. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81351. /** nearest is mag = nearest and min = nearest and mip = linear */
  81352. static readonly NEAREST_SAMPLINGMODE: number;
  81353. /** nearest is mag = nearest and min = nearest and mip = linear */
  81354. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81355. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81356. static readonly BILINEAR_SAMPLINGMODE: number;
  81357. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81358. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81359. /** Trilinear is mag = linear and min = linear and mip = linear */
  81360. static readonly TRILINEAR_SAMPLINGMODE: number;
  81361. /** Trilinear is mag = linear and min = linear and mip = linear */
  81362. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81363. /** mag = nearest and min = nearest and mip = nearest */
  81364. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81365. /** mag = nearest and min = linear and mip = nearest */
  81366. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81367. /** mag = nearest and min = linear and mip = linear */
  81368. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81369. /** mag = nearest and min = linear and mip = none */
  81370. static readonly NEAREST_LINEAR: number;
  81371. /** mag = nearest and min = nearest and mip = none */
  81372. static readonly NEAREST_NEAREST: number;
  81373. /** mag = linear and min = nearest and mip = nearest */
  81374. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81375. /** mag = linear and min = nearest and mip = linear */
  81376. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81377. /** mag = linear and min = linear and mip = none */
  81378. static readonly LINEAR_LINEAR: number;
  81379. /** mag = linear and min = nearest and mip = none */
  81380. static readonly LINEAR_NEAREST: number;
  81381. /** Explicit coordinates mode */
  81382. static readonly EXPLICIT_MODE: number;
  81383. /** Spherical coordinates mode */
  81384. static readonly SPHERICAL_MODE: number;
  81385. /** Planar coordinates mode */
  81386. static readonly PLANAR_MODE: number;
  81387. /** Cubic coordinates mode */
  81388. static readonly CUBIC_MODE: number;
  81389. /** Projection coordinates mode */
  81390. static readonly PROJECTION_MODE: number;
  81391. /** Inverse Cubic coordinates mode */
  81392. static readonly SKYBOX_MODE: number;
  81393. /** Inverse Cubic coordinates mode */
  81394. static readonly INVCUBIC_MODE: number;
  81395. /** Equirectangular coordinates mode */
  81396. static readonly EQUIRECTANGULAR_MODE: number;
  81397. /** Equirectangular Fixed coordinates mode */
  81398. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81399. /** Equirectangular Fixed Mirrored coordinates mode */
  81400. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81401. /** Texture is not repeating outside of 0..1 UVs */
  81402. static readonly CLAMP_ADDRESSMODE: number;
  81403. /** Texture is repeating outside of 0..1 UVs */
  81404. static readonly WRAP_ADDRESSMODE: number;
  81405. /** Texture is repeating and mirrored */
  81406. static readonly MIRROR_ADDRESSMODE: number;
  81407. /**
  81408. * 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
  81409. */
  81410. static UseSerializedUrlIfAny: boolean;
  81411. /**
  81412. * Define the url of the texture.
  81413. */
  81414. url: Nullable<string>;
  81415. /**
  81416. * Define an offset on the texture to offset the u coordinates of the UVs
  81417. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81418. */
  81419. uOffset: number;
  81420. /**
  81421. * Define an offset on the texture to offset the v coordinates of the UVs
  81422. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81423. */
  81424. vOffset: number;
  81425. /**
  81426. * Define an offset on the texture to scale the u coordinates of the UVs
  81427. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81428. */
  81429. uScale: number;
  81430. /**
  81431. * Define an offset on the texture to scale the v coordinates of the UVs
  81432. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81433. */
  81434. vScale: number;
  81435. /**
  81436. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81437. * @see http://doc.babylonjs.com/how_to/more_materials
  81438. */
  81439. uAng: number;
  81440. /**
  81441. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81442. * @see http://doc.babylonjs.com/how_to/more_materials
  81443. */
  81444. vAng: number;
  81445. /**
  81446. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81447. * @see http://doc.babylonjs.com/how_to/more_materials
  81448. */
  81449. wAng: number;
  81450. /**
  81451. * Defines the center of rotation (U)
  81452. */
  81453. uRotationCenter: number;
  81454. /**
  81455. * Defines the center of rotation (V)
  81456. */
  81457. vRotationCenter: number;
  81458. /**
  81459. * Defines the center of rotation (W)
  81460. */
  81461. wRotationCenter: number;
  81462. /**
  81463. * Are mip maps generated for this texture or not.
  81464. */
  81465. readonly noMipmap: boolean;
  81466. /**
  81467. * List of inspectable custom properties (used by the Inspector)
  81468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81469. */
  81470. inspectableCustomProperties: Nullable<IInspectable[]>;
  81471. private _noMipmap;
  81472. /** @hidden */
  81473. _invertY: boolean;
  81474. private _rowGenerationMatrix;
  81475. private _cachedTextureMatrix;
  81476. private _projectionModeMatrix;
  81477. private _t0;
  81478. private _t1;
  81479. private _t2;
  81480. private _cachedUOffset;
  81481. private _cachedVOffset;
  81482. private _cachedUScale;
  81483. private _cachedVScale;
  81484. private _cachedUAng;
  81485. private _cachedVAng;
  81486. private _cachedWAng;
  81487. private _cachedProjectionMatrixId;
  81488. private _cachedCoordinatesMode;
  81489. /** @hidden */
  81490. protected _initialSamplingMode: number;
  81491. /** @hidden */
  81492. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81493. private _deleteBuffer;
  81494. protected _format: Nullable<number>;
  81495. private _delayedOnLoad;
  81496. private _delayedOnError;
  81497. /**
  81498. * Observable triggered once the texture has been loaded.
  81499. */
  81500. onLoadObservable: Observable<Texture>;
  81501. protected _isBlocking: boolean;
  81502. /**
  81503. * Is the texture preventing material to render while loading.
  81504. * If false, a default texture will be used instead of the loading one during the preparation step.
  81505. */
  81506. isBlocking: boolean;
  81507. /**
  81508. * Get the current sampling mode associated with the texture.
  81509. */
  81510. readonly samplingMode: number;
  81511. /**
  81512. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81513. */
  81514. readonly invertY: boolean;
  81515. /**
  81516. * Instantiates a new texture.
  81517. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81518. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81519. * @param url define the url of the picture to load as a texture
  81520. * @param scene define the scene the texture will belong to
  81521. * @param noMipmap define if the texture will require mip maps or not
  81522. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81523. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81524. * @param onLoad define a callback triggered when the texture has been loaded
  81525. * @param onError define a callback triggered when an error occurred during the loading session
  81526. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81527. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81528. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81529. */
  81530. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81531. /**
  81532. * Update the url (and optional buffer) of this texture if url was null during construction.
  81533. * @param url the url of the texture
  81534. * @param buffer the buffer of the texture (defaults to null)
  81535. * @param onLoad callback called when the texture is loaded (defaults to null)
  81536. */
  81537. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81538. /**
  81539. * Finish the loading sequence of a texture flagged as delayed load.
  81540. * @hidden
  81541. */
  81542. delayLoad(): void;
  81543. private _prepareRowForTextureGeneration;
  81544. /**
  81545. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81546. * @returns the transform matrix of the texture.
  81547. */
  81548. getTextureMatrix(): Matrix;
  81549. /**
  81550. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81551. * @returns The reflection texture transform
  81552. */
  81553. getReflectionTextureMatrix(): Matrix;
  81554. /**
  81555. * Clones the texture.
  81556. * @returns the cloned texture
  81557. */
  81558. clone(): Texture;
  81559. /**
  81560. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81561. * @returns The JSON representation of the texture
  81562. */
  81563. serialize(): any;
  81564. /**
  81565. * Get the current class name of the texture useful for serialization or dynamic coding.
  81566. * @returns "Texture"
  81567. */
  81568. getClassName(): string;
  81569. /**
  81570. * Dispose the texture and release its associated resources.
  81571. */
  81572. dispose(): void;
  81573. /**
  81574. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81575. * @param parsedTexture Define the JSON representation of the texture
  81576. * @param scene Define the scene the parsed texture should be instantiated in
  81577. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81578. * @returns The parsed texture if successful
  81579. */
  81580. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81581. /**
  81582. * Creates a texture from its base 64 representation.
  81583. * @param data Define the base64 payload without the data: prefix
  81584. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81585. * @param scene Define the scene the texture should belong to
  81586. * @param noMipmap Forces the texture to not create mip map information if true
  81587. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81588. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81589. * @param onLoad define a callback triggered when the texture has been loaded
  81590. * @param onError define a callback triggered when an error occurred during the loading session
  81591. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81592. * @returns the created texture
  81593. */
  81594. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81595. /**
  81596. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81597. * @param data Define the base64 payload without the data: prefix
  81598. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81599. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81600. * @param scene Define the scene the texture should belong to
  81601. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81602. * @param noMipmap Forces the texture to not create mip map information if true
  81603. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81604. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81605. * @param onLoad define a callback triggered when the texture has been loaded
  81606. * @param onError define a callback triggered when an error occurred during the loading session
  81607. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81608. * @returns the created texture
  81609. */
  81610. 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;
  81611. }
  81612. }
  81613. declare module BABYLON {
  81614. /**
  81615. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81616. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81617. */
  81618. export class PostProcessManager {
  81619. private _scene;
  81620. private _indexBuffer;
  81621. private _vertexBuffers;
  81622. /**
  81623. * Creates a new instance PostProcess
  81624. * @param scene The scene that the post process is associated with.
  81625. */
  81626. constructor(scene: Scene);
  81627. private _prepareBuffers;
  81628. private _buildIndexBuffer;
  81629. /**
  81630. * Rebuilds the vertex buffers of the manager.
  81631. * @hidden
  81632. */
  81633. _rebuild(): void;
  81634. /**
  81635. * Prepares a frame to be run through a post process.
  81636. * @param sourceTexture The input texture to the post procesess. (default: null)
  81637. * @param postProcesses An array of post processes to be run. (default: null)
  81638. * @returns True if the post processes were able to be run.
  81639. * @hidden
  81640. */
  81641. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81642. /**
  81643. * Manually render a set of post processes to a texture.
  81644. * @param postProcesses An array of post processes to be run.
  81645. * @param targetTexture The target texture to render to.
  81646. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81647. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81648. * @param lodLevel defines which lod of the texture to render to
  81649. */
  81650. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81651. /**
  81652. * Finalize the result of the output of the postprocesses.
  81653. * @param doNotPresent If true the result will not be displayed to the screen.
  81654. * @param targetTexture The target texture to render to.
  81655. * @param faceIndex The index of the face to bind the target texture to.
  81656. * @param postProcesses The array of post processes to render.
  81657. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81658. * @hidden
  81659. */
  81660. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81661. /**
  81662. * Disposes of the post process manager.
  81663. */
  81664. dispose(): void;
  81665. }
  81666. }
  81667. declare module BABYLON {
  81668. interface AbstractScene {
  81669. /**
  81670. * The list of procedural textures added to the scene
  81671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81672. */
  81673. proceduralTextures: Array<ProceduralTexture>;
  81674. }
  81675. /**
  81676. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81677. * in a given scene.
  81678. */
  81679. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81680. /**
  81681. * The component name helpfull to identify the component in the list of scene components.
  81682. */
  81683. readonly name: string;
  81684. /**
  81685. * The scene the component belongs to.
  81686. */
  81687. scene: Scene;
  81688. /**
  81689. * Creates a new instance of the component for the given scene
  81690. * @param scene Defines the scene to register the component in
  81691. */
  81692. constructor(scene: Scene);
  81693. /**
  81694. * Registers the component in a given scene
  81695. */
  81696. register(): void;
  81697. /**
  81698. * Rebuilds the elements related to this component in case of
  81699. * context lost for instance.
  81700. */
  81701. rebuild(): void;
  81702. /**
  81703. * Disposes the component and the associated ressources.
  81704. */
  81705. dispose(): void;
  81706. private _beforeClear;
  81707. }
  81708. }
  81709. declare module BABYLON {
  81710. interface Engine {
  81711. /**
  81712. * Creates a new render target cube texture
  81713. * @param size defines the size of the texture
  81714. * @param options defines the options used to create the texture
  81715. * @returns a new render target cube texture stored in an InternalTexture
  81716. */
  81717. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81718. }
  81719. }
  81720. declare module BABYLON {
  81721. /** @hidden */
  81722. export var proceduralVertexShader: {
  81723. name: string;
  81724. shader: string;
  81725. };
  81726. }
  81727. declare module BABYLON {
  81728. /**
  81729. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  81730. * This is the base class of any Procedural texture and contains most of the shareable code.
  81731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81732. */
  81733. export class ProceduralTexture extends Texture {
  81734. isCube: boolean;
  81735. /**
  81736. * Define if the texture is enabled or not (disabled texture will not render)
  81737. */
  81738. isEnabled: boolean;
  81739. /**
  81740. * Define if the texture must be cleared before rendering (default is true)
  81741. */
  81742. autoClear: boolean;
  81743. /**
  81744. * Callback called when the texture is generated
  81745. */
  81746. onGenerated: () => void;
  81747. /**
  81748. * Event raised when the texture is generated
  81749. */
  81750. onGeneratedObservable: Observable<ProceduralTexture>;
  81751. /** @hidden */
  81752. _generateMipMaps: boolean;
  81753. /** @hidden **/
  81754. _effect: Effect;
  81755. /** @hidden */
  81756. _textures: {
  81757. [key: string]: Texture;
  81758. };
  81759. private _size;
  81760. private _currentRefreshId;
  81761. private _refreshRate;
  81762. private _vertexBuffers;
  81763. private _indexBuffer;
  81764. private _uniforms;
  81765. private _samplers;
  81766. private _fragment;
  81767. private _floats;
  81768. private _ints;
  81769. private _floatsArrays;
  81770. private _colors3;
  81771. private _colors4;
  81772. private _vectors2;
  81773. private _vectors3;
  81774. private _matrices;
  81775. private _fallbackTexture;
  81776. private _fallbackTextureUsed;
  81777. private _engine;
  81778. private _cachedDefines;
  81779. private _contentUpdateId;
  81780. private _contentData;
  81781. /**
  81782. * Instantiates a new procedural texture.
  81783. * 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.
  81784. * This is the base class of any Procedural texture and contains most of the shareable code.
  81785. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81786. * @param name Define the name of the texture
  81787. * @param size Define the size of the texture to create
  81788. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81789. * @param scene Define the scene the texture belongs to
  81790. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81791. * @param generateMipMaps Define if the texture should creates mip maps or not
  81792. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81793. */
  81794. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81795. /**
  81796. * The effect that is created when initializing the post process.
  81797. * @returns The created effect corresponding the the postprocess.
  81798. */
  81799. getEffect(): Effect;
  81800. /**
  81801. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81802. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81803. */
  81804. getContent(): Nullable<ArrayBufferView>;
  81805. private _createIndexBuffer;
  81806. /** @hidden */
  81807. _rebuild(): void;
  81808. /**
  81809. * Resets the texture in order to recreate its associated resources.
  81810. * This can be called in case of context loss
  81811. */
  81812. reset(): void;
  81813. protected _getDefines(): string;
  81814. /**
  81815. * Is the texture ready to be used ? (rendered at least once)
  81816. * @returns true if ready, otherwise, false.
  81817. */
  81818. isReady(): boolean;
  81819. /**
  81820. * Resets the refresh counter of the texture and start bak from scratch.
  81821. * Could be useful to regenerate the texture if it is setup to render only once.
  81822. */
  81823. resetRefreshCounter(): void;
  81824. /**
  81825. * Set the fragment shader to use in order to render the texture.
  81826. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81827. */
  81828. setFragment(fragment: any): void;
  81829. /**
  81830. * Define the refresh rate of the texture or the rendering frequency.
  81831. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81832. */
  81833. refreshRate: number;
  81834. /** @hidden */
  81835. _shouldRender(): boolean;
  81836. /**
  81837. * Get the size the texture is rendering at.
  81838. * @returns the size (texture is always squared)
  81839. */
  81840. getRenderSize(): number;
  81841. /**
  81842. * Resize the texture to new value.
  81843. * @param size Define the new size the texture should have
  81844. * @param generateMipMaps Define whether the new texture should create mip maps
  81845. */
  81846. resize(size: number, generateMipMaps: boolean): void;
  81847. private _checkUniform;
  81848. /**
  81849. * Set a texture in the shader program used to render.
  81850. * @param name Define the name of the uniform samplers as defined in the shader
  81851. * @param texture Define the texture to bind to this sampler
  81852. * @return the texture itself allowing "fluent" like uniform updates
  81853. */
  81854. setTexture(name: string, texture: Texture): ProceduralTexture;
  81855. /**
  81856. * Set a float in the shader.
  81857. * @param name Define the name of the uniform as defined in the shader
  81858. * @param value Define the value to give to the uniform
  81859. * @return the texture itself allowing "fluent" like uniform updates
  81860. */
  81861. setFloat(name: string, value: number): ProceduralTexture;
  81862. /**
  81863. * Set a int in the shader.
  81864. * @param name Define the name of the uniform as defined in the shader
  81865. * @param value Define the value to give to the uniform
  81866. * @return the texture itself allowing "fluent" like uniform updates
  81867. */
  81868. setInt(name: string, value: number): ProceduralTexture;
  81869. /**
  81870. * Set an array of floats in the shader.
  81871. * @param name Define the name of the uniform as defined in the shader
  81872. * @param value Define the value to give to the uniform
  81873. * @return the texture itself allowing "fluent" like uniform updates
  81874. */
  81875. setFloats(name: string, value: number[]): ProceduralTexture;
  81876. /**
  81877. * Set a vec3 in the shader from a Color3.
  81878. * @param name Define the name of the uniform as defined in the shader
  81879. * @param value Define the value to give to the uniform
  81880. * @return the texture itself allowing "fluent" like uniform updates
  81881. */
  81882. setColor3(name: string, value: Color3): ProceduralTexture;
  81883. /**
  81884. * Set a vec4 in the shader from a Color4.
  81885. * @param name Define the name of the uniform as defined in the shader
  81886. * @param value Define the value to give to the uniform
  81887. * @return the texture itself allowing "fluent" like uniform updates
  81888. */
  81889. setColor4(name: string, value: Color4): ProceduralTexture;
  81890. /**
  81891. * Set a vec2 in the shader from a Vector2.
  81892. * @param name Define the name of the uniform as defined in the shader
  81893. * @param value Define the value to give to the uniform
  81894. * @return the texture itself allowing "fluent" like uniform updates
  81895. */
  81896. setVector2(name: string, value: Vector2): ProceduralTexture;
  81897. /**
  81898. * Set a vec3 in the shader from a Vector3.
  81899. * @param name Define the name of the uniform as defined in the shader
  81900. * @param value Define the value to give to the uniform
  81901. * @return the texture itself allowing "fluent" like uniform updates
  81902. */
  81903. setVector3(name: string, value: Vector3): ProceduralTexture;
  81904. /**
  81905. * Set a mat4 in the shader from a MAtrix.
  81906. * @param name Define the name of the uniform as defined in the shader
  81907. * @param value Define the value to give to the uniform
  81908. * @return the texture itself allowing "fluent" like uniform updates
  81909. */
  81910. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81911. /**
  81912. * Render the texture to its associated render target.
  81913. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81914. */
  81915. render(useCameraPostProcess?: boolean): void;
  81916. /**
  81917. * Clone the texture.
  81918. * @returns the cloned texture
  81919. */
  81920. clone(): ProceduralTexture;
  81921. /**
  81922. * Dispose the texture and release its asoociated resources.
  81923. */
  81924. dispose(): void;
  81925. }
  81926. }
  81927. declare module BABYLON {
  81928. /**
  81929. * This represents the base class for particle system in Babylon.
  81930. * 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.
  81931. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81932. * @example https://doc.babylonjs.com/babylon101/particles
  81933. */
  81934. export class BaseParticleSystem {
  81935. /**
  81936. * Source color is added to the destination color without alpha affecting the result
  81937. */
  81938. static BLENDMODE_ONEONE: number;
  81939. /**
  81940. * Blend current color and particle color using particle’s alpha
  81941. */
  81942. static BLENDMODE_STANDARD: number;
  81943. /**
  81944. * Add current color and particle color multiplied by particle’s alpha
  81945. */
  81946. static BLENDMODE_ADD: number;
  81947. /**
  81948. * Multiply current color with particle color
  81949. */
  81950. static BLENDMODE_MULTIPLY: number;
  81951. /**
  81952. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81953. */
  81954. static BLENDMODE_MULTIPLYADD: number;
  81955. /**
  81956. * List of animations used by the particle system.
  81957. */
  81958. animations: Animation[];
  81959. /**
  81960. * The id of the Particle system.
  81961. */
  81962. id: string;
  81963. /**
  81964. * The friendly name of the Particle system.
  81965. */
  81966. name: string;
  81967. /**
  81968. * The rendering group used by the Particle system to chose when to render.
  81969. */
  81970. renderingGroupId: number;
  81971. /**
  81972. * The emitter represents the Mesh or position we are attaching the particle system to.
  81973. */
  81974. emitter: Nullable<AbstractMesh | Vector3>;
  81975. /**
  81976. * The maximum number of particles to emit per frame
  81977. */
  81978. emitRate: number;
  81979. /**
  81980. * If you want to launch only a few particles at once, that can be done, as well.
  81981. */
  81982. manualEmitCount: number;
  81983. /**
  81984. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81985. */
  81986. updateSpeed: number;
  81987. /**
  81988. * The amount of time the particle system is running (depends of the overall update speed).
  81989. */
  81990. targetStopDuration: number;
  81991. /**
  81992. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81993. */
  81994. disposeOnStop: boolean;
  81995. /**
  81996. * Minimum power of emitting particles.
  81997. */
  81998. minEmitPower: number;
  81999. /**
  82000. * Maximum power of emitting particles.
  82001. */
  82002. maxEmitPower: number;
  82003. /**
  82004. * Minimum life time of emitting particles.
  82005. */
  82006. minLifeTime: number;
  82007. /**
  82008. * Maximum life time of emitting particles.
  82009. */
  82010. maxLifeTime: number;
  82011. /**
  82012. * Minimum Size of emitting particles.
  82013. */
  82014. minSize: number;
  82015. /**
  82016. * Maximum Size of emitting particles.
  82017. */
  82018. maxSize: number;
  82019. /**
  82020. * Minimum scale of emitting particles on X axis.
  82021. */
  82022. minScaleX: number;
  82023. /**
  82024. * Maximum scale of emitting particles on X axis.
  82025. */
  82026. maxScaleX: number;
  82027. /**
  82028. * Minimum scale of emitting particles on Y axis.
  82029. */
  82030. minScaleY: number;
  82031. /**
  82032. * Maximum scale of emitting particles on Y axis.
  82033. */
  82034. maxScaleY: number;
  82035. /**
  82036. * Gets or sets the minimal initial rotation in radians.
  82037. */
  82038. minInitialRotation: number;
  82039. /**
  82040. * Gets or sets the maximal initial rotation in radians.
  82041. */
  82042. maxInitialRotation: number;
  82043. /**
  82044. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82045. */
  82046. minAngularSpeed: number;
  82047. /**
  82048. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82049. */
  82050. maxAngularSpeed: number;
  82051. /**
  82052. * The texture used to render each particle. (this can be a spritesheet)
  82053. */
  82054. particleTexture: Nullable<Texture>;
  82055. /**
  82056. * The layer mask we are rendering the particles through.
  82057. */
  82058. layerMask: number;
  82059. /**
  82060. * This can help using your own shader to render the particle system.
  82061. * The according effect will be created
  82062. */
  82063. customShader: any;
  82064. /**
  82065. * By default particle system starts as soon as they are created. This prevents the
  82066. * automatic start to happen and let you decide when to start emitting particles.
  82067. */
  82068. preventAutoStart: boolean;
  82069. private _noiseTexture;
  82070. /**
  82071. * Gets or sets a texture used to add random noise to particle positions
  82072. */
  82073. noiseTexture: Nullable<ProceduralTexture>;
  82074. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82075. noiseStrength: Vector3;
  82076. /**
  82077. * Callback triggered when the particle animation is ending.
  82078. */
  82079. onAnimationEnd: Nullable<() => void>;
  82080. /**
  82081. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82082. */
  82083. blendMode: number;
  82084. /**
  82085. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82086. * to override the particles.
  82087. */
  82088. forceDepthWrite: boolean;
  82089. /** 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 */
  82090. preWarmCycles: number;
  82091. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82092. preWarmStepOffset: number;
  82093. /**
  82094. * 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)
  82095. */
  82096. spriteCellChangeSpeed: number;
  82097. /**
  82098. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82099. */
  82100. startSpriteCellID: number;
  82101. /**
  82102. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82103. */
  82104. endSpriteCellID: number;
  82105. /**
  82106. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82107. */
  82108. spriteCellWidth: number;
  82109. /**
  82110. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82111. */
  82112. spriteCellHeight: number;
  82113. /**
  82114. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82115. */
  82116. spriteRandomStartCell: boolean;
  82117. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82118. translationPivot: Vector2;
  82119. /** @hidden */
  82120. protected _isAnimationSheetEnabled: boolean;
  82121. /**
  82122. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82123. */
  82124. beginAnimationOnStart: boolean;
  82125. /**
  82126. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82127. */
  82128. beginAnimationFrom: number;
  82129. /**
  82130. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82131. */
  82132. beginAnimationTo: number;
  82133. /**
  82134. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82135. */
  82136. beginAnimationLoop: boolean;
  82137. /**
  82138. * Gets or sets a world offset applied to all particles
  82139. */
  82140. worldOffset: Vector3;
  82141. /**
  82142. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82143. */
  82144. isAnimationSheetEnabled: boolean;
  82145. /**
  82146. * Get hosting scene
  82147. * @returns the scene
  82148. */
  82149. getScene(): Scene;
  82150. /**
  82151. * You can use gravity if you want to give an orientation to your particles.
  82152. */
  82153. gravity: Vector3;
  82154. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82155. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82156. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82157. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82158. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82159. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82160. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82161. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82162. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82163. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82164. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82165. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82166. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82167. /**
  82168. * Defines the delay in milliseconds before starting the system (0 by default)
  82169. */
  82170. startDelay: number;
  82171. /**
  82172. * Gets the current list of drag gradients.
  82173. * You must use addDragGradient and removeDragGradient to udpate this list
  82174. * @returns the list of drag gradients
  82175. */
  82176. getDragGradients(): Nullable<Array<FactorGradient>>;
  82177. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82178. limitVelocityDamping: number;
  82179. /**
  82180. * Gets the current list of limit velocity gradients.
  82181. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82182. * @returns the list of limit velocity gradients
  82183. */
  82184. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82185. /**
  82186. * Gets the current list of color gradients.
  82187. * You must use addColorGradient and removeColorGradient to udpate this list
  82188. * @returns the list of color gradients
  82189. */
  82190. getColorGradients(): Nullable<Array<ColorGradient>>;
  82191. /**
  82192. * Gets the current list of size gradients.
  82193. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82194. * @returns the list of size gradients
  82195. */
  82196. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82197. /**
  82198. * Gets the current list of color remap gradients.
  82199. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82200. * @returns the list of color remap gradients
  82201. */
  82202. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82203. /**
  82204. * Gets the current list of alpha remap gradients.
  82205. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82206. * @returns the list of alpha remap gradients
  82207. */
  82208. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82209. /**
  82210. * Gets the current list of life time gradients.
  82211. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82212. * @returns the list of life time gradients
  82213. */
  82214. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82215. /**
  82216. * Gets the current list of angular speed gradients.
  82217. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82218. * @returns the list of angular speed gradients
  82219. */
  82220. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82221. /**
  82222. * Gets the current list of velocity gradients.
  82223. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82224. * @returns the list of velocity gradients
  82225. */
  82226. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82227. /**
  82228. * Gets the current list of start size gradients.
  82229. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82230. * @returns the list of start size gradients
  82231. */
  82232. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82233. /**
  82234. * Gets the current list of emit rate gradients.
  82235. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82236. * @returns the list of emit rate gradients
  82237. */
  82238. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82239. /**
  82240. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82241. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82242. */
  82243. direction1: Vector3;
  82244. /**
  82245. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82246. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82247. */
  82248. direction2: Vector3;
  82249. /**
  82250. * 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.
  82251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82252. */
  82253. minEmitBox: Vector3;
  82254. /**
  82255. * 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.
  82256. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82257. */
  82258. maxEmitBox: Vector3;
  82259. /**
  82260. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82261. */
  82262. color1: Color4;
  82263. /**
  82264. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82265. */
  82266. color2: Color4;
  82267. /**
  82268. * Color the particle will have at the end of its lifetime
  82269. */
  82270. colorDead: Color4;
  82271. /**
  82272. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82273. */
  82274. textureMask: Color4;
  82275. /**
  82276. * The particle emitter type defines the emitter used by the particle system.
  82277. * It can be for example box, sphere, or cone...
  82278. */
  82279. particleEmitterType: IParticleEmitterType;
  82280. /** @hidden */
  82281. _isSubEmitter: boolean;
  82282. /**
  82283. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82284. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82285. */
  82286. billboardMode: number;
  82287. protected _isBillboardBased: boolean;
  82288. /**
  82289. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82290. */
  82291. isBillboardBased: boolean;
  82292. /**
  82293. * The scene the particle system belongs to.
  82294. */
  82295. protected _scene: Scene;
  82296. /**
  82297. * Local cache of defines for image processing.
  82298. */
  82299. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82300. /**
  82301. * Default configuration related to image processing available in the standard Material.
  82302. */
  82303. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82304. /**
  82305. * Gets the image processing configuration used either in this material.
  82306. */
  82307. /**
  82308. * Sets the Default image processing configuration used either in the this material.
  82309. *
  82310. * If sets to null, the scene one is in use.
  82311. */
  82312. imageProcessingConfiguration: ImageProcessingConfiguration;
  82313. /**
  82314. * Attaches a new image processing configuration to the Standard Material.
  82315. * @param configuration
  82316. */
  82317. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82318. /** @hidden */
  82319. protected _reset(): void;
  82320. /** @hidden */
  82321. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82322. /**
  82323. * Instantiates a particle system.
  82324. * 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.
  82325. * @param name The name of the particle system
  82326. */
  82327. constructor(name: string);
  82328. /**
  82329. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82330. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82331. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82332. * @returns the emitter
  82333. */
  82334. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82335. /**
  82336. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82337. * @param radius The radius of the hemisphere to emit from
  82338. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82339. * @returns the emitter
  82340. */
  82341. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82342. /**
  82343. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82344. * @param radius The radius of the sphere to emit from
  82345. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82346. * @returns the emitter
  82347. */
  82348. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82349. /**
  82350. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82351. * @param radius The radius of the sphere to emit from
  82352. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82353. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82354. * @returns the emitter
  82355. */
  82356. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82357. /**
  82358. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82359. * @param radius The radius of the emission cylinder
  82360. * @param height The height of the emission cylinder
  82361. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82362. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82363. * @returns the emitter
  82364. */
  82365. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82366. /**
  82367. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82368. * @param radius The radius of the cylinder to emit from
  82369. * @param height The height of the emission cylinder
  82370. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82373. * @returns the emitter
  82374. */
  82375. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82376. /**
  82377. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82378. * @param radius The radius of the cone to emit from
  82379. * @param angle The base angle of the cone
  82380. * @returns the emitter
  82381. */
  82382. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82383. /**
  82384. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82385. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82386. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82387. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82388. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82389. * @returns the emitter
  82390. */
  82391. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82392. }
  82393. }
  82394. declare module BABYLON {
  82395. /**
  82396. * Type of sub emitter
  82397. */
  82398. export enum SubEmitterType {
  82399. /**
  82400. * Attached to the particle over it's lifetime
  82401. */
  82402. ATTACHED = 0,
  82403. /**
  82404. * Created when the particle dies
  82405. */
  82406. END = 1
  82407. }
  82408. /**
  82409. * Sub emitter class used to emit particles from an existing particle
  82410. */
  82411. export class SubEmitter {
  82412. /**
  82413. * the particle system to be used by the sub emitter
  82414. */
  82415. particleSystem: ParticleSystem;
  82416. /**
  82417. * Type of the submitter (Default: END)
  82418. */
  82419. type: SubEmitterType;
  82420. /**
  82421. * 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)
  82422. * Note: This only is supported when using an emitter of type Mesh
  82423. */
  82424. inheritDirection: boolean;
  82425. /**
  82426. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82427. */
  82428. inheritedVelocityAmount: number;
  82429. /**
  82430. * Creates a sub emitter
  82431. * @param particleSystem the particle system to be used by the sub emitter
  82432. */
  82433. constructor(
  82434. /**
  82435. * the particle system to be used by the sub emitter
  82436. */
  82437. particleSystem: ParticleSystem);
  82438. /**
  82439. * Clones the sub emitter
  82440. * @returns the cloned sub emitter
  82441. */
  82442. clone(): SubEmitter;
  82443. /**
  82444. * Serialize current object to a JSON object
  82445. * @returns the serialized object
  82446. */
  82447. serialize(): any;
  82448. /** @hidden */
  82449. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82450. /**
  82451. * Creates a new SubEmitter from a serialized JSON version
  82452. * @param serializationObject defines the JSON object to read from
  82453. * @param scene defines the hosting scene
  82454. * @param rootUrl defines the rootUrl for data loading
  82455. * @returns a new SubEmitter
  82456. */
  82457. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82458. /** Release associated resources */
  82459. dispose(): void;
  82460. }
  82461. }
  82462. declare module BABYLON {
  82463. /** @hidden */
  82464. export var imageProcessingDeclaration: {
  82465. name: string;
  82466. shader: string;
  82467. };
  82468. }
  82469. declare module BABYLON {
  82470. /** @hidden */
  82471. export var imageProcessingFunctions: {
  82472. name: string;
  82473. shader: string;
  82474. };
  82475. }
  82476. declare module BABYLON {
  82477. /** @hidden */
  82478. export var particlesPixelShader: {
  82479. name: string;
  82480. shader: string;
  82481. };
  82482. }
  82483. declare module BABYLON {
  82484. /** @hidden */
  82485. export var particlesVertexShader: {
  82486. name: string;
  82487. shader: string;
  82488. };
  82489. }
  82490. declare module BABYLON {
  82491. /**
  82492. * This represents a particle system in Babylon.
  82493. * 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.
  82494. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82495. * @example https://doc.babylonjs.com/babylon101/particles
  82496. */
  82497. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82498. /**
  82499. * Billboard mode will only apply to Y axis
  82500. */
  82501. static readonly BILLBOARDMODE_Y: number;
  82502. /**
  82503. * Billboard mode will apply to all axes
  82504. */
  82505. static readonly BILLBOARDMODE_ALL: number;
  82506. /**
  82507. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82508. */
  82509. static readonly BILLBOARDMODE_STRETCHED: number;
  82510. /**
  82511. * This function can be defined to provide custom update for active particles.
  82512. * This function will be called instead of regular update (age, position, color, etc.).
  82513. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82514. */
  82515. updateFunction: (particles: Particle[]) => void;
  82516. private _emitterWorldMatrix;
  82517. /**
  82518. * This function can be defined to specify initial direction for every new particle.
  82519. * It by default use the emitterType defined function
  82520. */
  82521. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82522. /**
  82523. * This function can be defined to specify initial position for every new particle.
  82524. * It by default use the emitterType defined function
  82525. */
  82526. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82527. /**
  82528. * @hidden
  82529. */
  82530. _inheritedVelocityOffset: Vector3;
  82531. /**
  82532. * An event triggered when the system is disposed
  82533. */
  82534. onDisposeObservable: Observable<ParticleSystem>;
  82535. private _onDisposeObserver;
  82536. /**
  82537. * Sets a callback that will be triggered when the system is disposed
  82538. */
  82539. onDispose: () => void;
  82540. private _particles;
  82541. private _epsilon;
  82542. private _capacity;
  82543. private _stockParticles;
  82544. private _newPartsExcess;
  82545. private _vertexData;
  82546. private _vertexBuffer;
  82547. private _vertexBuffers;
  82548. private _spriteBuffer;
  82549. private _indexBuffer;
  82550. private _effect;
  82551. private _customEffect;
  82552. private _cachedDefines;
  82553. private _scaledColorStep;
  82554. private _colorDiff;
  82555. private _scaledDirection;
  82556. private _scaledGravity;
  82557. private _currentRenderId;
  82558. private _alive;
  82559. private _useInstancing;
  82560. private _started;
  82561. private _stopped;
  82562. private _actualFrame;
  82563. private _scaledUpdateSpeed;
  82564. private _vertexBufferSize;
  82565. /** @hidden */
  82566. _currentEmitRateGradient: Nullable<FactorGradient>;
  82567. /** @hidden */
  82568. _currentEmitRate1: number;
  82569. /** @hidden */
  82570. _currentEmitRate2: number;
  82571. /** @hidden */
  82572. _currentStartSizeGradient: Nullable<FactorGradient>;
  82573. /** @hidden */
  82574. _currentStartSize1: number;
  82575. /** @hidden */
  82576. _currentStartSize2: number;
  82577. private readonly _rawTextureWidth;
  82578. private _rampGradientsTexture;
  82579. private _useRampGradients;
  82580. /** Gets or sets a boolean indicating that ramp gradients must be used
  82581. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82582. */
  82583. useRampGradients: boolean;
  82584. /**
  82585. * 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.
  82586. * 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: [])
  82587. */
  82588. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82589. private _subEmitters;
  82590. /**
  82591. * @hidden
  82592. * If the particle systems emitter should be disposed when the particle system is disposed
  82593. */
  82594. _disposeEmitterOnDispose: boolean;
  82595. /**
  82596. * The current active Sub-systems, this property is used by the root particle system only.
  82597. */
  82598. activeSubSystems: Array<ParticleSystem>;
  82599. private _rootParticleSystem;
  82600. /**
  82601. * Gets the current list of active particles
  82602. */
  82603. readonly particles: Particle[];
  82604. /**
  82605. * Returns the string "ParticleSystem"
  82606. * @returns a string containing the class name
  82607. */
  82608. getClassName(): string;
  82609. /**
  82610. * Instantiates a particle system.
  82611. * 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.
  82612. * @param name The name of the particle system
  82613. * @param capacity The max number of particles alive at the same time
  82614. * @param scene The scene the particle system belongs to
  82615. * @param customEffect a custom effect used to change the way particles are rendered by default
  82616. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82617. * @param epsilon Offset used to render the particles
  82618. */
  82619. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82620. private _addFactorGradient;
  82621. private _removeFactorGradient;
  82622. /**
  82623. * Adds a new life time gradient
  82624. * @param gradient defines the gradient to use (between 0 and 1)
  82625. * @param factor defines the life time factor to affect to the specified gradient
  82626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82627. * @returns the current particle system
  82628. */
  82629. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82630. /**
  82631. * Remove a specific life time gradient
  82632. * @param gradient defines the gradient to remove
  82633. * @returns the current particle system
  82634. */
  82635. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82636. /**
  82637. * Adds a new size gradient
  82638. * @param gradient defines the gradient to use (between 0 and 1)
  82639. * @param factor defines the size factor to affect to the specified gradient
  82640. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82641. * @returns the current particle system
  82642. */
  82643. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82644. /**
  82645. * Remove a specific size gradient
  82646. * @param gradient defines the gradient to remove
  82647. * @returns the current particle system
  82648. */
  82649. removeSizeGradient(gradient: number): IParticleSystem;
  82650. /**
  82651. * Adds a new color remap gradient
  82652. * @param gradient defines the gradient to use (between 0 and 1)
  82653. * @param min defines the color remap minimal range
  82654. * @param max defines the color remap maximal range
  82655. * @returns the current particle system
  82656. */
  82657. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82658. /**
  82659. * Remove a specific color remap gradient
  82660. * @param gradient defines the gradient to remove
  82661. * @returns the current particle system
  82662. */
  82663. removeColorRemapGradient(gradient: number): IParticleSystem;
  82664. /**
  82665. * Adds a new alpha remap gradient
  82666. * @param gradient defines the gradient to use (between 0 and 1)
  82667. * @param min defines the alpha remap minimal range
  82668. * @param max defines the alpha remap maximal range
  82669. * @returns the current particle system
  82670. */
  82671. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82672. /**
  82673. * Remove a specific alpha remap gradient
  82674. * @param gradient defines the gradient to remove
  82675. * @returns the current particle system
  82676. */
  82677. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82678. /**
  82679. * Adds a new angular speed gradient
  82680. * @param gradient defines the gradient to use (between 0 and 1)
  82681. * @param factor defines the angular speed to affect to the specified gradient
  82682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82683. * @returns the current particle system
  82684. */
  82685. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82686. /**
  82687. * Remove a specific angular speed gradient
  82688. * @param gradient defines the gradient to remove
  82689. * @returns the current particle system
  82690. */
  82691. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82692. /**
  82693. * Adds a new velocity gradient
  82694. * @param gradient defines the gradient to use (between 0 and 1)
  82695. * @param factor defines the velocity to affect to the specified gradient
  82696. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82697. * @returns the current particle system
  82698. */
  82699. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82700. /**
  82701. * Remove a specific velocity gradient
  82702. * @param gradient defines the gradient to remove
  82703. * @returns the current particle system
  82704. */
  82705. removeVelocityGradient(gradient: number): IParticleSystem;
  82706. /**
  82707. * Adds a new limit velocity gradient
  82708. * @param gradient defines the gradient to use (between 0 and 1)
  82709. * @param factor defines the limit velocity value to affect to the specified gradient
  82710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82711. * @returns the current particle system
  82712. */
  82713. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82714. /**
  82715. * Remove a specific limit velocity gradient
  82716. * @param gradient defines the gradient to remove
  82717. * @returns the current particle system
  82718. */
  82719. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82720. /**
  82721. * Adds a new drag gradient
  82722. * @param gradient defines the gradient to use (between 0 and 1)
  82723. * @param factor defines the drag value to affect to the specified gradient
  82724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82725. * @returns the current particle system
  82726. */
  82727. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82728. /**
  82729. * Remove a specific drag gradient
  82730. * @param gradient defines the gradient to remove
  82731. * @returns the current particle system
  82732. */
  82733. removeDragGradient(gradient: number): IParticleSystem;
  82734. /**
  82735. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82736. * @param gradient defines the gradient to use (between 0 and 1)
  82737. * @param factor defines the emit rate value to affect to the specified gradient
  82738. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82739. * @returns the current particle system
  82740. */
  82741. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82742. /**
  82743. * Remove a specific emit rate gradient
  82744. * @param gradient defines the gradient to remove
  82745. * @returns the current particle system
  82746. */
  82747. removeEmitRateGradient(gradient: number): IParticleSystem;
  82748. /**
  82749. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82750. * @param gradient defines the gradient to use (between 0 and 1)
  82751. * @param factor defines the start size value to affect to the specified gradient
  82752. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82753. * @returns the current particle system
  82754. */
  82755. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82756. /**
  82757. * Remove a specific start size gradient
  82758. * @param gradient defines the gradient to remove
  82759. * @returns the current particle system
  82760. */
  82761. removeStartSizeGradient(gradient: number): IParticleSystem;
  82762. private _createRampGradientTexture;
  82763. /**
  82764. * Gets the current list of ramp gradients.
  82765. * You must use addRampGradient and removeRampGradient to udpate this list
  82766. * @returns the list of ramp gradients
  82767. */
  82768. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82769. /**
  82770. * Adds a new ramp gradient used to remap particle colors
  82771. * @param gradient defines the gradient to use (between 0 and 1)
  82772. * @param color defines the color to affect to the specified gradient
  82773. * @returns the current particle system
  82774. */
  82775. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82776. /**
  82777. * Remove a specific ramp gradient
  82778. * @param gradient defines the gradient to remove
  82779. * @returns the current particle system
  82780. */
  82781. removeRampGradient(gradient: number): ParticleSystem;
  82782. /**
  82783. * Adds a new color gradient
  82784. * @param gradient defines the gradient to use (between 0 and 1)
  82785. * @param color1 defines the color to affect to the specified gradient
  82786. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82787. * @returns this particle system
  82788. */
  82789. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82790. /**
  82791. * Remove a specific color gradient
  82792. * @param gradient defines the gradient to remove
  82793. * @returns this particle system
  82794. */
  82795. removeColorGradient(gradient: number): IParticleSystem;
  82796. private _fetchR;
  82797. protected _reset(): void;
  82798. private _resetEffect;
  82799. private _createVertexBuffers;
  82800. private _createIndexBuffer;
  82801. /**
  82802. * Gets the maximum number of particles active at the same time.
  82803. * @returns The max number of active particles.
  82804. */
  82805. getCapacity(): number;
  82806. /**
  82807. * Gets whether there are still active particles in the system.
  82808. * @returns True if it is alive, otherwise false.
  82809. */
  82810. isAlive(): boolean;
  82811. /**
  82812. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82813. * @returns True if it has been started, otherwise false.
  82814. */
  82815. isStarted(): boolean;
  82816. private _prepareSubEmitterInternalArray;
  82817. /**
  82818. * Starts the particle system and begins to emit
  82819. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82820. */
  82821. start(delay?: number): void;
  82822. /**
  82823. * Stops the particle system.
  82824. * @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.
  82825. */
  82826. stop(stopSubEmitters?: boolean): void;
  82827. /**
  82828. * Remove all active particles
  82829. */
  82830. reset(): void;
  82831. /**
  82832. * @hidden (for internal use only)
  82833. */
  82834. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82835. /**
  82836. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82837. * Its lifetime will start back at 0.
  82838. */
  82839. recycleParticle: (particle: Particle) => void;
  82840. private _stopSubEmitters;
  82841. private _createParticle;
  82842. private _removeFromRoot;
  82843. private _emitFromParticle;
  82844. private _update;
  82845. /** @hidden */
  82846. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82847. /** @hidden */
  82848. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82849. /** @hidden */
  82850. private _getEffect;
  82851. /**
  82852. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82853. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82854. */
  82855. animate(preWarmOnly?: boolean): void;
  82856. private _appendParticleVertices;
  82857. /**
  82858. * Rebuilds the particle system.
  82859. */
  82860. rebuild(): void;
  82861. /**
  82862. * Is this system ready to be used/rendered
  82863. * @return true if the system is ready
  82864. */
  82865. isReady(): boolean;
  82866. private _render;
  82867. /**
  82868. * Renders the particle system in its current state.
  82869. * @returns the current number of particles
  82870. */
  82871. render(): number;
  82872. /**
  82873. * Disposes the particle system and free the associated resources
  82874. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82875. */
  82876. dispose(disposeTexture?: boolean): void;
  82877. /**
  82878. * Clones the particle system.
  82879. * @param name The name of the cloned object
  82880. * @param newEmitter The new emitter to use
  82881. * @returns the cloned particle system
  82882. */
  82883. clone(name: string, newEmitter: any): ParticleSystem;
  82884. /**
  82885. * Serializes the particle system to a JSON object.
  82886. * @returns the JSON object
  82887. */
  82888. serialize(): any;
  82889. /** @hidden */
  82890. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82891. /** @hidden */
  82892. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82893. /**
  82894. * Parses a JSON object to create a particle system.
  82895. * @param parsedParticleSystem The JSON object to parse
  82896. * @param scene The scene to create the particle system in
  82897. * @param rootUrl The root url to use to load external dependencies like texture
  82898. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82899. * @returns the Parsed particle system
  82900. */
  82901. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82902. }
  82903. }
  82904. declare module BABYLON {
  82905. /**
  82906. * A particle represents one of the element emitted by a particle system.
  82907. * This is mainly define by its coordinates, direction, velocity and age.
  82908. */
  82909. export class Particle {
  82910. /**
  82911. * The particle system the particle belongs to.
  82912. */
  82913. particleSystem: ParticleSystem;
  82914. private static _Count;
  82915. /**
  82916. * Unique ID of the particle
  82917. */
  82918. id: number;
  82919. /**
  82920. * The world position of the particle in the scene.
  82921. */
  82922. position: Vector3;
  82923. /**
  82924. * The world direction of the particle in the scene.
  82925. */
  82926. direction: Vector3;
  82927. /**
  82928. * The color of the particle.
  82929. */
  82930. color: Color4;
  82931. /**
  82932. * The color change of the particle per step.
  82933. */
  82934. colorStep: Color4;
  82935. /**
  82936. * Defines how long will the life of the particle be.
  82937. */
  82938. lifeTime: number;
  82939. /**
  82940. * The current age of the particle.
  82941. */
  82942. age: number;
  82943. /**
  82944. * The current size of the particle.
  82945. */
  82946. size: number;
  82947. /**
  82948. * The current scale of the particle.
  82949. */
  82950. scale: Vector2;
  82951. /**
  82952. * The current angle of the particle.
  82953. */
  82954. angle: number;
  82955. /**
  82956. * Defines how fast is the angle changing.
  82957. */
  82958. angularSpeed: number;
  82959. /**
  82960. * Defines the cell index used by the particle to be rendered from a sprite.
  82961. */
  82962. cellIndex: number;
  82963. /**
  82964. * The information required to support color remapping
  82965. */
  82966. remapData: Vector4;
  82967. /** @hidden */
  82968. _randomCellOffset?: number;
  82969. /** @hidden */
  82970. _initialDirection: Nullable<Vector3>;
  82971. /** @hidden */
  82972. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82973. /** @hidden */
  82974. _initialStartSpriteCellID: number;
  82975. /** @hidden */
  82976. _initialEndSpriteCellID: number;
  82977. /** @hidden */
  82978. _currentColorGradient: Nullable<ColorGradient>;
  82979. /** @hidden */
  82980. _currentColor1: Color4;
  82981. /** @hidden */
  82982. _currentColor2: Color4;
  82983. /** @hidden */
  82984. _currentSizeGradient: Nullable<FactorGradient>;
  82985. /** @hidden */
  82986. _currentSize1: number;
  82987. /** @hidden */
  82988. _currentSize2: number;
  82989. /** @hidden */
  82990. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82991. /** @hidden */
  82992. _currentAngularSpeed1: number;
  82993. /** @hidden */
  82994. _currentAngularSpeed2: number;
  82995. /** @hidden */
  82996. _currentVelocityGradient: Nullable<FactorGradient>;
  82997. /** @hidden */
  82998. _currentVelocity1: number;
  82999. /** @hidden */
  83000. _currentVelocity2: number;
  83001. /** @hidden */
  83002. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83003. /** @hidden */
  83004. _currentLimitVelocity1: number;
  83005. /** @hidden */
  83006. _currentLimitVelocity2: number;
  83007. /** @hidden */
  83008. _currentDragGradient: Nullable<FactorGradient>;
  83009. /** @hidden */
  83010. _currentDrag1: number;
  83011. /** @hidden */
  83012. _currentDrag2: number;
  83013. /** @hidden */
  83014. _randomNoiseCoordinates1: Vector3;
  83015. /** @hidden */
  83016. _randomNoiseCoordinates2: Vector3;
  83017. /**
  83018. * Creates a new instance Particle
  83019. * @param particleSystem the particle system the particle belongs to
  83020. */
  83021. constructor(
  83022. /**
  83023. * The particle system the particle belongs to.
  83024. */
  83025. particleSystem: ParticleSystem);
  83026. private updateCellInfoFromSystem;
  83027. /**
  83028. * Defines how the sprite cell index is updated for the particle
  83029. */
  83030. updateCellIndex(): void;
  83031. /** @hidden */
  83032. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83033. /** @hidden */
  83034. _inheritParticleInfoToSubEmitters(): void;
  83035. /** @hidden */
  83036. _reset(): void;
  83037. /**
  83038. * Copy the properties of particle to another one.
  83039. * @param other the particle to copy the information to.
  83040. */
  83041. copyTo(other: Particle): void;
  83042. }
  83043. }
  83044. declare module BABYLON {
  83045. /**
  83046. * Particle emitter represents a volume emitting particles.
  83047. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83048. */
  83049. export interface IParticleEmitterType {
  83050. /**
  83051. * Called by the particle System when the direction is computed for the created particle.
  83052. * @param worldMatrix is the world matrix of the particle system
  83053. * @param directionToUpdate is the direction vector to update with the result
  83054. * @param particle is the particle we are computed the direction for
  83055. */
  83056. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83057. /**
  83058. * Called by the particle System when the position is computed for the created particle.
  83059. * @param worldMatrix is the world matrix of the particle system
  83060. * @param positionToUpdate is the position vector to update with the result
  83061. * @param particle is the particle we are computed the position for
  83062. */
  83063. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83064. /**
  83065. * Clones the current emitter and returns a copy of it
  83066. * @returns the new emitter
  83067. */
  83068. clone(): IParticleEmitterType;
  83069. /**
  83070. * Called by the GPUParticleSystem to setup the update shader
  83071. * @param effect defines the update shader
  83072. */
  83073. applyToShader(effect: Effect): void;
  83074. /**
  83075. * Returns a string to use to update the GPU particles update shader
  83076. * @returns the effect defines string
  83077. */
  83078. getEffectDefines(): string;
  83079. /**
  83080. * Returns a string representing the class name
  83081. * @returns a string containing the class name
  83082. */
  83083. getClassName(): string;
  83084. /**
  83085. * Serializes the particle system to a JSON object.
  83086. * @returns the JSON object
  83087. */
  83088. serialize(): any;
  83089. /**
  83090. * Parse properties from a JSON object
  83091. * @param serializationObject defines the JSON object
  83092. */
  83093. parse(serializationObject: any): void;
  83094. }
  83095. }
  83096. declare module BABYLON {
  83097. /**
  83098. * Particle emitter emitting particles from the inside of a box.
  83099. * It emits the particles randomly between 2 given directions.
  83100. */
  83101. export class BoxParticleEmitter implements IParticleEmitterType {
  83102. /**
  83103. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83104. */
  83105. direction1: Vector3;
  83106. /**
  83107. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83108. */
  83109. direction2: Vector3;
  83110. /**
  83111. * 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.
  83112. */
  83113. minEmitBox: Vector3;
  83114. /**
  83115. * 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.
  83116. */
  83117. maxEmitBox: Vector3;
  83118. /**
  83119. * Creates a new instance BoxParticleEmitter
  83120. */
  83121. constructor();
  83122. /**
  83123. * Called by the particle System when the direction is computed for the created particle.
  83124. * @param worldMatrix is the world matrix of the particle system
  83125. * @param directionToUpdate is the direction vector to update with the result
  83126. * @param particle is the particle we are computed the direction for
  83127. */
  83128. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83129. /**
  83130. * Called by the particle System when the position is computed for the created particle.
  83131. * @param worldMatrix is the world matrix of the particle system
  83132. * @param positionToUpdate is the position vector to update with the result
  83133. * @param particle is the particle we are computed the position for
  83134. */
  83135. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83136. /**
  83137. * Clones the current emitter and returns a copy of it
  83138. * @returns the new emitter
  83139. */
  83140. clone(): BoxParticleEmitter;
  83141. /**
  83142. * Called by the GPUParticleSystem to setup the update shader
  83143. * @param effect defines the update shader
  83144. */
  83145. applyToShader(effect: Effect): void;
  83146. /**
  83147. * Returns a string to use to update the GPU particles update shader
  83148. * @returns a string containng the defines string
  83149. */
  83150. getEffectDefines(): string;
  83151. /**
  83152. * Returns the string "BoxParticleEmitter"
  83153. * @returns a string containing the class name
  83154. */
  83155. getClassName(): string;
  83156. /**
  83157. * Serializes the particle system to a JSON object.
  83158. * @returns the JSON object
  83159. */
  83160. serialize(): any;
  83161. /**
  83162. * Parse properties from a JSON object
  83163. * @param serializationObject defines the JSON object
  83164. */
  83165. parse(serializationObject: any): void;
  83166. }
  83167. }
  83168. declare module BABYLON {
  83169. /**
  83170. * Particle emitter emitting particles from the inside of a cone.
  83171. * It emits the particles alongside the cone volume from the base to the particle.
  83172. * The emission direction might be randomized.
  83173. */
  83174. export class ConeParticleEmitter implements IParticleEmitterType {
  83175. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83176. directionRandomizer: number;
  83177. private _radius;
  83178. private _angle;
  83179. private _height;
  83180. /**
  83181. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83182. */
  83183. radiusRange: number;
  83184. /**
  83185. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83186. */
  83187. heightRange: number;
  83188. /**
  83189. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83190. */
  83191. emitFromSpawnPointOnly: boolean;
  83192. /**
  83193. * Gets or sets the radius of the emission cone
  83194. */
  83195. radius: number;
  83196. /**
  83197. * Gets or sets the angle of the emission cone
  83198. */
  83199. angle: number;
  83200. private _buildHeight;
  83201. /**
  83202. * Creates a new instance ConeParticleEmitter
  83203. * @param radius the radius of the emission cone (1 by default)
  83204. * @param angle the cone base angle (PI by default)
  83205. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83206. */
  83207. constructor(radius?: number, angle?: number,
  83208. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83209. directionRandomizer?: number);
  83210. /**
  83211. * Called by the particle System when the direction is computed for the created particle.
  83212. * @param worldMatrix is the world matrix of the particle system
  83213. * @param directionToUpdate is the direction vector to update with the result
  83214. * @param particle is the particle we are computed the direction for
  83215. */
  83216. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83217. /**
  83218. * Called by the particle System when the position is computed for the created particle.
  83219. * @param worldMatrix is the world matrix of the particle system
  83220. * @param positionToUpdate is the position vector to update with the result
  83221. * @param particle is the particle we are computed the position for
  83222. */
  83223. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83224. /**
  83225. * Clones the current emitter and returns a copy of it
  83226. * @returns the new emitter
  83227. */
  83228. clone(): ConeParticleEmitter;
  83229. /**
  83230. * Called by the GPUParticleSystem to setup the update shader
  83231. * @param effect defines the update shader
  83232. */
  83233. applyToShader(effect: Effect): void;
  83234. /**
  83235. * Returns a string to use to update the GPU particles update shader
  83236. * @returns a string containng the defines string
  83237. */
  83238. getEffectDefines(): string;
  83239. /**
  83240. * Returns the string "ConeParticleEmitter"
  83241. * @returns a string containing the class name
  83242. */
  83243. getClassName(): string;
  83244. /**
  83245. * Serializes the particle system to a JSON object.
  83246. * @returns the JSON object
  83247. */
  83248. serialize(): any;
  83249. /**
  83250. * Parse properties from a JSON object
  83251. * @param serializationObject defines the JSON object
  83252. */
  83253. parse(serializationObject: any): void;
  83254. }
  83255. }
  83256. declare module BABYLON {
  83257. /**
  83258. * Particle emitter emitting particles from the inside of a cylinder.
  83259. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83260. */
  83261. export class CylinderParticleEmitter implements IParticleEmitterType {
  83262. /**
  83263. * The radius of the emission cylinder.
  83264. */
  83265. radius: number;
  83266. /**
  83267. * The height of the emission cylinder.
  83268. */
  83269. height: number;
  83270. /**
  83271. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83272. */
  83273. radiusRange: number;
  83274. /**
  83275. * How much to randomize the particle direction [0-1].
  83276. */
  83277. directionRandomizer: number;
  83278. /**
  83279. * Creates a new instance CylinderParticleEmitter
  83280. * @param radius the radius of the emission cylinder (1 by default)
  83281. * @param height the height of the emission cylinder (1 by default)
  83282. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83283. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83284. */
  83285. constructor(
  83286. /**
  83287. * The radius of the emission cylinder.
  83288. */
  83289. radius?: number,
  83290. /**
  83291. * The height of the emission cylinder.
  83292. */
  83293. height?: number,
  83294. /**
  83295. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83296. */
  83297. radiusRange?: number,
  83298. /**
  83299. * How much to randomize the particle direction [0-1].
  83300. */
  83301. directionRandomizer?: number);
  83302. /**
  83303. * Called by the particle System when the direction is computed for the created particle.
  83304. * @param worldMatrix is the world matrix of the particle system
  83305. * @param directionToUpdate is the direction vector to update with the result
  83306. * @param particle is the particle we are computed the direction for
  83307. */
  83308. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83309. /**
  83310. * Called by the particle System when the position is computed for the created particle.
  83311. * @param worldMatrix is the world matrix of the particle system
  83312. * @param positionToUpdate is the position vector to update with the result
  83313. * @param particle is the particle we are computed the position for
  83314. */
  83315. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83316. /**
  83317. * Clones the current emitter and returns a copy of it
  83318. * @returns the new emitter
  83319. */
  83320. clone(): CylinderParticleEmitter;
  83321. /**
  83322. * Called by the GPUParticleSystem to setup the update shader
  83323. * @param effect defines the update shader
  83324. */
  83325. applyToShader(effect: Effect): void;
  83326. /**
  83327. * Returns a string to use to update the GPU particles update shader
  83328. * @returns a string containng the defines string
  83329. */
  83330. getEffectDefines(): string;
  83331. /**
  83332. * Returns the string "CylinderParticleEmitter"
  83333. * @returns a string containing the class name
  83334. */
  83335. getClassName(): string;
  83336. /**
  83337. * Serializes the particle system to a JSON object.
  83338. * @returns the JSON object
  83339. */
  83340. serialize(): any;
  83341. /**
  83342. * Parse properties from a JSON object
  83343. * @param serializationObject defines the JSON object
  83344. */
  83345. parse(serializationObject: any): void;
  83346. }
  83347. /**
  83348. * Particle emitter emitting particles from the inside of a cylinder.
  83349. * It emits the particles randomly between two vectors.
  83350. */
  83351. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83352. /**
  83353. * The min limit of the emission direction.
  83354. */
  83355. direction1: Vector3;
  83356. /**
  83357. * The max limit of the emission direction.
  83358. */
  83359. direction2: Vector3;
  83360. /**
  83361. * Creates a new instance CylinderDirectedParticleEmitter
  83362. * @param radius the radius of the emission cylinder (1 by default)
  83363. * @param height the height of the emission cylinder (1 by default)
  83364. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83365. * @param direction1 the min limit of the emission direction (up vector by default)
  83366. * @param direction2 the max limit of the emission direction (up vector by default)
  83367. */
  83368. constructor(radius?: number, height?: number, radiusRange?: number,
  83369. /**
  83370. * The min limit of the emission direction.
  83371. */
  83372. direction1?: Vector3,
  83373. /**
  83374. * The max limit of the emission direction.
  83375. */
  83376. direction2?: Vector3);
  83377. /**
  83378. * Called by the particle System when the direction is computed for the created particle.
  83379. * @param worldMatrix is the world matrix of the particle system
  83380. * @param directionToUpdate is the direction vector to update with the result
  83381. * @param particle is the particle we are computed the direction for
  83382. */
  83383. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83384. /**
  83385. * Clones the current emitter and returns a copy of it
  83386. * @returns the new emitter
  83387. */
  83388. clone(): CylinderDirectedParticleEmitter;
  83389. /**
  83390. * Called by the GPUParticleSystem to setup the update shader
  83391. * @param effect defines the update shader
  83392. */
  83393. applyToShader(effect: Effect): void;
  83394. /**
  83395. * Returns a string to use to update the GPU particles update shader
  83396. * @returns a string containng the defines string
  83397. */
  83398. getEffectDefines(): string;
  83399. /**
  83400. * Returns the string "CylinderDirectedParticleEmitter"
  83401. * @returns a string containing the class name
  83402. */
  83403. getClassName(): string;
  83404. /**
  83405. * Serializes the particle system to a JSON object.
  83406. * @returns the JSON object
  83407. */
  83408. serialize(): any;
  83409. /**
  83410. * Parse properties from a JSON object
  83411. * @param serializationObject defines the JSON object
  83412. */
  83413. parse(serializationObject: any): void;
  83414. }
  83415. }
  83416. declare module BABYLON {
  83417. /**
  83418. * Particle emitter emitting particles from the inside of a hemisphere.
  83419. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83420. */
  83421. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83422. /**
  83423. * The radius of the emission hemisphere.
  83424. */
  83425. radius: number;
  83426. /**
  83427. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83428. */
  83429. radiusRange: number;
  83430. /**
  83431. * How much to randomize the particle direction [0-1].
  83432. */
  83433. directionRandomizer: number;
  83434. /**
  83435. * Creates a new instance HemisphericParticleEmitter
  83436. * @param radius the radius of the emission hemisphere (1 by default)
  83437. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83438. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83439. */
  83440. constructor(
  83441. /**
  83442. * The radius of the emission hemisphere.
  83443. */
  83444. radius?: number,
  83445. /**
  83446. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83447. */
  83448. radiusRange?: number,
  83449. /**
  83450. * How much to randomize the particle direction [0-1].
  83451. */
  83452. directionRandomizer?: number);
  83453. /**
  83454. * Called by the particle System when the direction is computed for the created particle.
  83455. * @param worldMatrix is the world matrix of the particle system
  83456. * @param directionToUpdate is the direction vector to update with the result
  83457. * @param particle is the particle we are computed the direction for
  83458. */
  83459. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83460. /**
  83461. * Called by the particle System when the position is computed for the created particle.
  83462. * @param worldMatrix is the world matrix of the particle system
  83463. * @param positionToUpdate is the position vector to update with the result
  83464. * @param particle is the particle we are computed the position for
  83465. */
  83466. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83467. /**
  83468. * Clones the current emitter and returns a copy of it
  83469. * @returns the new emitter
  83470. */
  83471. clone(): HemisphericParticleEmitter;
  83472. /**
  83473. * Called by the GPUParticleSystem to setup the update shader
  83474. * @param effect defines the update shader
  83475. */
  83476. applyToShader(effect: Effect): void;
  83477. /**
  83478. * Returns a string to use to update the GPU particles update shader
  83479. * @returns a string containng the defines string
  83480. */
  83481. getEffectDefines(): string;
  83482. /**
  83483. * Returns the string "HemisphericParticleEmitter"
  83484. * @returns a string containing the class name
  83485. */
  83486. getClassName(): string;
  83487. /**
  83488. * Serializes the particle system to a JSON object.
  83489. * @returns the JSON object
  83490. */
  83491. serialize(): any;
  83492. /**
  83493. * Parse properties from a JSON object
  83494. * @param serializationObject defines the JSON object
  83495. */
  83496. parse(serializationObject: any): void;
  83497. }
  83498. }
  83499. declare module BABYLON {
  83500. /**
  83501. * Particle emitter emitting particles from a point.
  83502. * It emits the particles randomly between 2 given directions.
  83503. */
  83504. export class PointParticleEmitter implements IParticleEmitterType {
  83505. /**
  83506. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83507. */
  83508. direction1: Vector3;
  83509. /**
  83510. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83511. */
  83512. direction2: Vector3;
  83513. /**
  83514. * Creates a new instance PointParticleEmitter
  83515. */
  83516. constructor();
  83517. /**
  83518. * Called by the particle System when the direction is computed for the created particle.
  83519. * @param worldMatrix is the world matrix of the particle system
  83520. * @param directionToUpdate is the direction vector to update with the result
  83521. * @param particle is the particle we are computed the direction for
  83522. */
  83523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83524. /**
  83525. * Called by the particle System when the position is computed for the created particle.
  83526. * @param worldMatrix is the world matrix of the particle system
  83527. * @param positionToUpdate is the position vector to update with the result
  83528. * @param particle is the particle we are computed the position for
  83529. */
  83530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83531. /**
  83532. * Clones the current emitter and returns a copy of it
  83533. * @returns the new emitter
  83534. */
  83535. clone(): PointParticleEmitter;
  83536. /**
  83537. * Called by the GPUParticleSystem to setup the update shader
  83538. * @param effect defines the update shader
  83539. */
  83540. applyToShader(effect: Effect): void;
  83541. /**
  83542. * Returns a string to use to update the GPU particles update shader
  83543. * @returns a string containng the defines string
  83544. */
  83545. getEffectDefines(): string;
  83546. /**
  83547. * Returns the string "PointParticleEmitter"
  83548. * @returns a string containing the class name
  83549. */
  83550. getClassName(): string;
  83551. /**
  83552. * Serializes the particle system to a JSON object.
  83553. * @returns the JSON object
  83554. */
  83555. serialize(): any;
  83556. /**
  83557. * Parse properties from a JSON object
  83558. * @param serializationObject defines the JSON object
  83559. */
  83560. parse(serializationObject: any): void;
  83561. }
  83562. }
  83563. declare module BABYLON {
  83564. /**
  83565. * Particle emitter emitting particles from the inside of a sphere.
  83566. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83567. */
  83568. export class SphereParticleEmitter implements IParticleEmitterType {
  83569. /**
  83570. * The radius of the emission sphere.
  83571. */
  83572. radius: number;
  83573. /**
  83574. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83575. */
  83576. radiusRange: number;
  83577. /**
  83578. * How much to randomize the particle direction [0-1].
  83579. */
  83580. directionRandomizer: number;
  83581. /**
  83582. * Creates a new instance SphereParticleEmitter
  83583. * @param radius the radius of the emission sphere (1 by default)
  83584. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83585. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83586. */
  83587. constructor(
  83588. /**
  83589. * The radius of the emission sphere.
  83590. */
  83591. radius?: number,
  83592. /**
  83593. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83594. */
  83595. radiusRange?: number,
  83596. /**
  83597. * How much to randomize the particle direction [0-1].
  83598. */
  83599. directionRandomizer?: number);
  83600. /**
  83601. * Called by the particle System when the direction is computed for the created particle.
  83602. * @param worldMatrix is the world matrix of the particle system
  83603. * @param directionToUpdate is the direction vector to update with the result
  83604. * @param particle is the particle we are computed the direction for
  83605. */
  83606. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83607. /**
  83608. * Called by the particle System when the position is computed for the created particle.
  83609. * @param worldMatrix is the world matrix of the particle system
  83610. * @param positionToUpdate is the position vector to update with the result
  83611. * @param particle is the particle we are computed the position for
  83612. */
  83613. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83614. /**
  83615. * Clones the current emitter and returns a copy of it
  83616. * @returns the new emitter
  83617. */
  83618. clone(): SphereParticleEmitter;
  83619. /**
  83620. * Called by the GPUParticleSystem to setup the update shader
  83621. * @param effect defines the update shader
  83622. */
  83623. applyToShader(effect: Effect): void;
  83624. /**
  83625. * Returns a string to use to update the GPU particles update shader
  83626. * @returns a string containng the defines string
  83627. */
  83628. getEffectDefines(): string;
  83629. /**
  83630. * Returns the string "SphereParticleEmitter"
  83631. * @returns a string containing the class name
  83632. */
  83633. getClassName(): string;
  83634. /**
  83635. * Serializes the particle system to a JSON object.
  83636. * @returns the JSON object
  83637. */
  83638. serialize(): any;
  83639. /**
  83640. * Parse properties from a JSON object
  83641. * @param serializationObject defines the JSON object
  83642. */
  83643. parse(serializationObject: any): void;
  83644. }
  83645. /**
  83646. * Particle emitter emitting particles from the inside of a sphere.
  83647. * It emits the particles randomly between two vectors.
  83648. */
  83649. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83650. /**
  83651. * The min limit of the emission direction.
  83652. */
  83653. direction1: Vector3;
  83654. /**
  83655. * The max limit of the emission direction.
  83656. */
  83657. direction2: Vector3;
  83658. /**
  83659. * Creates a new instance SphereDirectedParticleEmitter
  83660. * @param radius the radius of the emission sphere (1 by default)
  83661. * @param direction1 the min limit of the emission direction (up vector by default)
  83662. * @param direction2 the max limit of the emission direction (up vector by default)
  83663. */
  83664. constructor(radius?: number,
  83665. /**
  83666. * The min limit of the emission direction.
  83667. */
  83668. direction1?: Vector3,
  83669. /**
  83670. * The max limit of the emission direction.
  83671. */
  83672. direction2?: Vector3);
  83673. /**
  83674. * Called by the particle System when the direction is computed for the created particle.
  83675. * @param worldMatrix is the world matrix of the particle system
  83676. * @param directionToUpdate is the direction vector to update with the result
  83677. * @param particle is the particle we are computed the direction for
  83678. */
  83679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83680. /**
  83681. * Clones the current emitter and returns a copy of it
  83682. * @returns the new emitter
  83683. */
  83684. clone(): SphereDirectedParticleEmitter;
  83685. /**
  83686. * Called by the GPUParticleSystem to setup the update shader
  83687. * @param effect defines the update shader
  83688. */
  83689. applyToShader(effect: Effect): void;
  83690. /**
  83691. * Returns a string to use to update the GPU particles update shader
  83692. * @returns a string containng the defines string
  83693. */
  83694. getEffectDefines(): string;
  83695. /**
  83696. * Returns the string "SphereDirectedParticleEmitter"
  83697. * @returns a string containing the class name
  83698. */
  83699. getClassName(): string;
  83700. /**
  83701. * Serializes the particle system to a JSON object.
  83702. * @returns the JSON object
  83703. */
  83704. serialize(): any;
  83705. /**
  83706. * Parse properties from a JSON object
  83707. * @param serializationObject defines the JSON object
  83708. */
  83709. parse(serializationObject: any): void;
  83710. }
  83711. }
  83712. declare module BABYLON {
  83713. /**
  83714. * Interface representing a particle system in Babylon.js.
  83715. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83716. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83717. */
  83718. export interface IParticleSystem {
  83719. /**
  83720. * List of animations used by the particle system.
  83721. */
  83722. animations: Animation[];
  83723. /**
  83724. * The id of the Particle system.
  83725. */
  83726. id: string;
  83727. /**
  83728. * The name of the Particle system.
  83729. */
  83730. name: string;
  83731. /**
  83732. * The emitter represents the Mesh or position we are attaching the particle system to.
  83733. */
  83734. emitter: Nullable<AbstractMesh | Vector3>;
  83735. /**
  83736. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83737. */
  83738. isBillboardBased: boolean;
  83739. /**
  83740. * The rendering group used by the Particle system to chose when to render.
  83741. */
  83742. renderingGroupId: number;
  83743. /**
  83744. * The layer mask we are rendering the particles through.
  83745. */
  83746. layerMask: number;
  83747. /**
  83748. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83749. */
  83750. updateSpeed: number;
  83751. /**
  83752. * The amount of time the particle system is running (depends of the overall update speed).
  83753. */
  83754. targetStopDuration: number;
  83755. /**
  83756. * The texture used to render each particle. (this can be a spritesheet)
  83757. */
  83758. particleTexture: Nullable<Texture>;
  83759. /**
  83760. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83761. */
  83762. blendMode: number;
  83763. /**
  83764. * Minimum life time of emitting particles.
  83765. */
  83766. minLifeTime: number;
  83767. /**
  83768. * Maximum life time of emitting particles.
  83769. */
  83770. maxLifeTime: number;
  83771. /**
  83772. * Minimum Size of emitting particles.
  83773. */
  83774. minSize: number;
  83775. /**
  83776. * Maximum Size of emitting particles.
  83777. */
  83778. maxSize: number;
  83779. /**
  83780. * Minimum scale of emitting particles on X axis.
  83781. */
  83782. minScaleX: number;
  83783. /**
  83784. * Maximum scale of emitting particles on X axis.
  83785. */
  83786. maxScaleX: number;
  83787. /**
  83788. * Minimum scale of emitting particles on Y axis.
  83789. */
  83790. minScaleY: number;
  83791. /**
  83792. * Maximum scale of emitting particles on Y axis.
  83793. */
  83794. maxScaleY: number;
  83795. /**
  83796. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83797. */
  83798. color1: Color4;
  83799. /**
  83800. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83801. */
  83802. color2: Color4;
  83803. /**
  83804. * Color the particle will have at the end of its lifetime.
  83805. */
  83806. colorDead: Color4;
  83807. /**
  83808. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83809. */
  83810. emitRate: number;
  83811. /**
  83812. * You can use gravity if you want to give an orientation to your particles.
  83813. */
  83814. gravity: Vector3;
  83815. /**
  83816. * Minimum power of emitting particles.
  83817. */
  83818. minEmitPower: number;
  83819. /**
  83820. * Maximum power of emitting particles.
  83821. */
  83822. maxEmitPower: number;
  83823. /**
  83824. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83825. */
  83826. minAngularSpeed: number;
  83827. /**
  83828. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83829. */
  83830. maxAngularSpeed: number;
  83831. /**
  83832. * Gets or sets the minimal initial rotation in radians.
  83833. */
  83834. minInitialRotation: number;
  83835. /**
  83836. * Gets or sets the maximal initial rotation in radians.
  83837. */
  83838. maxInitialRotation: number;
  83839. /**
  83840. * The particle emitter type defines the emitter used by the particle system.
  83841. * It can be for example box, sphere, or cone...
  83842. */
  83843. particleEmitterType: Nullable<IParticleEmitterType>;
  83844. /**
  83845. * Defines the delay in milliseconds before starting the system (0 by default)
  83846. */
  83847. startDelay: number;
  83848. /**
  83849. * 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
  83850. */
  83851. preWarmCycles: number;
  83852. /**
  83853. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83854. */
  83855. preWarmStepOffset: number;
  83856. /**
  83857. * 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)
  83858. */
  83859. spriteCellChangeSpeed: number;
  83860. /**
  83861. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83862. */
  83863. startSpriteCellID: number;
  83864. /**
  83865. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83866. */
  83867. endSpriteCellID: number;
  83868. /**
  83869. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83870. */
  83871. spriteCellWidth: number;
  83872. /**
  83873. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83874. */
  83875. spriteCellHeight: number;
  83876. /**
  83877. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83878. */
  83879. spriteRandomStartCell: boolean;
  83880. /**
  83881. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83882. */
  83883. isAnimationSheetEnabled: boolean;
  83884. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83885. translationPivot: Vector2;
  83886. /**
  83887. * Gets or sets a texture used to add random noise to particle positions
  83888. */
  83889. noiseTexture: Nullable<BaseTexture>;
  83890. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83891. noiseStrength: Vector3;
  83892. /**
  83893. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83894. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83895. */
  83896. billboardMode: number;
  83897. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83898. limitVelocityDamping: number;
  83899. /**
  83900. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83901. */
  83902. beginAnimationOnStart: boolean;
  83903. /**
  83904. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83905. */
  83906. beginAnimationFrom: number;
  83907. /**
  83908. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83909. */
  83910. beginAnimationTo: number;
  83911. /**
  83912. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83913. */
  83914. beginAnimationLoop: boolean;
  83915. /**
  83916. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83917. */
  83918. disposeOnStop: boolean;
  83919. /**
  83920. * Gets the maximum number of particles active at the same time.
  83921. * @returns The max number of active particles.
  83922. */
  83923. getCapacity(): number;
  83924. /**
  83925. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83926. * @returns True if it has been started, otherwise false.
  83927. */
  83928. isStarted(): boolean;
  83929. /**
  83930. * Animates the particle system for this frame.
  83931. */
  83932. animate(): void;
  83933. /**
  83934. * Renders the particle system in its current state.
  83935. * @returns the current number of particles
  83936. */
  83937. render(): number;
  83938. /**
  83939. * Dispose the particle system and frees its associated resources.
  83940. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83941. */
  83942. dispose(disposeTexture?: boolean): void;
  83943. /**
  83944. * Clones the particle system.
  83945. * @param name The name of the cloned object
  83946. * @param newEmitter The new emitter to use
  83947. * @returns the cloned particle system
  83948. */
  83949. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83950. /**
  83951. * Serializes the particle system to a JSON object.
  83952. * @returns the JSON object
  83953. */
  83954. serialize(): any;
  83955. /**
  83956. * Rebuild the particle system
  83957. */
  83958. rebuild(): void;
  83959. /**
  83960. * Starts the particle system and begins to emit
  83961. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83962. */
  83963. start(delay?: number): void;
  83964. /**
  83965. * Stops the particle system.
  83966. */
  83967. stop(): void;
  83968. /**
  83969. * Remove all active particles
  83970. */
  83971. reset(): void;
  83972. /**
  83973. * Is this system ready to be used/rendered
  83974. * @return true if the system is ready
  83975. */
  83976. isReady(): boolean;
  83977. /**
  83978. * Adds a new color gradient
  83979. * @param gradient defines the gradient to use (between 0 and 1)
  83980. * @param color1 defines the color to affect to the specified gradient
  83981. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83982. * @returns the current particle system
  83983. */
  83984. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83985. /**
  83986. * Remove a specific color gradient
  83987. * @param gradient defines the gradient to remove
  83988. * @returns the current particle system
  83989. */
  83990. removeColorGradient(gradient: number): IParticleSystem;
  83991. /**
  83992. * Adds a new size gradient
  83993. * @param gradient defines the gradient to use (between 0 and 1)
  83994. * @param factor defines the size factor to affect to the specified gradient
  83995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83996. * @returns the current particle system
  83997. */
  83998. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83999. /**
  84000. * Remove a specific size gradient
  84001. * @param gradient defines the gradient to remove
  84002. * @returns the current particle system
  84003. */
  84004. removeSizeGradient(gradient: number): IParticleSystem;
  84005. /**
  84006. * Gets the current list of color gradients.
  84007. * You must use addColorGradient and removeColorGradient to udpate this list
  84008. * @returns the list of color gradients
  84009. */
  84010. getColorGradients(): Nullable<Array<ColorGradient>>;
  84011. /**
  84012. * Gets the current list of size gradients.
  84013. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84014. * @returns the list of size gradients
  84015. */
  84016. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84017. /**
  84018. * Gets the current list of angular speed gradients.
  84019. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84020. * @returns the list of angular speed gradients
  84021. */
  84022. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84023. /**
  84024. * Adds a new angular speed gradient
  84025. * @param gradient defines the gradient to use (between 0 and 1)
  84026. * @param factor defines the angular speed to affect to the specified gradient
  84027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84028. * @returns the current particle system
  84029. */
  84030. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84031. /**
  84032. * Remove a specific angular speed gradient
  84033. * @param gradient defines the gradient to remove
  84034. * @returns the current particle system
  84035. */
  84036. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84037. /**
  84038. * Gets the current list of velocity gradients.
  84039. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84040. * @returns the list of velocity gradients
  84041. */
  84042. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84043. /**
  84044. * Adds a new velocity gradient
  84045. * @param gradient defines the gradient to use (between 0 and 1)
  84046. * @param factor defines the velocity to affect to the specified gradient
  84047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84048. * @returns the current particle system
  84049. */
  84050. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84051. /**
  84052. * Remove a specific velocity gradient
  84053. * @param gradient defines the gradient to remove
  84054. * @returns the current particle system
  84055. */
  84056. removeVelocityGradient(gradient: number): IParticleSystem;
  84057. /**
  84058. * Gets the current list of limit velocity gradients.
  84059. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84060. * @returns the list of limit velocity gradients
  84061. */
  84062. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84063. /**
  84064. * Adds a new limit velocity gradient
  84065. * @param gradient defines the gradient to use (between 0 and 1)
  84066. * @param factor defines the limit velocity to affect to the specified gradient
  84067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84068. * @returns the current particle system
  84069. */
  84070. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84071. /**
  84072. * Remove a specific limit velocity gradient
  84073. * @param gradient defines the gradient to remove
  84074. * @returns the current particle system
  84075. */
  84076. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84077. /**
  84078. * Adds a new drag gradient
  84079. * @param gradient defines the gradient to use (between 0 and 1)
  84080. * @param factor defines the drag to affect to the specified gradient
  84081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84082. * @returns the current particle system
  84083. */
  84084. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84085. /**
  84086. * Remove a specific drag gradient
  84087. * @param gradient defines the gradient to remove
  84088. * @returns the current particle system
  84089. */
  84090. removeDragGradient(gradient: number): IParticleSystem;
  84091. /**
  84092. * Gets the current list of drag gradients.
  84093. * You must use addDragGradient and removeDragGradient to udpate this list
  84094. * @returns the list of drag gradients
  84095. */
  84096. getDragGradients(): Nullable<Array<FactorGradient>>;
  84097. /**
  84098. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84099. * @param gradient defines the gradient to use (between 0 and 1)
  84100. * @param factor defines the emit rate to affect to the specified gradient
  84101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84102. * @returns the current particle system
  84103. */
  84104. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84105. /**
  84106. * Remove a specific emit rate gradient
  84107. * @param gradient defines the gradient to remove
  84108. * @returns the current particle system
  84109. */
  84110. removeEmitRateGradient(gradient: number): IParticleSystem;
  84111. /**
  84112. * Gets the current list of emit rate gradients.
  84113. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84114. * @returns the list of emit rate gradients
  84115. */
  84116. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84117. /**
  84118. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84119. * @param gradient defines the gradient to use (between 0 and 1)
  84120. * @param factor defines the start size to affect to the specified gradient
  84121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84122. * @returns the current particle system
  84123. */
  84124. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84125. /**
  84126. * Remove a specific start size gradient
  84127. * @param gradient defines the gradient to remove
  84128. * @returns the current particle system
  84129. */
  84130. removeStartSizeGradient(gradient: number): IParticleSystem;
  84131. /**
  84132. * Gets the current list of start size gradients.
  84133. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84134. * @returns the list of start size gradients
  84135. */
  84136. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84137. /**
  84138. * Adds a new life time gradient
  84139. * @param gradient defines the gradient to use (between 0 and 1)
  84140. * @param factor defines the life time factor to affect to the specified gradient
  84141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84142. * @returns the current particle system
  84143. */
  84144. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84145. /**
  84146. * Remove a specific life time gradient
  84147. * @param gradient defines the gradient to remove
  84148. * @returns the current particle system
  84149. */
  84150. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84151. /**
  84152. * Gets the current list of life time gradients.
  84153. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84154. * @returns the list of life time gradients
  84155. */
  84156. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84157. /**
  84158. * Gets the current list of color gradients.
  84159. * You must use addColorGradient and removeColorGradient to udpate this list
  84160. * @returns the list of color gradients
  84161. */
  84162. getColorGradients(): Nullable<Array<ColorGradient>>;
  84163. /**
  84164. * Adds a new ramp gradient used to remap particle colors
  84165. * @param gradient defines the gradient to use (between 0 and 1)
  84166. * @param color defines the color to affect to the specified gradient
  84167. * @returns the current particle system
  84168. */
  84169. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84170. /**
  84171. * Gets the current list of ramp gradients.
  84172. * You must use addRampGradient and removeRampGradient to udpate this list
  84173. * @returns the list of ramp gradients
  84174. */
  84175. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84176. /** Gets or sets a boolean indicating that ramp gradients must be used
  84177. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84178. */
  84179. useRampGradients: boolean;
  84180. /**
  84181. * Adds a new color remap gradient
  84182. * @param gradient defines the gradient to use (between 0 and 1)
  84183. * @param min defines the color remap minimal range
  84184. * @param max defines the color remap maximal range
  84185. * @returns the current particle system
  84186. */
  84187. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84188. /**
  84189. * Gets the current list of color remap gradients.
  84190. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84191. * @returns the list of color remap gradients
  84192. */
  84193. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84194. /**
  84195. * Adds a new alpha remap gradient
  84196. * @param gradient defines the gradient to use (between 0 and 1)
  84197. * @param min defines the alpha remap minimal range
  84198. * @param max defines the alpha remap maximal range
  84199. * @returns the current particle system
  84200. */
  84201. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84202. /**
  84203. * Gets the current list of alpha remap gradients.
  84204. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84205. * @returns the list of alpha remap gradients
  84206. */
  84207. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84208. /**
  84209. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84210. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84211. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84212. * @returns the emitter
  84213. */
  84214. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84215. /**
  84216. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84217. * @param radius The radius of the hemisphere to emit from
  84218. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84219. * @returns the emitter
  84220. */
  84221. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84222. /**
  84223. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84224. * @param radius The radius of the sphere to emit from
  84225. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84226. * @returns the emitter
  84227. */
  84228. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84229. /**
  84230. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84231. * @param radius The radius of the sphere to emit from
  84232. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84233. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84234. * @returns the emitter
  84235. */
  84236. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84237. /**
  84238. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84239. * @param radius The radius of the emission cylinder
  84240. * @param height The height of the emission cylinder
  84241. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84242. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84243. * @returns the emitter
  84244. */
  84245. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84246. /**
  84247. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84248. * @param radius The radius of the cylinder to emit from
  84249. * @param height The height of the emission cylinder
  84250. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84251. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84252. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84253. * @returns the emitter
  84254. */
  84255. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84256. /**
  84257. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84258. * @param radius The radius of the cone to emit from
  84259. * @param angle The base angle of the cone
  84260. * @returns the emitter
  84261. */
  84262. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84263. /**
  84264. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84265. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84266. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84267. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84268. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84269. * @returns the emitter
  84270. */
  84271. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84272. /**
  84273. * Get hosting scene
  84274. * @returns the scene
  84275. */
  84276. getScene(): Scene;
  84277. }
  84278. }
  84279. declare module BABYLON {
  84280. /** @hidden */
  84281. export var linePixelShader: {
  84282. name: string;
  84283. shader: string;
  84284. };
  84285. }
  84286. declare module BABYLON {
  84287. /** @hidden */
  84288. export var lineVertexShader: {
  84289. name: string;
  84290. shader: string;
  84291. };
  84292. }
  84293. declare module BABYLON {
  84294. interface AbstractMesh {
  84295. /**
  84296. * Gets the edgesRenderer associated with the mesh
  84297. */
  84298. edgesRenderer: Nullable<EdgesRenderer>;
  84299. }
  84300. interface LinesMesh {
  84301. /**
  84302. * Enables the edge rendering mode on the mesh.
  84303. * This mode makes the mesh edges visible
  84304. * @param epsilon defines the maximal distance between two angles to detect a face
  84305. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84306. * @returns the currentAbstractMesh
  84307. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84308. */
  84309. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84310. }
  84311. interface InstancedLinesMesh {
  84312. /**
  84313. * Enables the edge rendering mode on the mesh.
  84314. * This mode makes the mesh edges visible
  84315. * @param epsilon defines the maximal distance between two angles to detect a face
  84316. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84317. * @returns the current InstancedLinesMesh
  84318. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84319. */
  84320. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84321. }
  84322. /**
  84323. * Defines the minimum contract an Edges renderer should follow.
  84324. */
  84325. export interface IEdgesRenderer extends IDisposable {
  84326. /**
  84327. * Gets or sets a boolean indicating if the edgesRenderer is active
  84328. */
  84329. isEnabled: boolean;
  84330. /**
  84331. * Renders the edges of the attached mesh,
  84332. */
  84333. render(): void;
  84334. /**
  84335. * Checks wether or not the edges renderer is ready to render.
  84336. * @return true if ready, otherwise false.
  84337. */
  84338. isReady(): boolean;
  84339. }
  84340. /**
  84341. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84342. */
  84343. export class EdgesRenderer implements IEdgesRenderer {
  84344. /**
  84345. * Define the size of the edges with an orthographic camera
  84346. */
  84347. edgesWidthScalerForOrthographic: number;
  84348. /**
  84349. * Define the size of the edges with a perspective camera
  84350. */
  84351. edgesWidthScalerForPerspective: number;
  84352. protected _source: AbstractMesh;
  84353. protected _linesPositions: number[];
  84354. protected _linesNormals: number[];
  84355. protected _linesIndices: number[];
  84356. protected _epsilon: number;
  84357. protected _indicesCount: number;
  84358. protected _lineShader: ShaderMaterial;
  84359. protected _ib: DataBuffer;
  84360. protected _buffers: {
  84361. [key: string]: Nullable<VertexBuffer>;
  84362. };
  84363. protected _checkVerticesInsteadOfIndices: boolean;
  84364. private _meshRebuildObserver;
  84365. private _meshDisposeObserver;
  84366. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84367. isEnabled: boolean;
  84368. /**
  84369. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84370. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84371. * @param source Mesh used to create edges
  84372. * @param epsilon sum of angles in adjacency to check for edge
  84373. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84374. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84375. */
  84376. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84377. protected _prepareRessources(): void;
  84378. /** @hidden */
  84379. _rebuild(): void;
  84380. /**
  84381. * Releases the required resources for the edges renderer
  84382. */
  84383. dispose(): void;
  84384. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84385. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84386. /**
  84387. * Checks if the pair of p0 and p1 is en edge
  84388. * @param faceIndex
  84389. * @param edge
  84390. * @param faceNormals
  84391. * @param p0
  84392. * @param p1
  84393. * @private
  84394. */
  84395. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84396. /**
  84397. * push line into the position, normal and index buffer
  84398. * @protected
  84399. */
  84400. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84401. /**
  84402. * Generates lines edges from adjacencjes
  84403. * @private
  84404. */
  84405. _generateEdgesLines(): void;
  84406. /**
  84407. * Checks wether or not the edges renderer is ready to render.
  84408. * @return true if ready, otherwise false.
  84409. */
  84410. isReady(): boolean;
  84411. /**
  84412. * Renders the edges of the attached mesh,
  84413. */
  84414. render(): void;
  84415. }
  84416. /**
  84417. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84418. */
  84419. export class LineEdgesRenderer extends EdgesRenderer {
  84420. /**
  84421. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84422. * @param source LineMesh used to generate edges
  84423. * @param epsilon not important (specified angle for edge detection)
  84424. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84425. */
  84426. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84427. /**
  84428. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84429. */
  84430. _generateEdgesLines(): void;
  84431. }
  84432. }
  84433. declare module BABYLON {
  84434. /**
  84435. * This represents the object necessary to create a rendering group.
  84436. * This is exclusively used and created by the rendering manager.
  84437. * To modify the behavior, you use the available helpers in your scene or meshes.
  84438. * @hidden
  84439. */
  84440. export class RenderingGroup {
  84441. index: number;
  84442. private static _zeroVector;
  84443. private _scene;
  84444. private _opaqueSubMeshes;
  84445. private _transparentSubMeshes;
  84446. private _alphaTestSubMeshes;
  84447. private _depthOnlySubMeshes;
  84448. private _particleSystems;
  84449. private _spriteManagers;
  84450. private _opaqueSortCompareFn;
  84451. private _alphaTestSortCompareFn;
  84452. private _transparentSortCompareFn;
  84453. private _renderOpaque;
  84454. private _renderAlphaTest;
  84455. private _renderTransparent;
  84456. /** @hidden */
  84457. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84458. onBeforeTransparentRendering: () => void;
  84459. /**
  84460. * Set the opaque sort comparison function.
  84461. * If null the sub meshes will be render in the order they were created
  84462. */
  84463. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84464. /**
  84465. * Set the alpha test sort comparison function.
  84466. * If null the sub meshes will be render in the order they were created
  84467. */
  84468. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84469. /**
  84470. * Set the transparent sort comparison function.
  84471. * If null the sub meshes will be render in the order they were created
  84472. */
  84473. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84474. /**
  84475. * Creates a new rendering group.
  84476. * @param index The rendering group index
  84477. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84478. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84479. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84480. */
  84481. 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>);
  84482. /**
  84483. * Render all the sub meshes contained in the group.
  84484. * @param customRenderFunction Used to override the default render behaviour of the group.
  84485. * @returns true if rendered some submeshes.
  84486. */
  84487. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84488. /**
  84489. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84490. * @param subMeshes The submeshes to render
  84491. */
  84492. private renderOpaqueSorted;
  84493. /**
  84494. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84495. * @param subMeshes The submeshes to render
  84496. */
  84497. private renderAlphaTestSorted;
  84498. /**
  84499. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84500. * @param subMeshes The submeshes to render
  84501. */
  84502. private renderTransparentSorted;
  84503. /**
  84504. * Renders the submeshes in a specified order.
  84505. * @param subMeshes The submeshes to sort before render
  84506. * @param sortCompareFn The comparison function use to sort
  84507. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84508. * @param transparent Specifies to activate blending if true
  84509. */
  84510. private static renderSorted;
  84511. /**
  84512. * Renders the submeshes in the order they were dispatched (no sort applied).
  84513. * @param subMeshes The submeshes to render
  84514. */
  84515. private static renderUnsorted;
  84516. /**
  84517. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84518. * are rendered back to front if in the same alpha index.
  84519. *
  84520. * @param a The first submesh
  84521. * @param b The second submesh
  84522. * @returns The result of the comparison
  84523. */
  84524. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84525. /**
  84526. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84527. * are rendered back to front.
  84528. *
  84529. * @param a The first submesh
  84530. * @param b The second submesh
  84531. * @returns The result of the comparison
  84532. */
  84533. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84534. /**
  84535. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84536. * are rendered front to back (prevent overdraw).
  84537. *
  84538. * @param a The first submesh
  84539. * @param b The second submesh
  84540. * @returns The result of the comparison
  84541. */
  84542. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84543. /**
  84544. * Resets the different lists of submeshes to prepare a new frame.
  84545. */
  84546. prepare(): void;
  84547. dispose(): void;
  84548. /**
  84549. * Inserts the submesh in its correct queue depending on its material.
  84550. * @param subMesh The submesh to dispatch
  84551. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84552. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84553. */
  84554. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84555. dispatchSprites(spriteManager: ISpriteManager): void;
  84556. dispatchParticles(particleSystem: IParticleSystem): void;
  84557. private _renderParticles;
  84558. private _renderSprites;
  84559. }
  84560. }
  84561. declare module BABYLON {
  84562. /**
  84563. * Interface describing the different options available in the rendering manager
  84564. * regarding Auto Clear between groups.
  84565. */
  84566. export interface IRenderingManagerAutoClearSetup {
  84567. /**
  84568. * Defines whether or not autoclear is enable.
  84569. */
  84570. autoClear: boolean;
  84571. /**
  84572. * Defines whether or not to autoclear the depth buffer.
  84573. */
  84574. depth: boolean;
  84575. /**
  84576. * Defines whether or not to autoclear the stencil buffer.
  84577. */
  84578. stencil: boolean;
  84579. }
  84580. /**
  84581. * This class is used by the onRenderingGroupObservable
  84582. */
  84583. export class RenderingGroupInfo {
  84584. /**
  84585. * The Scene that being rendered
  84586. */
  84587. scene: Scene;
  84588. /**
  84589. * The camera currently used for the rendering pass
  84590. */
  84591. camera: Nullable<Camera>;
  84592. /**
  84593. * The ID of the renderingGroup being processed
  84594. */
  84595. renderingGroupId: number;
  84596. }
  84597. /**
  84598. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84599. * It is enable to manage the different groups as well as the different necessary sort functions.
  84600. * This should not be used directly aside of the few static configurations
  84601. */
  84602. export class RenderingManager {
  84603. /**
  84604. * The max id used for rendering groups (not included)
  84605. */
  84606. static MAX_RENDERINGGROUPS: number;
  84607. /**
  84608. * The min id used for rendering groups (included)
  84609. */
  84610. static MIN_RENDERINGGROUPS: number;
  84611. /**
  84612. * Used to globally prevent autoclearing scenes.
  84613. */
  84614. static AUTOCLEAR: boolean;
  84615. /**
  84616. * @hidden
  84617. */
  84618. _useSceneAutoClearSetup: boolean;
  84619. private _scene;
  84620. private _renderingGroups;
  84621. private _depthStencilBufferAlreadyCleaned;
  84622. private _autoClearDepthStencil;
  84623. private _customOpaqueSortCompareFn;
  84624. private _customAlphaTestSortCompareFn;
  84625. private _customTransparentSortCompareFn;
  84626. private _renderingGroupInfo;
  84627. /**
  84628. * Instantiates a new rendering group for a particular scene
  84629. * @param scene Defines the scene the groups belongs to
  84630. */
  84631. constructor(scene: Scene);
  84632. private _clearDepthStencilBuffer;
  84633. /**
  84634. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84635. * @hidden
  84636. */
  84637. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84638. /**
  84639. * Resets the different information of the group to prepare a new frame
  84640. * @hidden
  84641. */
  84642. reset(): void;
  84643. /**
  84644. * Dispose and release the group and its associated resources.
  84645. * @hidden
  84646. */
  84647. dispose(): void;
  84648. /**
  84649. * Clear the info related to rendering groups preventing retention points during dispose.
  84650. */
  84651. freeRenderingGroups(): void;
  84652. private _prepareRenderingGroup;
  84653. /**
  84654. * Add a sprite manager to the rendering manager in order to render it this frame.
  84655. * @param spriteManager Define the sprite manager to render
  84656. */
  84657. dispatchSprites(spriteManager: ISpriteManager): void;
  84658. /**
  84659. * Add a particle system to the rendering manager in order to render it this frame.
  84660. * @param particleSystem Define the particle system to render
  84661. */
  84662. dispatchParticles(particleSystem: IParticleSystem): void;
  84663. /**
  84664. * Add a submesh to the manager in order to render it this frame
  84665. * @param subMesh The submesh to dispatch
  84666. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84667. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84668. */
  84669. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84670. /**
  84671. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84672. * This allowed control for front to back rendering or reversly depending of the special needs.
  84673. *
  84674. * @param renderingGroupId The rendering group id corresponding to its index
  84675. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84676. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84677. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84678. */
  84679. 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;
  84680. /**
  84681. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84682. *
  84683. * @param renderingGroupId The rendering group id corresponding to its index
  84684. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84685. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84686. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84687. */
  84688. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84689. /**
  84690. * Gets the current auto clear configuration for one rendering group of the rendering
  84691. * manager.
  84692. * @param index the rendering group index to get the information for
  84693. * @returns The auto clear setup for the requested rendering group
  84694. */
  84695. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84696. }
  84697. }
  84698. declare module BABYLON {
  84699. /**
  84700. * This Helps creating a texture that will be created from a camera in your scene.
  84701. * It is basically a dynamic texture that could be used to create special effects for instance.
  84702. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84703. */
  84704. export class RenderTargetTexture extends Texture {
  84705. isCube: boolean;
  84706. /**
  84707. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84708. */
  84709. static readonly REFRESHRATE_RENDER_ONCE: number;
  84710. /**
  84711. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84712. */
  84713. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84714. /**
  84715. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84716. * the central point of your effect and can save a lot of performances.
  84717. */
  84718. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84719. /**
  84720. * Use this predicate to dynamically define the list of mesh you want to render.
  84721. * If set, the renderList property will be overwritten.
  84722. */
  84723. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84724. private _renderList;
  84725. /**
  84726. * Use this list to define the list of mesh you want to render.
  84727. */
  84728. renderList: Nullable<Array<AbstractMesh>>;
  84729. private _hookArray;
  84730. /**
  84731. * Define if particles should be rendered in your texture.
  84732. */
  84733. renderParticles: boolean;
  84734. /**
  84735. * Define if sprites should be rendered in your texture.
  84736. */
  84737. renderSprites: boolean;
  84738. /**
  84739. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84740. */
  84741. coordinatesMode: number;
  84742. /**
  84743. * Define the camera used to render the texture.
  84744. */
  84745. activeCamera: Nullable<Camera>;
  84746. /**
  84747. * Override the render function of the texture with your own one.
  84748. */
  84749. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84750. /**
  84751. * Define if camera post processes should be use while rendering the texture.
  84752. */
  84753. useCameraPostProcesses: boolean;
  84754. /**
  84755. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84756. */
  84757. ignoreCameraViewport: boolean;
  84758. private _postProcessManager;
  84759. private _postProcesses;
  84760. private _resizeObserver;
  84761. /**
  84762. * An event triggered when the texture is unbind.
  84763. */
  84764. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84765. /**
  84766. * An event triggered when the texture is unbind.
  84767. */
  84768. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84769. private _onAfterUnbindObserver;
  84770. /**
  84771. * Set a after unbind callback in the texture.
  84772. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84773. */
  84774. onAfterUnbind: () => void;
  84775. /**
  84776. * An event triggered before rendering the texture
  84777. */
  84778. onBeforeRenderObservable: Observable<number>;
  84779. private _onBeforeRenderObserver;
  84780. /**
  84781. * Set a before render callback in the texture.
  84782. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84783. */
  84784. onBeforeRender: (faceIndex: number) => void;
  84785. /**
  84786. * An event triggered after rendering the texture
  84787. */
  84788. onAfterRenderObservable: Observable<number>;
  84789. private _onAfterRenderObserver;
  84790. /**
  84791. * Set a after render callback in the texture.
  84792. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84793. */
  84794. onAfterRender: (faceIndex: number) => void;
  84795. /**
  84796. * An event triggered after the texture clear
  84797. */
  84798. onClearObservable: Observable<Engine>;
  84799. private _onClearObserver;
  84800. /**
  84801. * Set a clear callback in the texture.
  84802. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84803. */
  84804. onClear: (Engine: Engine) => void;
  84805. /**
  84806. * Define the clear color of the Render Target if it should be different from the scene.
  84807. */
  84808. clearColor: Color4;
  84809. protected _size: number | {
  84810. width: number;
  84811. height: number;
  84812. };
  84813. protected _initialSizeParameter: number | {
  84814. width: number;
  84815. height: number;
  84816. } | {
  84817. ratio: number;
  84818. };
  84819. protected _sizeRatio: Nullable<number>;
  84820. /** @hidden */
  84821. _generateMipMaps: boolean;
  84822. protected _renderingManager: RenderingManager;
  84823. /** @hidden */
  84824. _waitingRenderList: string[];
  84825. protected _doNotChangeAspectRatio: boolean;
  84826. protected _currentRefreshId: number;
  84827. protected _refreshRate: number;
  84828. protected _textureMatrix: Matrix;
  84829. protected _samples: number;
  84830. protected _renderTargetOptions: RenderTargetCreationOptions;
  84831. /**
  84832. * Gets render target creation options that were used.
  84833. */
  84834. readonly renderTargetOptions: RenderTargetCreationOptions;
  84835. protected _engine: Engine;
  84836. protected _onRatioRescale(): void;
  84837. /**
  84838. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84839. * It must define where the camera used to render the texture is set
  84840. */
  84841. boundingBoxPosition: Vector3;
  84842. private _boundingBoxSize;
  84843. /**
  84844. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84845. * When defined, the cubemap will switch to local mode
  84846. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84847. * @example https://www.babylonjs-playground.com/#RNASML
  84848. */
  84849. boundingBoxSize: Vector3;
  84850. /**
  84851. * In case the RTT has been created with a depth texture, get the associated
  84852. * depth texture.
  84853. * Otherwise, return null.
  84854. */
  84855. depthStencilTexture: Nullable<InternalTexture>;
  84856. /**
  84857. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84858. * or used a shadow, depth texture...
  84859. * @param name The friendly name of the texture
  84860. * @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)
  84861. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84862. * @param generateMipMaps True if mip maps need to be generated after render.
  84863. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84864. * @param type The type of the buffer in the RTT (int, half float, float...)
  84865. * @param isCube True if a cube texture needs to be created
  84866. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84867. * @param generateDepthBuffer True to generate a depth buffer
  84868. * @param generateStencilBuffer True to generate a stencil buffer
  84869. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84870. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84871. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84872. */
  84873. constructor(name: string, size: number | {
  84874. width: number;
  84875. height: number;
  84876. } | {
  84877. ratio: number;
  84878. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84879. /**
  84880. * Creates a depth stencil texture.
  84881. * This is only available in WebGL 2 or with the depth texture extension available.
  84882. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84883. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84884. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84885. */
  84886. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84887. private _processSizeParameter;
  84888. /**
  84889. * Define the number of samples to use in case of MSAA.
  84890. * It defaults to one meaning no MSAA has been enabled.
  84891. */
  84892. samples: number;
  84893. /**
  84894. * Resets the refresh counter of the texture and start bak from scratch.
  84895. * Could be useful to regenerate the texture if it is setup to render only once.
  84896. */
  84897. resetRefreshCounter(): void;
  84898. /**
  84899. * Define the refresh rate of the texture or the rendering frequency.
  84900. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84901. */
  84902. refreshRate: number;
  84903. /**
  84904. * Adds a post process to the render target rendering passes.
  84905. * @param postProcess define the post process to add
  84906. */
  84907. addPostProcess(postProcess: PostProcess): void;
  84908. /**
  84909. * Clear all the post processes attached to the render target
  84910. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84911. */
  84912. clearPostProcesses(dispose?: boolean): void;
  84913. /**
  84914. * Remove one of the post process from the list of attached post processes to the texture
  84915. * @param postProcess define the post process to remove from the list
  84916. */
  84917. removePostProcess(postProcess: PostProcess): void;
  84918. /** @hidden */
  84919. _shouldRender(): boolean;
  84920. /**
  84921. * Gets the actual render size of the texture.
  84922. * @returns the width of the render size
  84923. */
  84924. getRenderSize(): number;
  84925. /**
  84926. * Gets the actual render width of the texture.
  84927. * @returns the width of the render size
  84928. */
  84929. getRenderWidth(): number;
  84930. /**
  84931. * Gets the actual render height of the texture.
  84932. * @returns the height of the render size
  84933. */
  84934. getRenderHeight(): number;
  84935. /**
  84936. * Get if the texture can be rescaled or not.
  84937. */
  84938. readonly canRescale: boolean;
  84939. /**
  84940. * Resize the texture using a ratio.
  84941. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84942. */
  84943. scale(ratio: number): void;
  84944. /**
  84945. * Get the texture reflection matrix used to rotate/transform the reflection.
  84946. * @returns the reflection matrix
  84947. */
  84948. getReflectionTextureMatrix(): Matrix;
  84949. /**
  84950. * Resize the texture to a new desired size.
  84951. * Be carrefull as it will recreate all the data in the new texture.
  84952. * @param size Define the new size. It can be:
  84953. * - a number for squared texture,
  84954. * - an object containing { width: number, height: number }
  84955. * - or an object containing a ratio { ratio: number }
  84956. */
  84957. resize(size: number | {
  84958. width: number;
  84959. height: number;
  84960. } | {
  84961. ratio: number;
  84962. }): void;
  84963. /**
  84964. * Renders all the objects from the render list into the texture.
  84965. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84966. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84967. */
  84968. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84969. private _bestReflectionRenderTargetDimension;
  84970. /**
  84971. * @hidden
  84972. * @param faceIndex face index to bind to if this is a cubetexture
  84973. */
  84974. _bindFrameBuffer(faceIndex?: number): void;
  84975. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84976. private renderToTarget;
  84977. /**
  84978. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84979. * This allowed control for front to back rendering or reversly depending of the special needs.
  84980. *
  84981. * @param renderingGroupId The rendering group id corresponding to its index
  84982. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84983. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84984. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84985. */
  84986. 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;
  84987. /**
  84988. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84989. *
  84990. * @param renderingGroupId The rendering group id corresponding to its index
  84991. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84992. */
  84993. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84994. /**
  84995. * Clones the texture.
  84996. * @returns the cloned texture
  84997. */
  84998. clone(): RenderTargetTexture;
  84999. /**
  85000. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85001. * @returns The JSON representation of the texture
  85002. */
  85003. serialize(): any;
  85004. /**
  85005. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85006. */
  85007. disposeFramebufferObjects(): void;
  85008. /**
  85009. * Dispose the texture and release its associated resources.
  85010. */
  85011. dispose(): void;
  85012. /** @hidden */
  85013. _rebuild(): void;
  85014. /**
  85015. * Clear the info related to rendering groups preventing retention point in material dispose.
  85016. */
  85017. freeRenderingGroups(): void;
  85018. /**
  85019. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85020. * @returns the view count
  85021. */
  85022. getViewCount(): number;
  85023. }
  85024. }
  85025. declare module BABYLON {
  85026. /**
  85027. * Base class for the main features of a material in Babylon.js
  85028. */
  85029. export class Material implements IAnimatable {
  85030. /**
  85031. * Returns the triangle fill mode
  85032. */
  85033. static readonly TriangleFillMode: number;
  85034. /**
  85035. * Returns the wireframe mode
  85036. */
  85037. static readonly WireFrameFillMode: number;
  85038. /**
  85039. * Returns the point fill mode
  85040. */
  85041. static readonly PointFillMode: number;
  85042. /**
  85043. * Returns the point list draw mode
  85044. */
  85045. static readonly PointListDrawMode: number;
  85046. /**
  85047. * Returns the line list draw mode
  85048. */
  85049. static readonly LineListDrawMode: number;
  85050. /**
  85051. * Returns the line loop draw mode
  85052. */
  85053. static readonly LineLoopDrawMode: number;
  85054. /**
  85055. * Returns the line strip draw mode
  85056. */
  85057. static readonly LineStripDrawMode: number;
  85058. /**
  85059. * Returns the triangle strip draw mode
  85060. */
  85061. static readonly TriangleStripDrawMode: number;
  85062. /**
  85063. * Returns the triangle fan draw mode
  85064. */
  85065. static readonly TriangleFanDrawMode: number;
  85066. /**
  85067. * Stores the clock-wise side orientation
  85068. */
  85069. static readonly ClockWiseSideOrientation: number;
  85070. /**
  85071. * Stores the counter clock-wise side orientation
  85072. */
  85073. static readonly CounterClockWiseSideOrientation: number;
  85074. /**
  85075. * The dirty texture flag value
  85076. */
  85077. static readonly TextureDirtyFlag: number;
  85078. /**
  85079. * The dirty light flag value
  85080. */
  85081. static readonly LightDirtyFlag: number;
  85082. /**
  85083. * The dirty fresnel flag value
  85084. */
  85085. static readonly FresnelDirtyFlag: number;
  85086. /**
  85087. * The dirty attribute flag value
  85088. */
  85089. static readonly AttributesDirtyFlag: number;
  85090. /**
  85091. * The dirty misc flag value
  85092. */
  85093. static readonly MiscDirtyFlag: number;
  85094. /**
  85095. * The all dirty flag value
  85096. */
  85097. static readonly AllDirtyFlag: number;
  85098. /**
  85099. * The ID of the material
  85100. */
  85101. id: string;
  85102. /**
  85103. * Gets or sets the unique id of the material
  85104. */
  85105. uniqueId: number;
  85106. /**
  85107. * The name of the material
  85108. */
  85109. name: string;
  85110. /**
  85111. * Gets or sets user defined metadata
  85112. */
  85113. metadata: any;
  85114. /**
  85115. * For internal use only. Please do not use.
  85116. */
  85117. reservedDataStore: any;
  85118. /**
  85119. * Specifies if the ready state should be checked on each call
  85120. */
  85121. checkReadyOnEveryCall: boolean;
  85122. /**
  85123. * Specifies if the ready state should be checked once
  85124. */
  85125. checkReadyOnlyOnce: boolean;
  85126. /**
  85127. * The state of the material
  85128. */
  85129. state: string;
  85130. /**
  85131. * The alpha value of the material
  85132. */
  85133. protected _alpha: number;
  85134. /**
  85135. * List of inspectable custom properties (used by the Inspector)
  85136. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85137. */
  85138. inspectableCustomProperties: IInspectable[];
  85139. /**
  85140. * Sets the alpha value of the material
  85141. */
  85142. /**
  85143. * Gets the alpha value of the material
  85144. */
  85145. alpha: number;
  85146. /**
  85147. * Specifies if back face culling is enabled
  85148. */
  85149. protected _backFaceCulling: boolean;
  85150. /**
  85151. * Sets the back-face culling state
  85152. */
  85153. /**
  85154. * Gets the back-face culling state
  85155. */
  85156. backFaceCulling: boolean;
  85157. /**
  85158. * Stores the value for side orientation
  85159. */
  85160. sideOrientation: number;
  85161. /**
  85162. * Callback triggered when the material is compiled
  85163. */
  85164. onCompiled: Nullable<(effect: Effect) => void>;
  85165. /**
  85166. * Callback triggered when an error occurs
  85167. */
  85168. onError: Nullable<(effect: Effect, errors: string) => void>;
  85169. /**
  85170. * Callback triggered to get the render target textures
  85171. */
  85172. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85173. /**
  85174. * Gets a boolean indicating that current material needs to register RTT
  85175. */
  85176. readonly hasRenderTargetTextures: boolean;
  85177. /**
  85178. * Specifies if the material should be serialized
  85179. */
  85180. doNotSerialize: boolean;
  85181. /**
  85182. * @hidden
  85183. */
  85184. _storeEffectOnSubMeshes: boolean;
  85185. /**
  85186. * Stores the animations for the material
  85187. */
  85188. animations: Nullable<Array<Animation>>;
  85189. /**
  85190. * An event triggered when the material is disposed
  85191. */
  85192. onDisposeObservable: Observable<Material>;
  85193. /**
  85194. * An observer which watches for dispose events
  85195. */
  85196. private _onDisposeObserver;
  85197. private _onUnBindObservable;
  85198. /**
  85199. * Called during a dispose event
  85200. */
  85201. onDispose: () => void;
  85202. private _onBindObservable;
  85203. /**
  85204. * An event triggered when the material is bound
  85205. */
  85206. readonly onBindObservable: Observable<AbstractMesh>;
  85207. /**
  85208. * An observer which watches for bind events
  85209. */
  85210. private _onBindObserver;
  85211. /**
  85212. * Called during a bind event
  85213. */
  85214. onBind: (Mesh: AbstractMesh) => void;
  85215. /**
  85216. * An event triggered when the material is unbound
  85217. */
  85218. readonly onUnBindObservable: Observable<Material>;
  85219. /**
  85220. * Stores the value of the alpha mode
  85221. */
  85222. private _alphaMode;
  85223. /**
  85224. * Sets the value of the alpha mode.
  85225. *
  85226. * | Value | Type | Description |
  85227. * | --- | --- | --- |
  85228. * | 0 | ALPHA_DISABLE | |
  85229. * | 1 | ALPHA_ADD | |
  85230. * | 2 | ALPHA_COMBINE | |
  85231. * | 3 | ALPHA_SUBTRACT | |
  85232. * | 4 | ALPHA_MULTIPLY | |
  85233. * | 5 | ALPHA_MAXIMIZED | |
  85234. * | 6 | ALPHA_ONEONE | |
  85235. * | 7 | ALPHA_PREMULTIPLIED | |
  85236. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85237. * | 9 | ALPHA_INTERPOLATE | |
  85238. * | 10 | ALPHA_SCREENMODE | |
  85239. *
  85240. */
  85241. /**
  85242. * Gets the value of the alpha mode
  85243. */
  85244. alphaMode: number;
  85245. /**
  85246. * Stores the state of the need depth pre-pass value
  85247. */
  85248. private _needDepthPrePass;
  85249. /**
  85250. * Sets the need depth pre-pass value
  85251. */
  85252. /**
  85253. * Gets the depth pre-pass value
  85254. */
  85255. needDepthPrePass: boolean;
  85256. /**
  85257. * Specifies if depth writing should be disabled
  85258. */
  85259. disableDepthWrite: boolean;
  85260. /**
  85261. * Specifies if depth writing should be forced
  85262. */
  85263. forceDepthWrite: boolean;
  85264. /**
  85265. * Specifies if there should be a separate pass for culling
  85266. */
  85267. separateCullingPass: boolean;
  85268. /**
  85269. * Stores the state specifing if fog should be enabled
  85270. */
  85271. private _fogEnabled;
  85272. /**
  85273. * Sets the state for enabling fog
  85274. */
  85275. /**
  85276. * Gets the value of the fog enabled state
  85277. */
  85278. fogEnabled: boolean;
  85279. /**
  85280. * Stores the size of points
  85281. */
  85282. pointSize: number;
  85283. /**
  85284. * Stores the z offset value
  85285. */
  85286. zOffset: number;
  85287. /**
  85288. * Gets a value specifying if wireframe mode is enabled
  85289. */
  85290. /**
  85291. * Sets the state of wireframe mode
  85292. */
  85293. wireframe: boolean;
  85294. /**
  85295. * Gets the value specifying if point clouds are enabled
  85296. */
  85297. /**
  85298. * Sets the state of point cloud mode
  85299. */
  85300. pointsCloud: boolean;
  85301. /**
  85302. * Gets the material fill mode
  85303. */
  85304. /**
  85305. * Sets the material fill mode
  85306. */
  85307. fillMode: number;
  85308. /**
  85309. * @hidden
  85310. * Stores the effects for the material
  85311. */
  85312. _effect: Nullable<Effect>;
  85313. /**
  85314. * @hidden
  85315. * Specifies if the material was previously ready
  85316. */
  85317. _wasPreviouslyReady: boolean;
  85318. /**
  85319. * Specifies if uniform buffers should be used
  85320. */
  85321. private _useUBO;
  85322. /**
  85323. * Stores a reference to the scene
  85324. */
  85325. private _scene;
  85326. /**
  85327. * Stores the fill mode state
  85328. */
  85329. private _fillMode;
  85330. /**
  85331. * Specifies if the depth write state should be cached
  85332. */
  85333. private _cachedDepthWriteState;
  85334. /**
  85335. * Stores the uniform buffer
  85336. */
  85337. protected _uniformBuffer: UniformBuffer;
  85338. /** @hidden */
  85339. _indexInSceneMaterialArray: number;
  85340. /** @hidden */
  85341. meshMap: Nullable<{
  85342. [id: string]: AbstractMesh | undefined;
  85343. }>;
  85344. /**
  85345. * Creates a material instance
  85346. * @param name defines the name of the material
  85347. * @param scene defines the scene to reference
  85348. * @param doNotAdd specifies if the material should be added to the scene
  85349. */
  85350. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85351. /**
  85352. * Returns a string representation of the current material
  85353. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85354. * @returns a string with material information
  85355. */
  85356. toString(fullDetails?: boolean): string;
  85357. /**
  85358. * Gets the class name of the material
  85359. * @returns a string with the class name of the material
  85360. */
  85361. getClassName(): string;
  85362. /**
  85363. * Specifies if updates for the material been locked
  85364. */
  85365. readonly isFrozen: boolean;
  85366. /**
  85367. * Locks updates for the material
  85368. */
  85369. freeze(): void;
  85370. /**
  85371. * Unlocks updates for the material
  85372. */
  85373. unfreeze(): void;
  85374. /**
  85375. * Specifies if the material is ready to be used
  85376. * @param mesh defines the mesh to check
  85377. * @param useInstances specifies if instances should be used
  85378. * @returns a boolean indicating if the material is ready to be used
  85379. */
  85380. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85381. /**
  85382. * Specifies that the submesh is ready to be used
  85383. * @param mesh defines the mesh to check
  85384. * @param subMesh defines which submesh to check
  85385. * @param useInstances specifies that instances should be used
  85386. * @returns a boolean indicating that the submesh is ready or not
  85387. */
  85388. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85389. /**
  85390. * Returns the material effect
  85391. * @returns the effect associated with the material
  85392. */
  85393. getEffect(): Nullable<Effect>;
  85394. /**
  85395. * Returns the current scene
  85396. * @returns a Scene
  85397. */
  85398. getScene(): Scene;
  85399. /**
  85400. * Specifies if the material will require alpha blending
  85401. * @returns a boolean specifying if alpha blending is needed
  85402. */
  85403. needAlphaBlending(): boolean;
  85404. /**
  85405. * Specifies if the mesh will require alpha blending
  85406. * @param mesh defines the mesh to check
  85407. * @returns a boolean specifying if alpha blending is needed for the mesh
  85408. */
  85409. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85410. /**
  85411. * Specifies if this material should be rendered in alpha test mode
  85412. * @returns a boolean specifying if an alpha test is needed.
  85413. */
  85414. needAlphaTesting(): boolean;
  85415. /**
  85416. * Gets the texture used for the alpha test
  85417. * @returns the texture to use for alpha testing
  85418. */
  85419. getAlphaTestTexture(): Nullable<BaseTexture>;
  85420. /**
  85421. * Marks the material to indicate that it needs to be re-calculated
  85422. */
  85423. markDirty(): void;
  85424. /** @hidden */
  85425. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85426. /**
  85427. * Binds the material to the mesh
  85428. * @param world defines the world transformation matrix
  85429. * @param mesh defines the mesh to bind the material to
  85430. */
  85431. bind(world: Matrix, mesh?: Mesh): void;
  85432. /**
  85433. * Binds the submesh to the material
  85434. * @param world defines the world transformation matrix
  85435. * @param mesh defines the mesh containing the submesh
  85436. * @param subMesh defines the submesh to bind the material to
  85437. */
  85438. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85439. /**
  85440. * Binds the world matrix to the material
  85441. * @param world defines the world transformation matrix
  85442. */
  85443. bindOnlyWorldMatrix(world: Matrix): void;
  85444. /**
  85445. * Binds the scene's uniform buffer to the effect.
  85446. * @param effect defines the effect to bind to the scene uniform buffer
  85447. * @param sceneUbo defines the uniform buffer storing scene data
  85448. */
  85449. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85450. /**
  85451. * Binds the view matrix to the effect
  85452. * @param effect defines the effect to bind the view matrix to
  85453. */
  85454. bindView(effect: Effect): void;
  85455. /**
  85456. * Binds the view projection matrix to the effect
  85457. * @param effect defines the effect to bind the view projection matrix to
  85458. */
  85459. bindViewProjection(effect: Effect): void;
  85460. /**
  85461. * Specifies if material alpha testing should be turned on for the mesh
  85462. * @param mesh defines the mesh to check
  85463. */
  85464. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85465. /**
  85466. * Processes to execute after binding the material to a mesh
  85467. * @param mesh defines the rendered mesh
  85468. */
  85469. protected _afterBind(mesh?: Mesh): void;
  85470. /**
  85471. * Unbinds the material from the mesh
  85472. */
  85473. unbind(): void;
  85474. /**
  85475. * Gets the active textures from the material
  85476. * @returns an array of textures
  85477. */
  85478. getActiveTextures(): BaseTexture[];
  85479. /**
  85480. * Specifies if the material uses a texture
  85481. * @param texture defines the texture to check against the material
  85482. * @returns a boolean specifying if the material uses the texture
  85483. */
  85484. hasTexture(texture: BaseTexture): boolean;
  85485. /**
  85486. * Makes a duplicate of the material, and gives it a new name
  85487. * @param name defines the new name for the duplicated material
  85488. * @returns the cloned material
  85489. */
  85490. clone(name: string): Nullable<Material>;
  85491. /**
  85492. * Gets the meshes bound to the material
  85493. * @returns an array of meshes bound to the material
  85494. */
  85495. getBindedMeshes(): AbstractMesh[];
  85496. /**
  85497. * Force shader compilation
  85498. * @param mesh defines the mesh associated with this material
  85499. * @param onCompiled defines a function to execute once the material is compiled
  85500. * @param options defines the options to configure the compilation
  85501. */
  85502. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85503. clipPlane: boolean;
  85504. }>): void;
  85505. /**
  85506. * Force shader compilation
  85507. * @param mesh defines the mesh that will use this material
  85508. * @param options defines additional options for compiling the shaders
  85509. * @returns a promise that resolves when the compilation completes
  85510. */
  85511. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85512. clipPlane: boolean;
  85513. }>): Promise<void>;
  85514. private static readonly _AllDirtyCallBack;
  85515. private static readonly _ImageProcessingDirtyCallBack;
  85516. private static readonly _TextureDirtyCallBack;
  85517. private static readonly _FresnelDirtyCallBack;
  85518. private static readonly _MiscDirtyCallBack;
  85519. private static readonly _LightsDirtyCallBack;
  85520. private static readonly _AttributeDirtyCallBack;
  85521. private static _FresnelAndMiscDirtyCallBack;
  85522. private static _TextureAndMiscDirtyCallBack;
  85523. private static readonly _DirtyCallbackArray;
  85524. private static readonly _RunDirtyCallBacks;
  85525. /**
  85526. * Marks a define in the material to indicate that it needs to be re-computed
  85527. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85528. */
  85529. markAsDirty(flag: number): void;
  85530. /**
  85531. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85532. * @param func defines a function which checks material defines against the submeshes
  85533. */
  85534. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85535. /**
  85536. * Indicates that we need to re-calculated for all submeshes
  85537. */
  85538. protected _markAllSubMeshesAsAllDirty(): void;
  85539. /**
  85540. * Indicates that image processing needs to be re-calculated for all submeshes
  85541. */
  85542. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85543. /**
  85544. * Indicates that textures need to be re-calculated for all submeshes
  85545. */
  85546. protected _markAllSubMeshesAsTexturesDirty(): void;
  85547. /**
  85548. * Indicates that fresnel needs to be re-calculated for all submeshes
  85549. */
  85550. protected _markAllSubMeshesAsFresnelDirty(): void;
  85551. /**
  85552. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85553. */
  85554. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85555. /**
  85556. * Indicates that lights need to be re-calculated for all submeshes
  85557. */
  85558. protected _markAllSubMeshesAsLightsDirty(): void;
  85559. /**
  85560. * Indicates that attributes need to be re-calculated for all submeshes
  85561. */
  85562. protected _markAllSubMeshesAsAttributesDirty(): void;
  85563. /**
  85564. * Indicates that misc needs to be re-calculated for all submeshes
  85565. */
  85566. protected _markAllSubMeshesAsMiscDirty(): void;
  85567. /**
  85568. * Indicates that textures and misc need to be re-calculated for all submeshes
  85569. */
  85570. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85571. /**
  85572. * Disposes the material
  85573. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85574. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85575. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85576. */
  85577. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85578. /** @hidden */
  85579. private releaseVertexArrayObject;
  85580. /**
  85581. * Serializes this material
  85582. * @returns the serialized material object
  85583. */
  85584. serialize(): any;
  85585. /**
  85586. * Creates a material from parsed material data
  85587. * @param parsedMaterial defines parsed material data
  85588. * @param scene defines the hosting scene
  85589. * @param rootUrl defines the root URL to use to load textures
  85590. * @returns a new material
  85591. */
  85592. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85593. }
  85594. }
  85595. declare module BABYLON {
  85596. /**
  85597. * Base class for submeshes
  85598. */
  85599. export class BaseSubMesh {
  85600. /** @hidden */
  85601. _materialDefines: Nullable<MaterialDefines>;
  85602. /** @hidden */
  85603. _materialEffect: Nullable<Effect>;
  85604. /**
  85605. * Gets associated effect
  85606. */
  85607. readonly effect: Nullable<Effect>;
  85608. /**
  85609. * Sets associated effect (effect used to render this submesh)
  85610. * @param effect defines the effect to associate with
  85611. * @param defines defines the set of defines used to compile this effect
  85612. */
  85613. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85614. }
  85615. /**
  85616. * Defines a subdivision inside a mesh
  85617. */
  85618. export class SubMesh extends BaseSubMesh implements ICullable {
  85619. /** the material index to use */
  85620. materialIndex: number;
  85621. /** vertex index start */
  85622. verticesStart: number;
  85623. /** vertices count */
  85624. verticesCount: number;
  85625. /** index start */
  85626. indexStart: number;
  85627. /** indices count */
  85628. indexCount: number;
  85629. /** @hidden */
  85630. _linesIndexCount: number;
  85631. private _mesh;
  85632. private _renderingMesh;
  85633. private _boundingInfo;
  85634. private _linesIndexBuffer;
  85635. /** @hidden */
  85636. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85637. /** @hidden */
  85638. _trianglePlanes: Plane[];
  85639. /** @hidden */
  85640. _lastColliderTransformMatrix: Nullable<Matrix>;
  85641. /** @hidden */
  85642. _renderId: number;
  85643. /** @hidden */
  85644. _alphaIndex: number;
  85645. /** @hidden */
  85646. _distanceToCamera: number;
  85647. /** @hidden */
  85648. _id: number;
  85649. private _currentMaterial;
  85650. /**
  85651. * Add a new submesh to a mesh
  85652. * @param materialIndex defines the material index to use
  85653. * @param verticesStart defines vertex index start
  85654. * @param verticesCount defines vertices count
  85655. * @param indexStart defines index start
  85656. * @param indexCount defines indices count
  85657. * @param mesh defines the parent mesh
  85658. * @param renderingMesh defines an optional rendering mesh
  85659. * @param createBoundingBox defines if bounding box should be created for this submesh
  85660. * @returns the new submesh
  85661. */
  85662. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85663. /**
  85664. * Creates a new submesh
  85665. * @param materialIndex defines the material index to use
  85666. * @param verticesStart defines vertex index start
  85667. * @param verticesCount defines vertices count
  85668. * @param indexStart defines index start
  85669. * @param indexCount defines indices count
  85670. * @param mesh defines the parent mesh
  85671. * @param renderingMesh defines an optional rendering mesh
  85672. * @param createBoundingBox defines if bounding box should be created for this submesh
  85673. */
  85674. constructor(
  85675. /** the material index to use */
  85676. materialIndex: number,
  85677. /** vertex index start */
  85678. verticesStart: number,
  85679. /** vertices count */
  85680. verticesCount: number,
  85681. /** index start */
  85682. indexStart: number,
  85683. /** indices count */
  85684. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85685. /**
  85686. * Returns true if this submesh covers the entire parent mesh
  85687. * @ignorenaming
  85688. */
  85689. readonly IsGlobal: boolean;
  85690. /**
  85691. * Returns the submesh BoudingInfo object
  85692. * @returns current bounding info (or mesh's one if the submesh is global)
  85693. */
  85694. getBoundingInfo(): BoundingInfo;
  85695. /**
  85696. * Sets the submesh BoundingInfo
  85697. * @param boundingInfo defines the new bounding info to use
  85698. * @returns the SubMesh
  85699. */
  85700. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85701. /**
  85702. * Returns the mesh of the current submesh
  85703. * @return the parent mesh
  85704. */
  85705. getMesh(): AbstractMesh;
  85706. /**
  85707. * Returns the rendering mesh of the submesh
  85708. * @returns the rendering mesh (could be different from parent mesh)
  85709. */
  85710. getRenderingMesh(): Mesh;
  85711. /**
  85712. * Returns the submesh material
  85713. * @returns null or the current material
  85714. */
  85715. getMaterial(): Nullable<Material>;
  85716. /**
  85717. * Sets a new updated BoundingInfo object to the submesh
  85718. * @param data defines an optional position array to use to determine the bounding info
  85719. * @returns the SubMesh
  85720. */
  85721. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85722. /** @hidden */
  85723. _checkCollision(collider: Collider): boolean;
  85724. /**
  85725. * Updates the submesh BoundingInfo
  85726. * @param world defines the world matrix to use to update the bounding info
  85727. * @returns the submesh
  85728. */
  85729. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85730. /**
  85731. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85732. * @param frustumPlanes defines the frustum planes
  85733. * @returns true if the submesh is intersecting with the frustum
  85734. */
  85735. isInFrustum(frustumPlanes: Plane[]): boolean;
  85736. /**
  85737. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85738. * @param frustumPlanes defines the frustum planes
  85739. * @returns true if the submesh is inside the frustum
  85740. */
  85741. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85742. /**
  85743. * Renders the submesh
  85744. * @param enableAlphaMode defines if alpha needs to be used
  85745. * @returns the submesh
  85746. */
  85747. render(enableAlphaMode: boolean): SubMesh;
  85748. /**
  85749. * @hidden
  85750. */
  85751. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85752. /**
  85753. * Checks if the submesh intersects with a ray
  85754. * @param ray defines the ray to test
  85755. * @returns true is the passed ray intersects the submesh bounding box
  85756. */
  85757. canIntersects(ray: Ray): boolean;
  85758. /**
  85759. * Intersects current submesh with a ray
  85760. * @param ray defines the ray to test
  85761. * @param positions defines mesh's positions array
  85762. * @param indices defines mesh's indices array
  85763. * @param fastCheck defines if only bounding info should be used
  85764. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85765. * @returns intersection info or null if no intersection
  85766. */
  85767. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85768. /** @hidden */
  85769. private _intersectLines;
  85770. /** @hidden */
  85771. private _intersectUnIndexedLines;
  85772. /** @hidden */
  85773. private _intersectTriangles;
  85774. /** @hidden */
  85775. private _intersectUnIndexedTriangles;
  85776. /** @hidden */
  85777. _rebuild(): void;
  85778. /**
  85779. * Creates a new submesh from the passed mesh
  85780. * @param newMesh defines the new hosting mesh
  85781. * @param newRenderingMesh defines an optional rendering mesh
  85782. * @returns the new submesh
  85783. */
  85784. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85785. /**
  85786. * Release associated resources
  85787. */
  85788. dispose(): void;
  85789. /**
  85790. * Gets the class name
  85791. * @returns the string "SubMesh".
  85792. */
  85793. getClassName(): string;
  85794. /**
  85795. * Creates a new submesh from indices data
  85796. * @param materialIndex the index of the main mesh material
  85797. * @param startIndex the index where to start the copy in the mesh indices array
  85798. * @param indexCount the number of indices to copy then from the startIndex
  85799. * @param mesh the main mesh to create the submesh from
  85800. * @param renderingMesh the optional rendering mesh
  85801. * @returns a new submesh
  85802. */
  85803. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85804. }
  85805. }
  85806. declare module BABYLON {
  85807. /**
  85808. * Class used to store geometry data (vertex buffers + index buffer)
  85809. */
  85810. export class Geometry implements IGetSetVerticesData {
  85811. /**
  85812. * Gets or sets the ID of the geometry
  85813. */
  85814. id: string;
  85815. /**
  85816. * Gets or sets the unique ID of the geometry
  85817. */
  85818. uniqueId: number;
  85819. /**
  85820. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85821. */
  85822. delayLoadState: number;
  85823. /**
  85824. * Gets the file containing the data to load when running in delay load state
  85825. */
  85826. delayLoadingFile: Nullable<string>;
  85827. /**
  85828. * Callback called when the geometry is updated
  85829. */
  85830. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85831. private _scene;
  85832. private _engine;
  85833. private _meshes;
  85834. private _totalVertices;
  85835. /** @hidden */
  85836. _indices: IndicesArray;
  85837. /** @hidden */
  85838. _vertexBuffers: {
  85839. [key: string]: VertexBuffer;
  85840. };
  85841. private _isDisposed;
  85842. private _extend;
  85843. private _boundingBias;
  85844. /** @hidden */
  85845. _delayInfo: Array<string>;
  85846. private _indexBuffer;
  85847. private _indexBufferIsUpdatable;
  85848. /** @hidden */
  85849. _boundingInfo: Nullable<BoundingInfo>;
  85850. /** @hidden */
  85851. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85852. /** @hidden */
  85853. _softwareSkinningFrameId: number;
  85854. private _vertexArrayObjects;
  85855. private _updatable;
  85856. /** @hidden */
  85857. _positions: Nullable<Vector3[]>;
  85858. /**
  85859. * 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
  85860. */
  85861. /**
  85862. * 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
  85863. */
  85864. boundingBias: Vector2;
  85865. /**
  85866. * Static function used to attach a new empty geometry to a mesh
  85867. * @param mesh defines the mesh to attach the geometry to
  85868. * @returns the new Geometry
  85869. */
  85870. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85871. /**
  85872. * Creates a new geometry
  85873. * @param id defines the unique ID
  85874. * @param scene defines the hosting scene
  85875. * @param vertexData defines the VertexData used to get geometry data
  85876. * @param updatable defines if geometry must be updatable (false by default)
  85877. * @param mesh defines the mesh that will be associated with the geometry
  85878. */
  85879. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85880. /**
  85881. * Gets the current extend of the geometry
  85882. */
  85883. readonly extend: {
  85884. minimum: Vector3;
  85885. maximum: Vector3;
  85886. };
  85887. /**
  85888. * Gets the hosting scene
  85889. * @returns the hosting Scene
  85890. */
  85891. getScene(): Scene;
  85892. /**
  85893. * Gets the hosting engine
  85894. * @returns the hosting Engine
  85895. */
  85896. getEngine(): Engine;
  85897. /**
  85898. * Defines if the geometry is ready to use
  85899. * @returns true if the geometry is ready to be used
  85900. */
  85901. isReady(): boolean;
  85902. /**
  85903. * Gets a value indicating that the geometry should not be serialized
  85904. */
  85905. readonly doNotSerialize: boolean;
  85906. /** @hidden */
  85907. _rebuild(): void;
  85908. /**
  85909. * Affects all geometry data in one call
  85910. * @param vertexData defines the geometry data
  85911. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85912. */
  85913. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85914. /**
  85915. * Set specific vertex data
  85916. * @param kind defines the data kind (Position, normal, etc...)
  85917. * @param data defines the vertex data to use
  85918. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85919. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85920. */
  85921. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85922. /**
  85923. * Removes a specific vertex data
  85924. * @param kind defines the data kind (Position, normal, etc...)
  85925. */
  85926. removeVerticesData(kind: string): void;
  85927. /**
  85928. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85929. * @param buffer defines the vertex buffer to use
  85930. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85931. */
  85932. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85933. /**
  85934. * Update a specific vertex buffer
  85935. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85936. * It will do nothing if the buffer is not updatable
  85937. * @param kind defines the data kind (Position, normal, etc...)
  85938. * @param data defines the data to use
  85939. * @param offset defines the offset in the target buffer where to store the data
  85940. * @param useBytes set to true if the offset is in bytes
  85941. */
  85942. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85943. /**
  85944. * Update a specific vertex buffer
  85945. * This function will create a new buffer if the current one is not updatable
  85946. * @param kind defines the data kind (Position, normal, etc...)
  85947. * @param data defines the data to use
  85948. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85949. */
  85950. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85951. private _updateBoundingInfo;
  85952. /** @hidden */
  85953. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85954. /**
  85955. * Gets total number of vertices
  85956. * @returns the total number of vertices
  85957. */
  85958. getTotalVertices(): number;
  85959. /**
  85960. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85961. * @param kind defines the data kind (Position, normal, etc...)
  85962. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85964. * @returns a float array containing vertex data
  85965. */
  85966. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85967. /**
  85968. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85969. * @param kind defines the data kind (Position, normal, etc...)
  85970. * @returns true if the vertex buffer with the specified kind is updatable
  85971. */
  85972. isVertexBufferUpdatable(kind: string): boolean;
  85973. /**
  85974. * Gets a specific vertex buffer
  85975. * @param kind defines the data kind (Position, normal, etc...)
  85976. * @returns a VertexBuffer
  85977. */
  85978. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85979. /**
  85980. * Returns all vertex buffers
  85981. * @return an object holding all vertex buffers indexed by kind
  85982. */
  85983. getVertexBuffers(): Nullable<{
  85984. [key: string]: VertexBuffer;
  85985. }>;
  85986. /**
  85987. * Gets a boolean indicating if specific vertex buffer is present
  85988. * @param kind defines the data kind (Position, normal, etc...)
  85989. * @returns true if data is present
  85990. */
  85991. isVerticesDataPresent(kind: string): boolean;
  85992. /**
  85993. * Gets a list of all attached data kinds (Position, normal, etc...)
  85994. * @returns a list of string containing all kinds
  85995. */
  85996. getVerticesDataKinds(): string[];
  85997. /**
  85998. * Update index buffer
  85999. * @param indices defines the indices to store in the index buffer
  86000. * @param offset defines the offset in the target buffer where to store the data
  86001. * @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)
  86002. */
  86003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86004. /**
  86005. * Creates a new index buffer
  86006. * @param indices defines the indices to store in the index buffer
  86007. * @param totalVertices defines the total number of vertices (could be null)
  86008. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86009. */
  86010. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86011. /**
  86012. * Return the total number of indices
  86013. * @returns the total number of indices
  86014. */
  86015. getTotalIndices(): number;
  86016. /**
  86017. * Gets the index buffer array
  86018. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86019. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86020. * @returns the index buffer array
  86021. */
  86022. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86023. /**
  86024. * Gets the index buffer
  86025. * @return the index buffer
  86026. */
  86027. getIndexBuffer(): Nullable<DataBuffer>;
  86028. /** @hidden */
  86029. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86030. /**
  86031. * Release the associated resources for a specific mesh
  86032. * @param mesh defines the source mesh
  86033. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86034. */
  86035. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86036. /**
  86037. * Apply current geometry to a given mesh
  86038. * @param mesh defines the mesh to apply geometry to
  86039. */
  86040. applyToMesh(mesh: Mesh): void;
  86041. private _updateExtend;
  86042. private _applyToMesh;
  86043. private notifyUpdate;
  86044. /**
  86045. * Load the geometry if it was flagged as delay loaded
  86046. * @param scene defines the hosting scene
  86047. * @param onLoaded defines a callback called when the geometry is loaded
  86048. */
  86049. load(scene: Scene, onLoaded?: () => void): void;
  86050. private _queueLoad;
  86051. /**
  86052. * Invert the geometry to move from a right handed system to a left handed one.
  86053. */
  86054. toLeftHanded(): void;
  86055. /** @hidden */
  86056. _resetPointsArrayCache(): void;
  86057. /** @hidden */
  86058. _generatePointsArray(): boolean;
  86059. /**
  86060. * Gets a value indicating if the geometry is disposed
  86061. * @returns true if the geometry was disposed
  86062. */
  86063. isDisposed(): boolean;
  86064. private _disposeVertexArrayObjects;
  86065. /**
  86066. * Free all associated resources
  86067. */
  86068. dispose(): void;
  86069. /**
  86070. * Clone the current geometry into a new geometry
  86071. * @param id defines the unique ID of the new geometry
  86072. * @returns a new geometry object
  86073. */
  86074. copy(id: string): Geometry;
  86075. /**
  86076. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86077. * @return a JSON representation of the current geometry data (without the vertices data)
  86078. */
  86079. serialize(): any;
  86080. private toNumberArray;
  86081. /**
  86082. * Serialize all vertices data into a JSON oject
  86083. * @returns a JSON representation of the current geometry data
  86084. */
  86085. serializeVerticeData(): any;
  86086. /**
  86087. * Extracts a clone of a mesh geometry
  86088. * @param mesh defines the source mesh
  86089. * @param id defines the unique ID of the new geometry object
  86090. * @returns the new geometry object
  86091. */
  86092. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86093. /**
  86094. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86095. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86096. * Be aware Math.random() could cause collisions, but:
  86097. * "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"
  86098. * @returns a string containing a new GUID
  86099. */
  86100. static RandomId(): string;
  86101. /** @hidden */
  86102. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86103. private static _CleanMatricesWeights;
  86104. /**
  86105. * Create a new geometry from persisted data (Using .babylon file format)
  86106. * @param parsedVertexData defines the persisted data
  86107. * @param scene defines the hosting scene
  86108. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86109. * @returns the new geometry object
  86110. */
  86111. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86112. }
  86113. }
  86114. declare module BABYLON {
  86115. /**
  86116. * Define an interface for all classes that will get and set the data on vertices
  86117. */
  86118. export interface IGetSetVerticesData {
  86119. /**
  86120. * Gets a boolean indicating if specific vertex data is present
  86121. * @param kind defines the vertex data kind to use
  86122. * @returns true is data kind is present
  86123. */
  86124. isVerticesDataPresent(kind: string): boolean;
  86125. /**
  86126. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86127. * @param kind defines the data kind (Position, normal, etc...)
  86128. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86129. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86130. * @returns a float array containing vertex data
  86131. */
  86132. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86133. /**
  86134. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86135. * @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.
  86136. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86137. * @returns the indices array or an empty array if the mesh has no geometry
  86138. */
  86139. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86140. /**
  86141. * Set specific vertex data
  86142. * @param kind defines the data kind (Position, normal, etc...)
  86143. * @param data defines the vertex data to use
  86144. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86145. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86146. */
  86147. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86148. /**
  86149. * Update a specific associated vertex buffer
  86150. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86151. * - VertexBuffer.PositionKind
  86152. * - VertexBuffer.UVKind
  86153. * - VertexBuffer.UV2Kind
  86154. * - VertexBuffer.UV3Kind
  86155. * - VertexBuffer.UV4Kind
  86156. * - VertexBuffer.UV5Kind
  86157. * - VertexBuffer.UV6Kind
  86158. * - VertexBuffer.ColorKind
  86159. * - VertexBuffer.MatricesIndicesKind
  86160. * - VertexBuffer.MatricesIndicesExtraKind
  86161. * - VertexBuffer.MatricesWeightsKind
  86162. * - VertexBuffer.MatricesWeightsExtraKind
  86163. * @param data defines the data source
  86164. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86165. * @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)
  86166. */
  86167. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86168. /**
  86169. * Creates a new index buffer
  86170. * @param indices defines the indices to store in the index buffer
  86171. * @param totalVertices defines the total number of vertices (could be null)
  86172. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86173. */
  86174. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86175. }
  86176. /**
  86177. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86178. */
  86179. export class VertexData {
  86180. /**
  86181. * Mesh side orientation : usually the external or front surface
  86182. */
  86183. static readonly FRONTSIDE: number;
  86184. /**
  86185. * Mesh side orientation : usually the internal or back surface
  86186. */
  86187. static readonly BACKSIDE: number;
  86188. /**
  86189. * Mesh side orientation : both internal and external or front and back surfaces
  86190. */
  86191. static readonly DOUBLESIDE: number;
  86192. /**
  86193. * Mesh side orientation : by default, `FRONTSIDE`
  86194. */
  86195. static readonly DEFAULTSIDE: number;
  86196. /**
  86197. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86198. */
  86199. positions: Nullable<FloatArray>;
  86200. /**
  86201. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86202. */
  86203. normals: Nullable<FloatArray>;
  86204. /**
  86205. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86206. */
  86207. tangents: Nullable<FloatArray>;
  86208. /**
  86209. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86210. */
  86211. uvs: Nullable<FloatArray>;
  86212. /**
  86213. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86214. */
  86215. uvs2: Nullable<FloatArray>;
  86216. /**
  86217. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86218. */
  86219. uvs3: Nullable<FloatArray>;
  86220. /**
  86221. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86222. */
  86223. uvs4: Nullable<FloatArray>;
  86224. /**
  86225. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86226. */
  86227. uvs5: Nullable<FloatArray>;
  86228. /**
  86229. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86230. */
  86231. uvs6: Nullable<FloatArray>;
  86232. /**
  86233. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86234. */
  86235. colors: Nullable<FloatArray>;
  86236. /**
  86237. * 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).
  86238. */
  86239. matricesIndices: Nullable<FloatArray>;
  86240. /**
  86241. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86242. */
  86243. matricesWeights: Nullable<FloatArray>;
  86244. /**
  86245. * An array extending the number of possible indices
  86246. */
  86247. matricesIndicesExtra: Nullable<FloatArray>;
  86248. /**
  86249. * An array extending the number of possible weights when the number of indices is extended
  86250. */
  86251. matricesWeightsExtra: Nullable<FloatArray>;
  86252. /**
  86253. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86254. */
  86255. indices: Nullable<IndicesArray>;
  86256. /**
  86257. * Uses the passed data array to set the set the values for the specified kind of data
  86258. * @param data a linear array of floating numbers
  86259. * @param kind the type of data that is being set, eg positions, colors etc
  86260. */
  86261. set(data: FloatArray, kind: string): void;
  86262. /**
  86263. * Associates the vertexData to the passed Mesh.
  86264. * Sets it as updatable or not (default `false`)
  86265. * @param mesh the mesh the vertexData is applied to
  86266. * @param updatable when used and having the value true allows new data to update the vertexData
  86267. * @returns the VertexData
  86268. */
  86269. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86270. /**
  86271. * Associates the vertexData to the passed Geometry.
  86272. * Sets it as updatable or not (default `false`)
  86273. * @param geometry the geometry the vertexData is applied to
  86274. * @param updatable when used and having the value true allows new data to update the vertexData
  86275. * @returns VertexData
  86276. */
  86277. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86278. /**
  86279. * Updates the associated mesh
  86280. * @param mesh the mesh to be updated
  86281. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86282. * @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
  86283. * @returns VertexData
  86284. */
  86285. updateMesh(mesh: Mesh): VertexData;
  86286. /**
  86287. * Updates the associated geometry
  86288. * @param geometry the geometry to be updated
  86289. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86290. * @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
  86291. * @returns VertexData.
  86292. */
  86293. updateGeometry(geometry: Geometry): VertexData;
  86294. private _applyTo;
  86295. private _update;
  86296. /**
  86297. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86298. * @param matrix the transforming matrix
  86299. * @returns the VertexData
  86300. */
  86301. transform(matrix: Matrix): VertexData;
  86302. /**
  86303. * Merges the passed VertexData into the current one
  86304. * @param other the VertexData to be merged into the current one
  86305. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86306. * @returns the modified VertexData
  86307. */
  86308. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86309. private _mergeElement;
  86310. private _validate;
  86311. /**
  86312. * Serializes the VertexData
  86313. * @returns a serialized object
  86314. */
  86315. serialize(): any;
  86316. /**
  86317. * Extracts the vertexData from a mesh
  86318. * @param mesh the mesh from which to extract the VertexData
  86319. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86320. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86321. * @returns the object VertexData associated to the passed mesh
  86322. */
  86323. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86324. /**
  86325. * Extracts the vertexData from the geometry
  86326. * @param geometry the geometry from which to extract the VertexData
  86327. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86328. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86329. * @returns the object VertexData associated to the passed mesh
  86330. */
  86331. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86332. private static _ExtractFrom;
  86333. /**
  86334. * Creates the VertexData for a Ribbon
  86335. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86336. * * pathArray array of paths, each of which an array of successive Vector3
  86337. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86338. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86339. * * 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
  86340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86341. * * 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)
  86342. * * 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)
  86343. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86344. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86345. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86346. * @returns the VertexData of the ribbon
  86347. */
  86348. static CreateRibbon(options: {
  86349. pathArray: Vector3[][];
  86350. closeArray?: boolean;
  86351. closePath?: boolean;
  86352. offset?: number;
  86353. sideOrientation?: number;
  86354. frontUVs?: Vector4;
  86355. backUVs?: Vector4;
  86356. invertUV?: boolean;
  86357. uvs?: Vector2[];
  86358. colors?: Color4[];
  86359. }): VertexData;
  86360. /**
  86361. * Creates the VertexData for a box
  86362. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86363. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86364. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86365. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86366. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86367. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86368. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86370. * * 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)
  86371. * * 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)
  86372. * @returns the VertexData of the box
  86373. */
  86374. static CreateBox(options: {
  86375. size?: number;
  86376. width?: number;
  86377. height?: number;
  86378. depth?: number;
  86379. faceUV?: Vector4[];
  86380. faceColors?: Color4[];
  86381. sideOrientation?: number;
  86382. frontUVs?: Vector4;
  86383. backUVs?: Vector4;
  86384. }): VertexData;
  86385. /**
  86386. * Creates the VertexData for a tiled box
  86387. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86388. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86389. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86390. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86391. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86392. * @returns the VertexData of the box
  86393. */
  86394. static CreateTiledBox(options: {
  86395. pattern?: number;
  86396. width?: number;
  86397. height?: number;
  86398. depth?: number;
  86399. tileSize?: number;
  86400. tileWidth?: number;
  86401. tileHeight?: number;
  86402. alignHorizontal?: number;
  86403. alignVertical?: number;
  86404. faceUV?: Vector4[];
  86405. faceColors?: Color4[];
  86406. sideOrientation?: number;
  86407. }): VertexData;
  86408. /**
  86409. * Creates the VertexData for a tiled plane
  86410. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86411. * * pattern a limited pattern arrangement depending on the number
  86412. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86413. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86414. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86416. * * 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)
  86417. * * 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)
  86418. * @returns the VertexData of the tiled plane
  86419. */
  86420. static CreateTiledPlane(options: {
  86421. pattern?: number;
  86422. tileSize?: number;
  86423. tileWidth?: number;
  86424. tileHeight?: number;
  86425. size?: number;
  86426. width?: number;
  86427. height?: number;
  86428. alignHorizontal?: number;
  86429. alignVertical?: number;
  86430. sideOrientation?: number;
  86431. frontUVs?: Vector4;
  86432. backUVs?: Vector4;
  86433. }): VertexData;
  86434. /**
  86435. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86436. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86437. * * segments sets the number of horizontal strips optional, default 32
  86438. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86439. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86440. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86441. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86442. * * 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
  86443. * * 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
  86444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86445. * * 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)
  86446. * * 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)
  86447. * @returns the VertexData of the ellipsoid
  86448. */
  86449. static CreateSphere(options: {
  86450. segments?: number;
  86451. diameter?: number;
  86452. diameterX?: number;
  86453. diameterY?: number;
  86454. diameterZ?: number;
  86455. arc?: number;
  86456. slice?: number;
  86457. sideOrientation?: number;
  86458. frontUVs?: Vector4;
  86459. backUVs?: Vector4;
  86460. }): VertexData;
  86461. /**
  86462. * Creates the VertexData for a cylinder, cone or prism
  86463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86464. * * height sets the height (y direction) of the cylinder, optional, default 2
  86465. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86466. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86467. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86468. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86469. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86470. * * 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
  86471. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86472. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86473. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86474. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86476. * * 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)
  86477. * * 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)
  86478. * @returns the VertexData of the cylinder, cone or prism
  86479. */
  86480. static CreateCylinder(options: {
  86481. height?: number;
  86482. diameterTop?: number;
  86483. diameterBottom?: number;
  86484. diameter?: number;
  86485. tessellation?: number;
  86486. subdivisions?: number;
  86487. arc?: number;
  86488. faceColors?: Color4[];
  86489. faceUV?: Vector4[];
  86490. hasRings?: boolean;
  86491. enclose?: boolean;
  86492. sideOrientation?: number;
  86493. frontUVs?: Vector4;
  86494. backUVs?: Vector4;
  86495. }): VertexData;
  86496. /**
  86497. * Creates the VertexData for a torus
  86498. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86499. * * diameter the diameter of the torus, optional default 1
  86500. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86501. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86503. * * 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)
  86504. * * 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)
  86505. * @returns the VertexData of the torus
  86506. */
  86507. static CreateTorus(options: {
  86508. diameter?: number;
  86509. thickness?: number;
  86510. tessellation?: number;
  86511. sideOrientation?: number;
  86512. frontUVs?: Vector4;
  86513. backUVs?: Vector4;
  86514. }): VertexData;
  86515. /**
  86516. * Creates the VertexData of the LineSystem
  86517. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86518. * - lines an array of lines, each line being an array of successive Vector3
  86519. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86520. * @returns the VertexData of the LineSystem
  86521. */
  86522. static CreateLineSystem(options: {
  86523. lines: Vector3[][];
  86524. colors?: Nullable<Color4[][]>;
  86525. }): VertexData;
  86526. /**
  86527. * Create the VertexData for a DashedLines
  86528. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86529. * - points an array successive Vector3
  86530. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86531. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86532. * - dashNb the intended total number of dashes, optional, default 200
  86533. * @returns the VertexData for the DashedLines
  86534. */
  86535. static CreateDashedLines(options: {
  86536. points: Vector3[];
  86537. dashSize?: number;
  86538. gapSize?: number;
  86539. dashNb?: number;
  86540. }): VertexData;
  86541. /**
  86542. * Creates the VertexData for a Ground
  86543. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86544. * - width the width (x direction) of the ground, optional, default 1
  86545. * - height the height (z direction) of the ground, optional, default 1
  86546. * - subdivisions the number of subdivisions per side, optional, default 1
  86547. * @returns the VertexData of the Ground
  86548. */
  86549. static CreateGround(options: {
  86550. width?: number;
  86551. height?: number;
  86552. subdivisions?: number;
  86553. subdivisionsX?: number;
  86554. subdivisionsY?: number;
  86555. }): VertexData;
  86556. /**
  86557. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86558. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86559. * * xmin the ground minimum X coordinate, optional, default -1
  86560. * * zmin the ground minimum Z coordinate, optional, default -1
  86561. * * xmax the ground maximum X coordinate, optional, default 1
  86562. * * zmax the ground maximum Z coordinate, optional, default 1
  86563. * * 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}
  86564. * * 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}
  86565. * @returns the VertexData of the TiledGround
  86566. */
  86567. static CreateTiledGround(options: {
  86568. xmin: number;
  86569. zmin: number;
  86570. xmax: number;
  86571. zmax: number;
  86572. subdivisions?: {
  86573. w: number;
  86574. h: number;
  86575. };
  86576. precision?: {
  86577. w: number;
  86578. h: number;
  86579. };
  86580. }): VertexData;
  86581. /**
  86582. * Creates the VertexData of the Ground designed from a heightmap
  86583. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86584. * * width the width (x direction) of the ground
  86585. * * height the height (z direction) of the ground
  86586. * * subdivisions the number of subdivisions per side
  86587. * * minHeight the minimum altitude on the ground, optional, default 0
  86588. * * maxHeight the maximum altitude on the ground, optional default 1
  86589. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86590. * * buffer the array holding the image color data
  86591. * * bufferWidth the width of image
  86592. * * bufferHeight the height of image
  86593. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86594. * @returns the VertexData of the Ground designed from a heightmap
  86595. */
  86596. static CreateGroundFromHeightMap(options: {
  86597. width: number;
  86598. height: number;
  86599. subdivisions: number;
  86600. minHeight: number;
  86601. maxHeight: number;
  86602. colorFilter: Color3;
  86603. buffer: Uint8Array;
  86604. bufferWidth: number;
  86605. bufferHeight: number;
  86606. alphaFilter: number;
  86607. }): VertexData;
  86608. /**
  86609. * Creates the VertexData for a Plane
  86610. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86611. * * size sets the width and height of the plane to the value of size, optional default 1
  86612. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86613. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86615. * * 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)
  86616. * * 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)
  86617. * @returns the VertexData of the box
  86618. */
  86619. static CreatePlane(options: {
  86620. size?: number;
  86621. width?: number;
  86622. height?: number;
  86623. sideOrientation?: number;
  86624. frontUVs?: Vector4;
  86625. backUVs?: Vector4;
  86626. }): VertexData;
  86627. /**
  86628. * Creates the VertexData of the Disc or regular Polygon
  86629. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86630. * * radius the radius of the disc, optional default 0.5
  86631. * * tessellation the number of polygon sides, optional, default 64
  86632. * * 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
  86633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86634. * * 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)
  86635. * * 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)
  86636. * @returns the VertexData of the box
  86637. */
  86638. static CreateDisc(options: {
  86639. radius?: number;
  86640. tessellation?: number;
  86641. arc?: number;
  86642. sideOrientation?: number;
  86643. frontUVs?: Vector4;
  86644. backUVs?: Vector4;
  86645. }): VertexData;
  86646. /**
  86647. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86648. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86649. * @param polygon a mesh built from polygonTriangulation.build()
  86650. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86651. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86652. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86653. * @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)
  86654. * @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)
  86655. * @returns the VertexData of the Polygon
  86656. */
  86657. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86658. /**
  86659. * Creates the VertexData of the IcoSphere
  86660. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86661. * * radius the radius of the IcoSphere, optional default 1
  86662. * * radiusX allows stretching in the x direction, optional, default radius
  86663. * * radiusY allows stretching in the y direction, optional, default radius
  86664. * * radiusZ allows stretching in the z direction, optional, default radius
  86665. * * flat when true creates a flat shaded mesh, optional, default true
  86666. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86667. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86668. * * 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)
  86669. * * 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)
  86670. * @returns the VertexData of the IcoSphere
  86671. */
  86672. static CreateIcoSphere(options: {
  86673. radius?: number;
  86674. radiusX?: number;
  86675. radiusY?: number;
  86676. radiusZ?: number;
  86677. flat?: boolean;
  86678. subdivisions?: number;
  86679. sideOrientation?: number;
  86680. frontUVs?: Vector4;
  86681. backUVs?: Vector4;
  86682. }): VertexData;
  86683. /**
  86684. * Creates the VertexData for a Polyhedron
  86685. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86686. * * type provided types are:
  86687. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86688. * * 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)
  86689. * * size the size of the IcoSphere, optional default 1
  86690. * * sizeX allows stretching in the x direction, optional, default size
  86691. * * sizeY allows stretching in the y direction, optional, default size
  86692. * * sizeZ allows stretching in the z direction, optional, default size
  86693. * * 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
  86694. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86695. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86696. * * flat when true creates a flat shaded mesh, optional, default true
  86697. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86699. * * 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)
  86700. * * 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)
  86701. * @returns the VertexData of the Polyhedron
  86702. */
  86703. static CreatePolyhedron(options: {
  86704. type?: number;
  86705. size?: number;
  86706. sizeX?: number;
  86707. sizeY?: number;
  86708. sizeZ?: number;
  86709. custom?: any;
  86710. faceUV?: Vector4[];
  86711. faceColors?: Color4[];
  86712. flat?: boolean;
  86713. sideOrientation?: number;
  86714. frontUVs?: Vector4;
  86715. backUVs?: Vector4;
  86716. }): VertexData;
  86717. /**
  86718. * Creates the VertexData for a TorusKnot
  86719. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86720. * * radius the radius of the torus knot, optional, default 2
  86721. * * tube the thickness of the tube, optional, default 0.5
  86722. * * radialSegments the number of sides on each tube segments, optional, default 32
  86723. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86724. * * p the number of windings around the z axis, optional, default 2
  86725. * * q the number of windings around the x axis, optional, default 3
  86726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86727. * * 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)
  86728. * * 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)
  86729. * @returns the VertexData of the Torus Knot
  86730. */
  86731. static CreateTorusKnot(options: {
  86732. radius?: number;
  86733. tube?: number;
  86734. radialSegments?: number;
  86735. tubularSegments?: number;
  86736. p?: number;
  86737. q?: number;
  86738. sideOrientation?: number;
  86739. frontUVs?: Vector4;
  86740. backUVs?: Vector4;
  86741. }): VertexData;
  86742. /**
  86743. * Compute normals for given positions and indices
  86744. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86745. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86746. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86747. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86748. * * facetNormals : optional array of facet normals (vector3)
  86749. * * facetPositions : optional array of facet positions (vector3)
  86750. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86751. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86752. * * bInfo : optional bounding info, required for facetPartitioning computation
  86753. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86754. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86755. * * useRightHandedSystem: optional boolean to for right handed system computation
  86756. * * depthSort : optional boolean to enable the facet depth sort computation
  86757. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86758. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86759. */
  86760. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86761. facetNormals?: any;
  86762. facetPositions?: any;
  86763. facetPartitioning?: any;
  86764. ratio?: number;
  86765. bInfo?: any;
  86766. bbSize?: Vector3;
  86767. subDiv?: any;
  86768. useRightHandedSystem?: boolean;
  86769. depthSort?: boolean;
  86770. distanceTo?: Vector3;
  86771. depthSortedFacets?: any;
  86772. }): void;
  86773. /** @hidden */
  86774. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86775. /**
  86776. * Applies VertexData created from the imported parameters to the geometry
  86777. * @param parsedVertexData the parsed data from an imported file
  86778. * @param geometry the geometry to apply the VertexData to
  86779. */
  86780. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86781. }
  86782. }
  86783. declare module BABYLON {
  86784. /**
  86785. * Class containing static functions to help procedurally build meshes
  86786. */
  86787. export class DiscBuilder {
  86788. /**
  86789. * Creates a plane polygonal mesh. By default, this is a disc
  86790. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86791. * * 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
  86792. * * 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
  86793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86796. * @param name defines the name of the mesh
  86797. * @param options defines the options used to create the mesh
  86798. * @param scene defines the hosting scene
  86799. * @returns the plane polygonal mesh
  86800. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86801. */
  86802. static CreateDisc(name: string, options: {
  86803. radius?: number;
  86804. tessellation?: number;
  86805. arc?: number;
  86806. updatable?: boolean;
  86807. sideOrientation?: number;
  86808. frontUVs?: Vector4;
  86809. backUVs?: Vector4;
  86810. }, scene?: Nullable<Scene>): Mesh;
  86811. }
  86812. }
  86813. declare module BABYLON {
  86814. /**
  86815. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86816. *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.
  86817. * The SPS is also a particle system. It provides some methods to manage the particles.
  86818. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86819. *
  86820. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86821. */
  86822. export class SolidParticleSystem implements IDisposable {
  86823. /**
  86824. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86825. * Example : var p = SPS.particles[i];
  86826. */
  86827. particles: SolidParticle[];
  86828. /**
  86829. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86830. */
  86831. nbParticles: number;
  86832. /**
  86833. * If the particles must ever face the camera (default false). Useful for planar particles.
  86834. */
  86835. billboard: boolean;
  86836. /**
  86837. * Recompute normals when adding a shape
  86838. */
  86839. recomputeNormals: boolean;
  86840. /**
  86841. * This a counter ofr your own usage. It's not set by any SPS functions.
  86842. */
  86843. counter: number;
  86844. /**
  86845. * The SPS name. This name is also given to the underlying mesh.
  86846. */
  86847. name: string;
  86848. /**
  86849. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86850. */
  86851. mesh: Mesh;
  86852. /**
  86853. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86854. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86855. */
  86856. vars: any;
  86857. /**
  86858. * This array is populated when the SPS is set as 'pickable'.
  86859. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86860. * Each element of this array is an object `{idx: int, faceId: int}`.
  86861. * `idx` is the picked particle index in the `SPS.particles` array
  86862. * `faceId` is the picked face index counted within this particle.
  86863. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86864. */
  86865. pickedParticles: {
  86866. idx: number;
  86867. faceId: number;
  86868. }[];
  86869. /**
  86870. * This array is populated when `enableDepthSort` is set to true.
  86871. * Each element of this array is an instance of the class DepthSortedParticle.
  86872. */
  86873. depthSortedParticles: DepthSortedParticle[];
  86874. /**
  86875. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86876. * @hidden
  86877. */
  86878. _bSphereOnly: boolean;
  86879. /**
  86880. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86881. * @hidden
  86882. */
  86883. _bSphereRadiusFactor: number;
  86884. private _scene;
  86885. private _positions;
  86886. private _indices;
  86887. private _normals;
  86888. private _colors;
  86889. private _uvs;
  86890. private _indices32;
  86891. private _positions32;
  86892. private _normals32;
  86893. private _fixedNormal32;
  86894. private _colors32;
  86895. private _uvs32;
  86896. private _index;
  86897. private _updatable;
  86898. private _pickable;
  86899. private _isVisibilityBoxLocked;
  86900. private _alwaysVisible;
  86901. private _depthSort;
  86902. private _shapeCounter;
  86903. private _copy;
  86904. private _color;
  86905. private _computeParticleColor;
  86906. private _computeParticleTexture;
  86907. private _computeParticleRotation;
  86908. private _computeParticleVertex;
  86909. private _computeBoundingBox;
  86910. private _depthSortParticles;
  86911. private _camera;
  86912. private _mustUnrotateFixedNormals;
  86913. private _particlesIntersect;
  86914. private _needs32Bits;
  86915. /**
  86916. * Creates a SPS (Solid Particle System) object.
  86917. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86918. * @param scene (Scene) is the scene in which the SPS is added.
  86919. * @param options defines the options of the sps e.g.
  86920. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86921. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86922. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86923. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86924. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86925. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86926. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86927. */
  86928. constructor(name: string, scene: Scene, options?: {
  86929. updatable?: boolean;
  86930. isPickable?: boolean;
  86931. enableDepthSort?: boolean;
  86932. particleIntersection?: boolean;
  86933. boundingSphereOnly?: boolean;
  86934. bSphereRadiusFactor?: number;
  86935. });
  86936. /**
  86937. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86938. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86939. * @returns the created mesh
  86940. */
  86941. buildMesh(): Mesh;
  86942. /**
  86943. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86944. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86945. * Thus the particles generated from `digest()` have their property `position` set yet.
  86946. * @param mesh ( Mesh ) is the mesh to be digested
  86947. * @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
  86948. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86949. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86950. * @returns the current SPS
  86951. */
  86952. digest(mesh: Mesh, options?: {
  86953. facetNb?: number;
  86954. number?: number;
  86955. delta?: number;
  86956. }): SolidParticleSystem;
  86957. private _unrotateFixedNormals;
  86958. private _resetCopy;
  86959. private _meshBuilder;
  86960. private _posToShape;
  86961. private _uvsToShapeUV;
  86962. private _addParticle;
  86963. /**
  86964. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86965. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86966. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86967. * @param nb (positive integer) the number of particles to be created from this model
  86968. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86969. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86970. * @returns the number of shapes in the system
  86971. */
  86972. addShape(mesh: Mesh, nb: number, options?: {
  86973. positionFunction?: any;
  86974. vertexFunction?: any;
  86975. }): number;
  86976. private _rebuildParticle;
  86977. /**
  86978. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86979. * @returns the SPS.
  86980. */
  86981. rebuildMesh(): SolidParticleSystem;
  86982. /**
  86983. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86984. * This method calls `updateParticle()` for each particle of the SPS.
  86985. * For an animated SPS, it is usually called within the render loop.
  86986. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86987. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86988. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86989. * @returns the SPS.
  86990. */
  86991. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86992. /**
  86993. * Disposes the SPS.
  86994. */
  86995. dispose(): void;
  86996. /**
  86997. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86998. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86999. * @returns the SPS.
  87000. */
  87001. refreshVisibleSize(): SolidParticleSystem;
  87002. /**
  87003. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  87004. * @param size the size (float) of the visibility box
  87005. * note : this doesn't lock the SPS mesh bounding box.
  87006. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87007. */
  87008. setVisibilityBox(size: number): void;
  87009. /**
  87010. * Gets whether the SPS as always visible or not
  87011. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87012. */
  87013. /**
  87014. * Sets the SPS as always visible or not
  87015. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87016. */
  87017. isAlwaysVisible: boolean;
  87018. /**
  87019. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87020. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87021. */
  87022. /**
  87023. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  87024. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  87025. */
  87026. isVisibilityBoxLocked: boolean;
  87027. /**
  87028. * Tells to `setParticles()` to compute the particle rotations or not.
  87029. * Default value : true. The SPS is faster when it's set to false.
  87030. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87031. */
  87032. /**
  87033. * Gets if `setParticles()` computes the particle rotations or not.
  87034. * Default value : true. The SPS is faster when it's set to false.
  87035. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  87036. */
  87037. computeParticleRotation: boolean;
  87038. /**
  87039. * Tells to `setParticles()` to compute the particle colors or not.
  87040. * Default value : true. The SPS is faster when it's set to false.
  87041. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87042. */
  87043. /**
  87044. * Gets if `setParticles()` computes the particle colors or not.
  87045. * Default value : true. The SPS is faster when it's set to false.
  87046. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  87047. */
  87048. computeParticleColor: boolean;
  87049. /**
  87050. * Gets if `setParticles()` computes the particle textures or not.
  87051. * Default value : true. The SPS is faster when it's set to false.
  87052. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  87053. */
  87054. computeParticleTexture: boolean;
  87055. /**
  87056. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  87057. * Default value : false. The SPS is faster when it's set to false.
  87058. * Note : the particle custom vertex positions aren't stored values.
  87059. */
  87060. /**
  87061. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  87062. * Default value : false. The SPS is faster when it's set to false.
  87063. * Note : the particle custom vertex positions aren't stored values.
  87064. */
  87065. computeParticleVertex: boolean;
  87066. /**
  87067. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  87068. */
  87069. /**
  87070. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  87071. */
  87072. computeBoundingBox: boolean;
  87073. /**
  87074. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  87075. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87076. * Default : `true`
  87077. */
  87078. /**
  87079. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  87080. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87081. * Default : `true`
  87082. */
  87083. depthSortParticles: boolean;
  87084. /**
  87085. * This function does nothing. It may be overwritten to set all the particle first values.
  87086. * The SPS doesn't call this function, you may have to call it by your own.
  87087. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87088. */
  87089. initParticles(): void;
  87090. /**
  87091. * This function does nothing. It may be overwritten to recycle a particle.
  87092. * The SPS doesn't call this function, you may have to call it by your own.
  87093. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87094. * @param particle The particle to recycle
  87095. * @returns the recycled particle
  87096. */
  87097. recycleParticle(particle: SolidParticle): SolidParticle;
  87098. /**
  87099. * Updates a particle : this function should be overwritten by the user.
  87100. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  87101. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87102. * @example : just set a particle position or velocity and recycle conditions
  87103. * @param particle The particle to update
  87104. * @returns the updated particle
  87105. */
  87106. updateParticle(particle: SolidParticle): SolidParticle;
  87107. /**
  87108. * Updates a vertex of a particle : it can be overwritten by the user.
  87109. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  87110. * @param particle the current particle
  87111. * @param vertex the current index of the current particle
  87112. * @param pt the index of the current vertex in the particle shape
  87113. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  87114. * @example : just set a vertex particle position
  87115. * @returns the updated vertex
  87116. */
  87117. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  87118. /**
  87119. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  87120. * This does nothing and may be overwritten by the user.
  87121. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87122. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87123. * @param update the boolean update value actually passed to setParticles()
  87124. */
  87125. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87126. /**
  87127. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  87128. * This will be passed three parameters.
  87129. * This does nothing and may be overwritten by the user.
  87130. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87131. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87132. * @param update the boolean update value actually passed to setParticles()
  87133. */
  87134. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87135. }
  87136. }
  87137. declare module BABYLON {
  87138. /**
  87139. * Represents one particle of a solid particle system.
  87140. */
  87141. export class SolidParticle {
  87142. /**
  87143. * particle global index
  87144. */
  87145. idx: number;
  87146. /**
  87147. * The color of the particle
  87148. */
  87149. color: Nullable<Color4>;
  87150. /**
  87151. * The world space position of the particle.
  87152. */
  87153. position: Vector3;
  87154. /**
  87155. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  87156. */
  87157. rotation: Vector3;
  87158. /**
  87159. * The world space rotation quaternion of the particle.
  87160. */
  87161. rotationQuaternion: Nullable<Quaternion>;
  87162. /**
  87163. * The scaling of the particle.
  87164. */
  87165. scaling: Vector3;
  87166. /**
  87167. * The uvs of the particle.
  87168. */
  87169. uvs: Vector4;
  87170. /**
  87171. * The current speed of the particle.
  87172. */
  87173. velocity: Vector3;
  87174. /**
  87175. * The pivot point in the particle local space.
  87176. */
  87177. pivot: Vector3;
  87178. /**
  87179. * Must the particle be translated from its pivot point in its local space ?
  87180. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  87181. * Default : false
  87182. */
  87183. translateFromPivot: boolean;
  87184. /**
  87185. * Is the particle active or not ?
  87186. */
  87187. alive: boolean;
  87188. /**
  87189. * Is the particle visible or not ?
  87190. */
  87191. isVisible: boolean;
  87192. /**
  87193. * Index of this particle in the global "positions" array (Internal use)
  87194. * @hidden
  87195. */
  87196. _pos: number;
  87197. /**
  87198. * @hidden Index of this particle in the global "indices" array (Internal use)
  87199. */
  87200. _ind: number;
  87201. /**
  87202. * @hidden ModelShape of this particle (Internal use)
  87203. */
  87204. _model: ModelShape;
  87205. /**
  87206. * ModelShape id of this particle
  87207. */
  87208. shapeId: number;
  87209. /**
  87210. * Index of the particle in its shape id (Internal use)
  87211. */
  87212. idxInShape: number;
  87213. /**
  87214. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  87215. */
  87216. _modelBoundingInfo: BoundingInfo;
  87217. /**
  87218. * @hidden Particle BoundingInfo object (Internal use)
  87219. */
  87220. _boundingInfo: BoundingInfo;
  87221. /**
  87222. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  87223. */
  87224. _sps: SolidParticleSystem;
  87225. /**
  87226. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  87227. */
  87228. _stillInvisible: boolean;
  87229. /**
  87230. * @hidden Last computed particle rotation matrix
  87231. */
  87232. _rotationMatrix: number[];
  87233. /**
  87234. * Parent particle Id, if any.
  87235. * Default null.
  87236. */
  87237. parentId: Nullable<number>;
  87238. /**
  87239. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  87240. * The possible values are :
  87241. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87242. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87243. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87244. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87245. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87246. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  87247. * */
  87248. cullingStrategy: number;
  87249. /**
  87250. * @hidden Internal global position in the SPS.
  87251. */
  87252. _globalPosition: Vector3;
  87253. /**
  87254. * Creates a Solid Particle object.
  87255. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  87256. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  87257. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  87258. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  87259. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  87260. * @param shapeId (integer) is the model shape identifier in the SPS.
  87261. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  87262. * @param sps defines the sps it is associated to
  87263. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  87264. */
  87265. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  87266. /**
  87267. * Legacy support, changed scale to scaling
  87268. */
  87269. /**
  87270. * Legacy support, changed scale to scaling
  87271. */
  87272. scale: Vector3;
  87273. /**
  87274. * Legacy support, changed quaternion to rotationQuaternion
  87275. */
  87276. /**
  87277. * Legacy support, changed quaternion to rotationQuaternion
  87278. */
  87279. quaternion: Nullable<Quaternion>;
  87280. /**
  87281. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  87282. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  87283. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  87284. * @returns true if it intersects
  87285. */
  87286. intersectsMesh(target: Mesh | SolidParticle): boolean;
  87287. /**
  87288. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  87289. * A particle is in the frustum if its bounding box intersects the frustum
  87290. * @param frustumPlanes defines the frustum to test
  87291. * @returns true if the particle is in the frustum planes
  87292. */
  87293. isInFrustum(frustumPlanes: Plane[]): boolean;
  87294. /**
  87295. * get the rotation matrix of the particle
  87296. * @hidden
  87297. */
  87298. getRotationMatrix(m: Matrix): void;
  87299. }
  87300. /**
  87301. * Represents the shape of the model used by one particle of a solid particle system.
  87302. * SPS internal tool, don't use it manually.
  87303. */
  87304. export class ModelShape {
  87305. /**
  87306. * The shape id
  87307. * @hidden
  87308. */
  87309. shapeID: number;
  87310. /**
  87311. * flat array of model positions (internal use)
  87312. * @hidden
  87313. */
  87314. _shape: Vector3[];
  87315. /**
  87316. * flat array of model UVs (internal use)
  87317. * @hidden
  87318. */
  87319. _shapeUV: number[];
  87320. /**
  87321. * length of the shape in the model indices array (internal use)
  87322. * @hidden
  87323. */
  87324. _indicesLength: number;
  87325. /**
  87326. * Custom position function (internal use)
  87327. * @hidden
  87328. */
  87329. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  87330. /**
  87331. * Custom vertex function (internal use)
  87332. * @hidden
  87333. */
  87334. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  87335. /**
  87336. * 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.
  87337. * SPS internal tool, don't use it manually.
  87338. * @hidden
  87339. */
  87340. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  87341. }
  87342. /**
  87343. * Represents a Depth Sorted Particle in the solid particle system.
  87344. */
  87345. export class DepthSortedParticle {
  87346. /**
  87347. * Index of the particle in the "indices" array
  87348. */
  87349. ind: number;
  87350. /**
  87351. * Length of the particle shape in the "indices" array
  87352. */
  87353. indicesLength: number;
  87354. /**
  87355. * Squared distance from the particle to the camera
  87356. */
  87357. sqDistance: number;
  87358. }
  87359. }
  87360. declare module BABYLON {
  87361. /**
  87362. * @hidden
  87363. */
  87364. export class _MeshCollisionData {
  87365. _checkCollisions: boolean;
  87366. _collisionMask: number;
  87367. _collisionGroup: number;
  87368. _collider: Nullable<Collider>;
  87369. _oldPositionForCollisions: Vector3;
  87370. _diffPositionForCollisions: Vector3;
  87371. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87372. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87373. }
  87374. }
  87375. declare module BABYLON {
  87376. /** @hidden */
  87377. class _FacetDataStorage {
  87378. facetPositions: Vector3[];
  87379. facetNormals: Vector3[];
  87380. facetPartitioning: number[][];
  87381. facetNb: number;
  87382. partitioningSubdivisions: number;
  87383. partitioningBBoxRatio: number;
  87384. facetDataEnabled: boolean;
  87385. facetParameters: any;
  87386. bbSize: Vector3;
  87387. subDiv: {
  87388. max: number;
  87389. X: number;
  87390. Y: number;
  87391. Z: number;
  87392. };
  87393. facetDepthSort: boolean;
  87394. facetDepthSortEnabled: boolean;
  87395. depthSortedIndices: IndicesArray;
  87396. depthSortedFacets: {
  87397. ind: number;
  87398. sqDistance: number;
  87399. }[];
  87400. facetDepthSortFunction: (f1: {
  87401. ind: number;
  87402. sqDistance: number;
  87403. }, f2: {
  87404. ind: number;
  87405. sqDistance: number;
  87406. }) => number;
  87407. facetDepthSortFrom: Vector3;
  87408. facetDepthSortOrigin: Vector3;
  87409. invertedMatrix: Matrix;
  87410. }
  87411. /**
  87412. * @hidden
  87413. **/
  87414. class _InternalAbstractMeshDataInfo {
  87415. _hasVertexAlpha: boolean;
  87416. _useVertexColors: boolean;
  87417. _numBoneInfluencers: number;
  87418. _applyFog: boolean;
  87419. _receiveShadows: boolean;
  87420. _facetData: _FacetDataStorage;
  87421. _visibility: number;
  87422. _skeleton: Nullable<Skeleton>;
  87423. _layerMask: number;
  87424. _computeBonesUsingShaders: boolean;
  87425. _isActive: boolean;
  87426. _onlyForInstances: boolean;
  87427. _isActiveIntermediate: boolean;
  87428. _onlyForInstancesIntermediate: boolean;
  87429. }
  87430. /**
  87431. * Class used to store all common mesh properties
  87432. */
  87433. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87434. /** No occlusion */
  87435. static OCCLUSION_TYPE_NONE: number;
  87436. /** Occlusion set to optimisitic */
  87437. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87438. /** Occlusion set to strict */
  87439. static OCCLUSION_TYPE_STRICT: number;
  87440. /** Use an accurante occlusion algorithm */
  87441. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87442. /** Use a conservative occlusion algorithm */
  87443. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87444. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87445. * Test order :
  87446. * Is the bounding sphere outside the frustum ?
  87447. * If not, are the bounding box vertices outside the frustum ?
  87448. * It not, then the cullable object is in the frustum.
  87449. */
  87450. static readonly CULLINGSTRATEGY_STANDARD: number;
  87451. /** Culling strategy : Bounding Sphere Only.
  87452. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87453. * It's also less accurate than the standard because some not visible objects can still be selected.
  87454. * Test : is the bounding sphere outside the frustum ?
  87455. * If not, then the cullable object is in the frustum.
  87456. */
  87457. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87458. /** Culling strategy : Optimistic Inclusion.
  87459. * This in an inclusion test first, then the standard exclusion test.
  87460. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87461. * 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.
  87462. * Anyway, it's as accurate as the standard strategy.
  87463. * Test :
  87464. * Is the cullable object bounding sphere center in the frustum ?
  87465. * If not, apply the default culling strategy.
  87466. */
  87467. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87468. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87469. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87470. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87471. * 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.
  87472. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87473. * Test :
  87474. * Is the cullable object bounding sphere center in the frustum ?
  87475. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87476. */
  87477. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87478. /**
  87479. * No billboard
  87480. */
  87481. static readonly BILLBOARDMODE_NONE: number;
  87482. /** Billboard on X axis */
  87483. static readonly BILLBOARDMODE_X: number;
  87484. /** Billboard on Y axis */
  87485. static readonly BILLBOARDMODE_Y: number;
  87486. /** Billboard on Z axis */
  87487. static readonly BILLBOARDMODE_Z: number;
  87488. /** Billboard on all axes */
  87489. static readonly BILLBOARDMODE_ALL: number;
  87490. /** @hidden */
  87491. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87492. /**
  87493. * The culling strategy to use to check whether the mesh must be rendered or not.
  87494. * This value can be changed at any time and will be used on the next render mesh selection.
  87495. * The possible values are :
  87496. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87497. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87498. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87499. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87500. * Please read each static variable documentation to get details about the culling process.
  87501. * */
  87502. cullingStrategy: number;
  87503. /**
  87504. * Gets the number of facets in the mesh
  87505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87506. */
  87507. readonly facetNb: number;
  87508. /**
  87509. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87511. */
  87512. partitioningSubdivisions: number;
  87513. /**
  87514. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87515. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87517. */
  87518. partitioningBBoxRatio: number;
  87519. /**
  87520. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87521. * Works only for updatable meshes.
  87522. * Doesn't work with multi-materials
  87523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87524. */
  87525. mustDepthSortFacets: boolean;
  87526. /**
  87527. * The location (Vector3) where the facet depth sort must be computed from.
  87528. * By default, the active camera position.
  87529. * Used only when facet depth sort is enabled
  87530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87531. */
  87532. facetDepthSortFrom: Vector3;
  87533. /**
  87534. * gets a boolean indicating if facetData is enabled
  87535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87536. */
  87537. readonly isFacetDataEnabled: boolean;
  87538. /** @hidden */
  87539. _updateNonUniformScalingState(value: boolean): boolean;
  87540. /**
  87541. * An event triggered when this mesh collides with another one
  87542. */
  87543. onCollideObservable: Observable<AbstractMesh>;
  87544. /** Set a function to call when this mesh collides with another one */
  87545. onCollide: () => void;
  87546. /**
  87547. * An event triggered when the collision's position changes
  87548. */
  87549. onCollisionPositionChangeObservable: Observable<Vector3>;
  87550. /** Set a function to call when the collision's position changes */
  87551. onCollisionPositionChange: () => void;
  87552. /**
  87553. * An event triggered when material is changed
  87554. */
  87555. onMaterialChangedObservable: Observable<AbstractMesh>;
  87556. /**
  87557. * Gets or sets the orientation for POV movement & rotation
  87558. */
  87559. definedFacingForward: boolean;
  87560. /** @hidden */
  87561. _occlusionQuery: Nullable<WebGLQuery>;
  87562. /** @hidden */
  87563. _renderingGroup: Nullable<RenderingGroup>;
  87564. /**
  87565. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87566. */
  87567. /**
  87568. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87569. */
  87570. visibility: number;
  87571. /** Gets or sets the alpha index used to sort transparent meshes
  87572. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87573. */
  87574. alphaIndex: number;
  87575. /**
  87576. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87577. */
  87578. isVisible: boolean;
  87579. /**
  87580. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87581. */
  87582. isPickable: boolean;
  87583. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87584. showSubMeshesBoundingBox: boolean;
  87585. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87586. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87587. */
  87588. isBlocker: boolean;
  87589. /**
  87590. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87591. */
  87592. enablePointerMoveEvents: boolean;
  87593. /**
  87594. * Specifies the rendering group id for this mesh (0 by default)
  87595. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87596. */
  87597. renderingGroupId: number;
  87598. private _material;
  87599. /** Gets or sets current material */
  87600. material: Nullable<Material>;
  87601. /**
  87602. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87603. * @see http://doc.babylonjs.com/babylon101/shadows
  87604. */
  87605. receiveShadows: boolean;
  87606. /** Defines color to use when rendering outline */
  87607. outlineColor: Color3;
  87608. /** Define width to use when rendering outline */
  87609. outlineWidth: number;
  87610. /** Defines color to use when rendering overlay */
  87611. overlayColor: Color3;
  87612. /** Defines alpha to use when rendering overlay */
  87613. overlayAlpha: number;
  87614. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87615. hasVertexAlpha: boolean;
  87616. /** 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) */
  87617. useVertexColors: boolean;
  87618. /**
  87619. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87620. */
  87621. computeBonesUsingShaders: boolean;
  87622. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87623. numBoneInfluencers: number;
  87624. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87625. applyFog: boolean;
  87626. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87627. useOctreeForRenderingSelection: boolean;
  87628. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87629. useOctreeForPicking: boolean;
  87630. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87631. useOctreeForCollisions: boolean;
  87632. /**
  87633. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87634. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87635. */
  87636. layerMask: number;
  87637. /**
  87638. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87639. */
  87640. alwaysSelectAsActiveMesh: boolean;
  87641. /**
  87642. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87643. */
  87644. doNotSyncBoundingInfo: boolean;
  87645. /**
  87646. * Gets or sets the current action manager
  87647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87648. */
  87649. actionManager: Nullable<AbstractActionManager>;
  87650. private _meshCollisionData;
  87651. /**
  87652. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87653. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87654. */
  87655. ellipsoid: Vector3;
  87656. /**
  87657. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87658. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87659. */
  87660. ellipsoidOffset: Vector3;
  87661. /**
  87662. * Gets or sets a collision mask used to mask collisions (default is -1).
  87663. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87664. */
  87665. collisionMask: number;
  87666. /**
  87667. * Gets or sets the current collision group mask (-1 by default).
  87668. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87669. */
  87670. collisionGroup: number;
  87671. /**
  87672. * Defines edge width used when edgesRenderer is enabled
  87673. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87674. */
  87675. edgesWidth: number;
  87676. /**
  87677. * Defines edge color used when edgesRenderer is enabled
  87678. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87679. */
  87680. edgesColor: Color4;
  87681. /** @hidden */
  87682. _edgesRenderer: Nullable<IEdgesRenderer>;
  87683. /** @hidden */
  87684. _masterMesh: Nullable<AbstractMesh>;
  87685. /** @hidden */
  87686. _boundingInfo: Nullable<BoundingInfo>;
  87687. /** @hidden */
  87688. _renderId: number;
  87689. /**
  87690. * Gets or sets the list of subMeshes
  87691. * @see http://doc.babylonjs.com/how_to/multi_materials
  87692. */
  87693. subMeshes: SubMesh[];
  87694. /** @hidden */
  87695. _intersectionsInProgress: AbstractMesh[];
  87696. /** @hidden */
  87697. _unIndexed: boolean;
  87698. /** @hidden */
  87699. _lightSources: Light[];
  87700. /** Gets the list of lights affecting that mesh */
  87701. readonly lightSources: Light[];
  87702. /** @hidden */
  87703. readonly _positions: Nullable<Vector3[]>;
  87704. /** @hidden */
  87705. _waitingData: {
  87706. lods: Nullable<any>;
  87707. actions: Nullable<any>;
  87708. freezeWorldMatrix: Nullable<boolean>;
  87709. };
  87710. /** @hidden */
  87711. _bonesTransformMatrices: Nullable<Float32Array>;
  87712. /**
  87713. * Gets or sets a skeleton to apply skining transformations
  87714. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87715. */
  87716. skeleton: Nullable<Skeleton>;
  87717. /**
  87718. * An event triggered when the mesh is rebuilt.
  87719. */
  87720. onRebuildObservable: Observable<AbstractMesh>;
  87721. /**
  87722. * Creates a new AbstractMesh
  87723. * @param name defines the name of the mesh
  87724. * @param scene defines the hosting scene
  87725. */
  87726. constructor(name: string, scene?: Nullable<Scene>);
  87727. /**
  87728. * Returns the string "AbstractMesh"
  87729. * @returns "AbstractMesh"
  87730. */
  87731. getClassName(): string;
  87732. /**
  87733. * Gets a string representation of the current mesh
  87734. * @param fullDetails defines a boolean indicating if full details must be included
  87735. * @returns a string representation of the current mesh
  87736. */
  87737. toString(fullDetails?: boolean): string;
  87738. /**
  87739. * @hidden
  87740. */
  87741. protected _getEffectiveParent(): Nullable<Node>;
  87742. /** @hidden */
  87743. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87744. /** @hidden */
  87745. _rebuild(): void;
  87746. /** @hidden */
  87747. _resyncLightSources(): void;
  87748. /** @hidden */
  87749. _resyncLighSource(light: Light): void;
  87750. /** @hidden */
  87751. _unBindEffect(): void;
  87752. /** @hidden */
  87753. _removeLightSource(light: Light): void;
  87754. private _markSubMeshesAsDirty;
  87755. /** @hidden */
  87756. _markSubMeshesAsLightDirty(): void;
  87757. /** @hidden */
  87758. _markSubMeshesAsAttributesDirty(): void;
  87759. /** @hidden */
  87760. _markSubMeshesAsMiscDirty(): void;
  87761. /**
  87762. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87763. */
  87764. scaling: Vector3;
  87765. /**
  87766. * Returns true if the mesh is blocked. Implemented by child classes
  87767. */
  87768. readonly isBlocked: boolean;
  87769. /**
  87770. * Returns the mesh itself by default. Implemented by child classes
  87771. * @param camera defines the camera to use to pick the right LOD level
  87772. * @returns the currentAbstractMesh
  87773. */
  87774. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87775. /**
  87776. * Returns 0 by default. Implemented by child classes
  87777. * @returns an integer
  87778. */
  87779. getTotalVertices(): number;
  87780. /**
  87781. * Returns a positive integer : the total number of indices in this mesh geometry.
  87782. * @returns the numner of indices or zero if the mesh has no geometry.
  87783. */
  87784. getTotalIndices(): number;
  87785. /**
  87786. * Returns null by default. Implemented by child classes
  87787. * @returns null
  87788. */
  87789. getIndices(): Nullable<IndicesArray>;
  87790. /**
  87791. * Returns the array of the requested vertex data kind. Implemented by child classes
  87792. * @param kind defines the vertex data kind to use
  87793. * @returns null
  87794. */
  87795. getVerticesData(kind: string): Nullable<FloatArray>;
  87796. /**
  87797. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87798. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87799. * Note that a new underlying VertexBuffer object is created each call.
  87800. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87801. * @param kind defines vertex data kind:
  87802. * * VertexBuffer.PositionKind
  87803. * * VertexBuffer.UVKind
  87804. * * VertexBuffer.UV2Kind
  87805. * * VertexBuffer.UV3Kind
  87806. * * VertexBuffer.UV4Kind
  87807. * * VertexBuffer.UV5Kind
  87808. * * VertexBuffer.UV6Kind
  87809. * * VertexBuffer.ColorKind
  87810. * * VertexBuffer.MatricesIndicesKind
  87811. * * VertexBuffer.MatricesIndicesExtraKind
  87812. * * VertexBuffer.MatricesWeightsKind
  87813. * * VertexBuffer.MatricesWeightsExtraKind
  87814. * @param data defines the data source
  87815. * @param updatable defines if the data must be flagged as updatable (or static)
  87816. * @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
  87817. * @returns the current mesh
  87818. */
  87819. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87820. /**
  87821. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87822. * If the mesh has no geometry, it is simply returned as it is.
  87823. * @param kind defines vertex data kind:
  87824. * * VertexBuffer.PositionKind
  87825. * * VertexBuffer.UVKind
  87826. * * VertexBuffer.UV2Kind
  87827. * * VertexBuffer.UV3Kind
  87828. * * VertexBuffer.UV4Kind
  87829. * * VertexBuffer.UV5Kind
  87830. * * VertexBuffer.UV6Kind
  87831. * * VertexBuffer.ColorKind
  87832. * * VertexBuffer.MatricesIndicesKind
  87833. * * VertexBuffer.MatricesIndicesExtraKind
  87834. * * VertexBuffer.MatricesWeightsKind
  87835. * * VertexBuffer.MatricesWeightsExtraKind
  87836. * @param data defines the data source
  87837. * @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
  87838. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87839. * @returns the current mesh
  87840. */
  87841. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87842. /**
  87843. * Sets the mesh indices,
  87844. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87845. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87846. * @param totalVertices Defines the total number of vertices
  87847. * @returns the current mesh
  87848. */
  87849. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87850. /**
  87851. * Gets a boolean indicating if specific vertex data is present
  87852. * @param kind defines the vertex data kind to use
  87853. * @returns true is data kind is present
  87854. */
  87855. isVerticesDataPresent(kind: string): boolean;
  87856. /**
  87857. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  87858. * @returns a BoundingInfo
  87859. */
  87860. getBoundingInfo(): BoundingInfo;
  87861. /**
  87862. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87863. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87864. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87865. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87866. * @returns the current mesh
  87867. */
  87868. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87869. /**
  87870. * Overwrite the current bounding info
  87871. * @param boundingInfo defines the new bounding info
  87872. * @returns the current mesh
  87873. */
  87874. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87875. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87876. readonly useBones: boolean;
  87877. /** @hidden */
  87878. _preActivate(): void;
  87879. /** @hidden */
  87880. _preActivateForIntermediateRendering(renderId: number): void;
  87881. /** @hidden */
  87882. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87883. /** @hidden */
  87884. _postActivate(): void;
  87885. /** @hidden */
  87886. _freeze(): void;
  87887. /** @hidden */
  87888. _unFreeze(): void;
  87889. /**
  87890. * Gets the current world matrix
  87891. * @returns a Matrix
  87892. */
  87893. getWorldMatrix(): Matrix;
  87894. /** @hidden */
  87895. _getWorldMatrixDeterminant(): number;
  87896. /**
  87897. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87898. */
  87899. readonly isAnInstance: boolean;
  87900. /**
  87901. * Perform relative position change from the point of view of behind the front of the mesh.
  87902. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87903. * Supports definition of mesh facing forward or backward
  87904. * @param amountRight defines the distance on the right axis
  87905. * @param amountUp defines the distance on the up axis
  87906. * @param amountForward defines the distance on the forward axis
  87907. * @returns the current mesh
  87908. */
  87909. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87910. /**
  87911. * Calculate relative position change from the point of view of behind the front of the mesh.
  87912. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87913. * Supports definition of mesh facing forward or backward
  87914. * @param amountRight defines the distance on the right axis
  87915. * @param amountUp defines the distance on the up axis
  87916. * @param amountForward defines the distance on the forward axis
  87917. * @returns the new displacement vector
  87918. */
  87919. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87920. /**
  87921. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87922. * Supports definition of mesh facing forward or backward
  87923. * @param flipBack defines the flip
  87924. * @param twirlClockwise defines the twirl
  87925. * @param tiltRight defines the tilt
  87926. * @returns the current mesh
  87927. */
  87928. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87929. /**
  87930. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87931. * Supports definition of mesh facing forward or backward.
  87932. * @param flipBack defines the flip
  87933. * @param twirlClockwise defines the twirl
  87934. * @param tiltRight defines the tilt
  87935. * @returns the new rotation vector
  87936. */
  87937. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87938. /**
  87939. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87940. * This means the mesh underlying bounding box and sphere are recomputed.
  87941. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87942. * @returns the current mesh
  87943. */
  87944. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87945. /** @hidden */
  87946. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87947. /** @hidden */
  87948. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87949. /** @hidden */
  87950. _updateBoundingInfo(): AbstractMesh;
  87951. /** @hidden */
  87952. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87953. /** @hidden */
  87954. protected _afterComputeWorldMatrix(): void;
  87955. /** @hidden */
  87956. readonly _effectiveMesh: AbstractMesh;
  87957. /**
  87958. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87959. * A mesh is in the frustum if its bounding box intersects the frustum
  87960. * @param frustumPlanes defines the frustum to test
  87961. * @returns true if the mesh is in the frustum planes
  87962. */
  87963. isInFrustum(frustumPlanes: Plane[]): boolean;
  87964. /**
  87965. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87966. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87967. * @param frustumPlanes defines the frustum to test
  87968. * @returns true if the mesh is completely in the frustum planes
  87969. */
  87970. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87971. /**
  87972. * True if the mesh intersects another mesh or a SolidParticle object
  87973. * @param mesh defines a target mesh or SolidParticle to test
  87974. * @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)
  87975. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87976. * @returns true if there is an intersection
  87977. */
  87978. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87979. /**
  87980. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87981. * @param point defines the point to test
  87982. * @returns true if there is an intersection
  87983. */
  87984. intersectsPoint(point: Vector3): boolean;
  87985. /**
  87986. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87987. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87988. */
  87989. checkCollisions: boolean;
  87990. /**
  87991. * Gets Collider object used to compute collisions (not physics)
  87992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87993. */
  87994. readonly collider: Nullable<Collider>;
  87995. /**
  87996. * Move the mesh using collision engine
  87997. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87998. * @param displacement defines the requested displacement vector
  87999. * @returns the current mesh
  88000. */
  88001. moveWithCollisions(displacement: Vector3): AbstractMesh;
  88002. private _onCollisionPositionChange;
  88003. /** @hidden */
  88004. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  88005. /** @hidden */
  88006. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  88007. /** @hidden */
  88008. _checkCollision(collider: Collider): AbstractMesh;
  88009. /** @hidden */
  88010. _generatePointsArray(): boolean;
  88011. /**
  88012. * Checks if the passed Ray intersects with the mesh
  88013. * @param ray defines the ray to use
  88014. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  88015. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88016. * @returns the picking info
  88017. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88018. */
  88019. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  88020. /**
  88021. * Clones the current mesh
  88022. * @param name defines the mesh name
  88023. * @param newParent defines the new mesh parent
  88024. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  88025. * @returns the new mesh
  88026. */
  88027. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88028. /**
  88029. * Disposes all the submeshes of the current meshnp
  88030. * @returns the current mesh
  88031. */
  88032. releaseSubMeshes(): AbstractMesh;
  88033. /**
  88034. * Releases resources associated with this abstract mesh.
  88035. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88036. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88037. */
  88038. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88039. /**
  88040. * Adds the passed mesh as a child to the current mesh
  88041. * @param mesh defines the child mesh
  88042. * @returns the current mesh
  88043. */
  88044. addChild(mesh: AbstractMesh): AbstractMesh;
  88045. /**
  88046. * Removes the passed mesh from the current mesh children list
  88047. * @param mesh defines the child mesh
  88048. * @returns the current mesh
  88049. */
  88050. removeChild(mesh: AbstractMesh): AbstractMesh;
  88051. /** @hidden */
  88052. private _initFacetData;
  88053. /**
  88054. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  88055. * This method can be called within the render loop.
  88056. * 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
  88057. * @returns the current mesh
  88058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88059. */
  88060. updateFacetData(): AbstractMesh;
  88061. /**
  88062. * Returns the facetLocalNormals array.
  88063. * The normals are expressed in the mesh local spac
  88064. * @returns an array of Vector3
  88065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88066. */
  88067. getFacetLocalNormals(): Vector3[];
  88068. /**
  88069. * Returns the facetLocalPositions array.
  88070. * The facet positions are expressed in the mesh local space
  88071. * @returns an array of Vector3
  88072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88073. */
  88074. getFacetLocalPositions(): Vector3[];
  88075. /**
  88076. * Returns the facetLocalPartioning array
  88077. * @returns an array of array of numbers
  88078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88079. */
  88080. getFacetLocalPartitioning(): number[][];
  88081. /**
  88082. * Returns the i-th facet position in the world system.
  88083. * This method allocates a new Vector3 per call
  88084. * @param i defines the facet index
  88085. * @returns a new Vector3
  88086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88087. */
  88088. getFacetPosition(i: number): Vector3;
  88089. /**
  88090. * Sets the reference Vector3 with the i-th facet position in the world system
  88091. * @param i defines the facet index
  88092. * @param ref defines the target vector
  88093. * @returns the current mesh
  88094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88095. */
  88096. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  88097. /**
  88098. * Returns the i-th facet normal in the world system.
  88099. * This method allocates a new Vector3 per call
  88100. * @param i defines the facet index
  88101. * @returns a new Vector3
  88102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88103. */
  88104. getFacetNormal(i: number): Vector3;
  88105. /**
  88106. * Sets the reference Vector3 with the i-th facet normal in the world system
  88107. * @param i defines the facet index
  88108. * @param ref defines the target vector
  88109. * @returns the current mesh
  88110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88111. */
  88112. getFacetNormalToRef(i: number, ref: Vector3): this;
  88113. /**
  88114. * 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)
  88115. * @param x defines x coordinate
  88116. * @param y defines y coordinate
  88117. * @param z defines z coordinate
  88118. * @returns the array of facet indexes
  88119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88120. */
  88121. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  88122. /**
  88123. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  88124. * @param projected sets as the (x,y,z) world projection on the facet
  88125. * @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
  88126. * @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
  88127. * @param x defines x coordinate
  88128. * @param y defines y coordinate
  88129. * @param z defines z coordinate
  88130. * @returns the face index if found (or null instead)
  88131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88132. */
  88133. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88134. /**
  88135. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  88136. * @param projected sets as the (x,y,z) local projection on the facet
  88137. * @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
  88138. * @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
  88139. * @param x defines x coordinate
  88140. * @param y defines y coordinate
  88141. * @param z defines z coordinate
  88142. * @returns the face index if found (or null instead)
  88143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88144. */
  88145. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88146. /**
  88147. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  88148. * @returns the parameters
  88149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88150. */
  88151. getFacetDataParameters(): any;
  88152. /**
  88153. * Disables the feature FacetData and frees the related memory
  88154. * @returns the current mesh
  88155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88156. */
  88157. disableFacetData(): AbstractMesh;
  88158. /**
  88159. * Updates the AbstractMesh indices array
  88160. * @param indices defines the data source
  88161. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88162. * @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)
  88163. * @returns the current mesh
  88164. */
  88165. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88166. /**
  88167. * Creates new normals data for the mesh
  88168. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  88169. * @returns the current mesh
  88170. */
  88171. createNormals(updatable: boolean): AbstractMesh;
  88172. /**
  88173. * Align the mesh with a normal
  88174. * @param normal defines the normal to use
  88175. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  88176. * @returns the current mesh
  88177. */
  88178. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  88179. /** @hidden */
  88180. _checkOcclusionQuery(): boolean;
  88181. /**
  88182. * Disables the mesh edge rendering mode
  88183. * @returns the currentAbstractMesh
  88184. */
  88185. disableEdgesRendering(): AbstractMesh;
  88186. /**
  88187. * Enables the edge rendering mode on the mesh.
  88188. * This mode makes the mesh edges visible
  88189. * @param epsilon defines the maximal distance between two angles to detect a face
  88190. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88191. * @returns the currentAbstractMesh
  88192. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88193. */
  88194. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88195. }
  88196. }
  88197. declare module BABYLON {
  88198. /**
  88199. * Interface used to define ActionEvent
  88200. */
  88201. export interface IActionEvent {
  88202. /** The mesh or sprite that triggered the action */
  88203. source: any;
  88204. /** The X mouse cursor position at the time of the event */
  88205. pointerX: number;
  88206. /** The Y mouse cursor position at the time of the event */
  88207. pointerY: number;
  88208. /** The mesh that is currently pointed at (can be null) */
  88209. meshUnderPointer: Nullable<AbstractMesh>;
  88210. /** the original (browser) event that triggered the ActionEvent */
  88211. sourceEvent?: any;
  88212. /** additional data for the event */
  88213. additionalData?: any;
  88214. }
  88215. /**
  88216. * ActionEvent is the event being sent when an action is triggered.
  88217. */
  88218. export class ActionEvent implements IActionEvent {
  88219. /** The mesh or sprite that triggered the action */
  88220. source: any;
  88221. /** The X mouse cursor position at the time of the event */
  88222. pointerX: number;
  88223. /** The Y mouse cursor position at the time of the event */
  88224. pointerY: number;
  88225. /** The mesh that is currently pointed at (can be null) */
  88226. meshUnderPointer: Nullable<AbstractMesh>;
  88227. /** the original (browser) event that triggered the ActionEvent */
  88228. sourceEvent?: any;
  88229. /** additional data for the event */
  88230. additionalData?: any;
  88231. /**
  88232. * Creates a new ActionEvent
  88233. * @param source The mesh or sprite that triggered the action
  88234. * @param pointerX The X mouse cursor position at the time of the event
  88235. * @param pointerY The Y mouse cursor position at the time of the event
  88236. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  88237. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  88238. * @param additionalData additional data for the event
  88239. */
  88240. constructor(
  88241. /** The mesh or sprite that triggered the action */
  88242. source: any,
  88243. /** The X mouse cursor position at the time of the event */
  88244. pointerX: number,
  88245. /** The Y mouse cursor position at the time of the event */
  88246. pointerY: number,
  88247. /** The mesh that is currently pointed at (can be null) */
  88248. meshUnderPointer: Nullable<AbstractMesh>,
  88249. /** the original (browser) event that triggered the ActionEvent */
  88250. sourceEvent?: any,
  88251. /** additional data for the event */
  88252. additionalData?: any);
  88253. /**
  88254. * Helper function to auto-create an ActionEvent from a source mesh.
  88255. * @param source The source mesh that triggered the event
  88256. * @param evt The original (browser) event
  88257. * @param additionalData additional data for the event
  88258. * @returns the new ActionEvent
  88259. */
  88260. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  88261. /**
  88262. * Helper function to auto-create an ActionEvent from a source sprite
  88263. * @param source The source sprite that triggered the event
  88264. * @param scene Scene associated with the sprite
  88265. * @param evt The original (browser) event
  88266. * @param additionalData additional data for the event
  88267. * @returns the new ActionEvent
  88268. */
  88269. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  88270. /**
  88271. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  88272. * @param scene the scene where the event occurred
  88273. * @param evt The original (browser) event
  88274. * @returns the new ActionEvent
  88275. */
  88276. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  88277. /**
  88278. * Helper function to auto-create an ActionEvent from a primitive
  88279. * @param prim defines the target primitive
  88280. * @param pointerPos defines the pointer position
  88281. * @param evt The original (browser) event
  88282. * @param additionalData additional data for the event
  88283. * @returns the new ActionEvent
  88284. */
  88285. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  88286. }
  88287. }
  88288. declare module BABYLON {
  88289. /**
  88290. * Abstract class used to decouple action Manager from scene and meshes.
  88291. * Do not instantiate.
  88292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88293. */
  88294. export abstract class AbstractActionManager implements IDisposable {
  88295. /** Gets the list of active triggers */
  88296. static Triggers: {
  88297. [key: string]: number;
  88298. };
  88299. /** Gets the cursor to use when hovering items */
  88300. hoverCursor: string;
  88301. /** Gets the list of actions */
  88302. actions: IAction[];
  88303. /**
  88304. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  88305. */
  88306. isRecursive: boolean;
  88307. /**
  88308. * Releases all associated resources
  88309. */
  88310. abstract dispose(): void;
  88311. /**
  88312. * Does this action manager has pointer triggers
  88313. */
  88314. abstract readonly hasPointerTriggers: boolean;
  88315. /**
  88316. * Does this action manager has pick triggers
  88317. */
  88318. abstract readonly hasPickTriggers: boolean;
  88319. /**
  88320. * Process a specific trigger
  88321. * @param trigger defines the trigger to process
  88322. * @param evt defines the event details to be processed
  88323. */
  88324. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  88325. /**
  88326. * Does this action manager handles actions of any of the given triggers
  88327. * @param triggers defines the triggers to be tested
  88328. * @return a boolean indicating whether one (or more) of the triggers is handled
  88329. */
  88330. abstract hasSpecificTriggers(triggers: number[]): boolean;
  88331. /**
  88332. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88333. * speed.
  88334. * @param triggerA defines the trigger to be tested
  88335. * @param triggerB defines the trigger to be tested
  88336. * @return a boolean indicating whether one (or more) of the triggers is handled
  88337. */
  88338. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88339. /**
  88340. * Does this action manager handles actions of a given trigger
  88341. * @param trigger defines the trigger to be tested
  88342. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88343. * @return whether the trigger is handled
  88344. */
  88345. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88346. /**
  88347. * Serialize this manager to a JSON object
  88348. * @param name defines the property name to store this manager
  88349. * @returns a JSON representation of this manager
  88350. */
  88351. abstract serialize(name: string): any;
  88352. /**
  88353. * Registers an action to this action manager
  88354. * @param action defines the action to be registered
  88355. * @return the action amended (prepared) after registration
  88356. */
  88357. abstract registerAction(action: IAction): Nullable<IAction>;
  88358. /**
  88359. * Unregisters an action to this action manager
  88360. * @param action defines the action to be unregistered
  88361. * @return a boolean indicating whether the action has been unregistered
  88362. */
  88363. abstract unregisterAction(action: IAction): Boolean;
  88364. /**
  88365. * Does exist one action manager with at least one trigger
  88366. **/
  88367. static readonly HasTriggers: boolean;
  88368. /**
  88369. * Does exist one action manager with at least one pick trigger
  88370. **/
  88371. static readonly HasPickTriggers: boolean;
  88372. /**
  88373. * Does exist one action manager that handles actions of a given trigger
  88374. * @param trigger defines the trigger to be tested
  88375. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88376. **/
  88377. static HasSpecificTrigger(trigger: number): boolean;
  88378. }
  88379. }
  88380. declare module BABYLON {
  88381. /**
  88382. * Defines how a node can be built from a string name.
  88383. */
  88384. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88385. /**
  88386. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88387. */
  88388. export class Node implements IBehaviorAware<Node> {
  88389. /** @hidden */
  88390. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88391. private static _NodeConstructors;
  88392. /**
  88393. * Add a new node constructor
  88394. * @param type defines the type name of the node to construct
  88395. * @param constructorFunc defines the constructor function
  88396. */
  88397. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88398. /**
  88399. * Returns a node constructor based on type name
  88400. * @param type defines the type name
  88401. * @param name defines the new node name
  88402. * @param scene defines the hosting scene
  88403. * @param options defines optional options to transmit to constructors
  88404. * @returns the new constructor or null
  88405. */
  88406. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88407. /**
  88408. * Gets or sets the name of the node
  88409. */
  88410. name: string;
  88411. /**
  88412. * Gets or sets the id of the node
  88413. */
  88414. id: string;
  88415. /**
  88416. * Gets or sets the unique id of the node
  88417. */
  88418. uniqueId: number;
  88419. /**
  88420. * Gets or sets a string used to store user defined state for the node
  88421. */
  88422. state: string;
  88423. /**
  88424. * Gets or sets an object used to store user defined information for the node
  88425. */
  88426. metadata: any;
  88427. /**
  88428. * For internal use only. Please do not use.
  88429. */
  88430. reservedDataStore: any;
  88431. /**
  88432. * List of inspectable custom properties (used by the Inspector)
  88433. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88434. */
  88435. inspectableCustomProperties: IInspectable[];
  88436. /**
  88437. * Gets or sets a boolean used to define if the node must be serialized
  88438. */
  88439. doNotSerialize: boolean;
  88440. /** @hidden */
  88441. _isDisposed: boolean;
  88442. /**
  88443. * Gets a list of Animations associated with the node
  88444. */
  88445. animations: Animation[];
  88446. protected _ranges: {
  88447. [name: string]: Nullable<AnimationRange>;
  88448. };
  88449. /**
  88450. * Callback raised when the node is ready to be used
  88451. */
  88452. onReady: Nullable<(node: Node) => void>;
  88453. private _isEnabled;
  88454. private _isParentEnabled;
  88455. private _isReady;
  88456. /** @hidden */
  88457. _currentRenderId: number;
  88458. private _parentUpdateId;
  88459. /** @hidden */
  88460. _childUpdateId: number;
  88461. /** @hidden */
  88462. _waitingParentId: Nullable<string>;
  88463. /** @hidden */
  88464. _scene: Scene;
  88465. /** @hidden */
  88466. _cache: any;
  88467. private _parentNode;
  88468. private _children;
  88469. /** @hidden */
  88470. _worldMatrix: Matrix;
  88471. /** @hidden */
  88472. _worldMatrixDeterminant: number;
  88473. /** @hidden */
  88474. _worldMatrixDeterminantIsDirty: boolean;
  88475. /** @hidden */
  88476. private _sceneRootNodesIndex;
  88477. /**
  88478. * Gets a boolean indicating if the node has been disposed
  88479. * @returns true if the node was disposed
  88480. */
  88481. isDisposed(): boolean;
  88482. /**
  88483. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88484. * @see https://doc.babylonjs.com/how_to/parenting
  88485. */
  88486. parent: Nullable<Node>;
  88487. private addToSceneRootNodes;
  88488. private removeFromSceneRootNodes;
  88489. private _animationPropertiesOverride;
  88490. /**
  88491. * Gets or sets the animation properties override
  88492. */
  88493. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88494. /**
  88495. * Gets a string idenfifying the name of the class
  88496. * @returns "Node" string
  88497. */
  88498. getClassName(): string;
  88499. /** @hidden */
  88500. readonly _isNode: boolean;
  88501. /**
  88502. * An event triggered when the mesh is disposed
  88503. */
  88504. onDisposeObservable: Observable<Node>;
  88505. private _onDisposeObserver;
  88506. /**
  88507. * Sets a callback that will be raised when the node will be disposed
  88508. */
  88509. onDispose: () => void;
  88510. /**
  88511. * Creates a new Node
  88512. * @param name the name and id to be given to this node
  88513. * @param scene the scene this node will be added to
  88514. * @param addToRootNodes the node will be added to scene.rootNodes
  88515. */
  88516. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88517. /**
  88518. * Gets the scene of the node
  88519. * @returns a scene
  88520. */
  88521. getScene(): Scene;
  88522. /**
  88523. * Gets the engine of the node
  88524. * @returns a Engine
  88525. */
  88526. getEngine(): Engine;
  88527. private _behaviors;
  88528. /**
  88529. * Attach a behavior to the node
  88530. * @see http://doc.babylonjs.com/features/behaviour
  88531. * @param behavior defines the behavior to attach
  88532. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88533. * @returns the current Node
  88534. */
  88535. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88536. /**
  88537. * Remove an attached behavior
  88538. * @see http://doc.babylonjs.com/features/behaviour
  88539. * @param behavior defines the behavior to attach
  88540. * @returns the current Node
  88541. */
  88542. removeBehavior(behavior: Behavior<Node>): Node;
  88543. /**
  88544. * Gets the list of attached behaviors
  88545. * @see http://doc.babylonjs.com/features/behaviour
  88546. */
  88547. readonly behaviors: Behavior<Node>[];
  88548. /**
  88549. * Gets an attached behavior by name
  88550. * @param name defines the name of the behavior to look for
  88551. * @see http://doc.babylonjs.com/features/behaviour
  88552. * @returns null if behavior was not found else the requested behavior
  88553. */
  88554. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88555. /**
  88556. * Returns the latest update of the World matrix
  88557. * @returns a Matrix
  88558. */
  88559. getWorldMatrix(): Matrix;
  88560. /** @hidden */
  88561. _getWorldMatrixDeterminant(): number;
  88562. /**
  88563. * Returns directly the latest state of the mesh World matrix.
  88564. * A Matrix is returned.
  88565. */
  88566. readonly worldMatrixFromCache: Matrix;
  88567. /** @hidden */
  88568. _initCache(): void;
  88569. /** @hidden */
  88570. updateCache(force?: boolean): void;
  88571. /** @hidden */
  88572. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88573. /** @hidden */
  88574. _updateCache(ignoreParentClass?: boolean): void;
  88575. /** @hidden */
  88576. _isSynchronized(): boolean;
  88577. /** @hidden */
  88578. _markSyncedWithParent(): void;
  88579. /** @hidden */
  88580. isSynchronizedWithParent(): boolean;
  88581. /** @hidden */
  88582. isSynchronized(): boolean;
  88583. /**
  88584. * Is this node ready to be used/rendered
  88585. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88586. * @return true if the node is ready
  88587. */
  88588. isReady(completeCheck?: boolean): boolean;
  88589. /**
  88590. * Is this node enabled?
  88591. * 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
  88592. * @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
  88593. * @return whether this node (and its parent) is enabled
  88594. */
  88595. isEnabled(checkAncestors?: boolean): boolean;
  88596. /** @hidden */
  88597. protected _syncParentEnabledState(): void;
  88598. /**
  88599. * Set the enabled state of this node
  88600. * @param value defines the new enabled state
  88601. */
  88602. setEnabled(value: boolean): void;
  88603. /**
  88604. * Is this node a descendant of the given node?
  88605. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88606. * @param ancestor defines the parent node to inspect
  88607. * @returns a boolean indicating if this node is a descendant of the given node
  88608. */
  88609. isDescendantOf(ancestor: Node): boolean;
  88610. /** @hidden */
  88611. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88612. /**
  88613. * Will return all nodes that have this node as ascendant
  88614. * @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
  88615. * @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
  88616. * @return all children nodes of all types
  88617. */
  88618. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88619. /**
  88620. * Get all child-meshes of this node
  88621. * @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)
  88622. * @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
  88623. * @returns an array of AbstractMesh
  88624. */
  88625. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88626. /**
  88627. * Get all direct children of this node
  88628. * @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
  88629. * @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)
  88630. * @returns an array of Node
  88631. */
  88632. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88633. /** @hidden */
  88634. _setReady(state: boolean): void;
  88635. /**
  88636. * Get an animation by name
  88637. * @param name defines the name of the animation to look for
  88638. * @returns null if not found else the requested animation
  88639. */
  88640. getAnimationByName(name: string): Nullable<Animation>;
  88641. /**
  88642. * Creates an animation range for this node
  88643. * @param name defines the name of the range
  88644. * @param from defines the starting key
  88645. * @param to defines the end key
  88646. */
  88647. createAnimationRange(name: string, from: number, to: number): void;
  88648. /**
  88649. * Delete a specific animation range
  88650. * @param name defines the name of the range to delete
  88651. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88652. */
  88653. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88654. /**
  88655. * Get an animation range by name
  88656. * @param name defines the name of the animation range to look for
  88657. * @returns null if not found else the requested animation range
  88658. */
  88659. getAnimationRange(name: string): Nullable<AnimationRange>;
  88660. /**
  88661. * Gets the list of all animation ranges defined on this node
  88662. * @returns an array
  88663. */
  88664. getAnimationRanges(): Nullable<AnimationRange>[];
  88665. /**
  88666. * Will start the animation sequence
  88667. * @param name defines the range frames for animation sequence
  88668. * @param loop defines if the animation should loop (false by default)
  88669. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88670. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88671. * @returns the object created for this animation. If range does not exist, it will return null
  88672. */
  88673. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88674. /**
  88675. * Serialize animation ranges into a JSON compatible object
  88676. * @returns serialization object
  88677. */
  88678. serializeAnimationRanges(): any;
  88679. /**
  88680. * Computes the world matrix of the node
  88681. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88682. * @returns the world matrix
  88683. */
  88684. computeWorldMatrix(force?: boolean): Matrix;
  88685. /**
  88686. * Releases resources associated with this node.
  88687. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88688. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88689. */
  88690. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88691. /**
  88692. * Parse animation range data from a serialization object and store them into a given node
  88693. * @param node defines where to store the animation ranges
  88694. * @param parsedNode defines the serialization object to read data from
  88695. * @param scene defines the hosting scene
  88696. */
  88697. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88698. /**
  88699. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88700. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88701. * @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
  88702. * @returns the new bounding vectors
  88703. */
  88704. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88705. min: Vector3;
  88706. max: Vector3;
  88707. };
  88708. }
  88709. }
  88710. declare module BABYLON {
  88711. /**
  88712. * @hidden
  88713. */
  88714. export class _IAnimationState {
  88715. key: number;
  88716. repeatCount: number;
  88717. workValue?: any;
  88718. loopMode?: number;
  88719. offsetValue?: any;
  88720. highLimitValue?: any;
  88721. }
  88722. /**
  88723. * Class used to store any kind of animation
  88724. */
  88725. export class Animation {
  88726. /**Name of the animation */
  88727. name: string;
  88728. /**Property to animate */
  88729. targetProperty: string;
  88730. /**The frames per second of the animation */
  88731. framePerSecond: number;
  88732. /**The data type of the animation */
  88733. dataType: number;
  88734. /**The loop mode of the animation */
  88735. loopMode?: number | undefined;
  88736. /**Specifies if blending should be enabled */
  88737. enableBlending?: boolean | undefined;
  88738. /**
  88739. * Use matrix interpolation instead of using direct key value when animating matrices
  88740. */
  88741. static AllowMatricesInterpolation: boolean;
  88742. /**
  88743. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88744. */
  88745. static AllowMatrixDecomposeForInterpolation: boolean;
  88746. /**
  88747. * Stores the key frames of the animation
  88748. */
  88749. private _keys;
  88750. /**
  88751. * Stores the easing function of the animation
  88752. */
  88753. private _easingFunction;
  88754. /**
  88755. * @hidden Internal use only
  88756. */
  88757. _runtimeAnimations: RuntimeAnimation[];
  88758. /**
  88759. * The set of event that will be linked to this animation
  88760. */
  88761. private _events;
  88762. /**
  88763. * Stores an array of target property paths
  88764. */
  88765. targetPropertyPath: string[];
  88766. /**
  88767. * Stores the blending speed of the animation
  88768. */
  88769. blendingSpeed: number;
  88770. /**
  88771. * Stores the animation ranges for the animation
  88772. */
  88773. private _ranges;
  88774. /**
  88775. * @hidden Internal use
  88776. */
  88777. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88778. /**
  88779. * Sets up an animation
  88780. * @param property The property to animate
  88781. * @param animationType The animation type to apply
  88782. * @param framePerSecond The frames per second of the animation
  88783. * @param easingFunction The easing function used in the animation
  88784. * @returns The created animation
  88785. */
  88786. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88787. /**
  88788. * Create and start an animation on a node
  88789. * @param name defines the name of the global animation that will be run on all nodes
  88790. * @param node defines the root node where the animation will take place
  88791. * @param targetProperty defines property to animate
  88792. * @param framePerSecond defines the number of frame per second yo use
  88793. * @param totalFrame defines the number of frames in total
  88794. * @param from defines the initial value
  88795. * @param to defines the final value
  88796. * @param loopMode defines which loop mode you want to use (off by default)
  88797. * @param easingFunction defines the easing function to use (linear by default)
  88798. * @param onAnimationEnd defines the callback to call when animation end
  88799. * @returns the animatable created for this animation
  88800. */
  88801. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88802. /**
  88803. * Create and start an animation on a node and its descendants
  88804. * @param name defines the name of the global animation that will be run on all nodes
  88805. * @param node defines the root node where the animation will take place
  88806. * @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
  88807. * @param targetProperty defines property to animate
  88808. * @param framePerSecond defines the number of frame per second to use
  88809. * @param totalFrame defines the number of frames in total
  88810. * @param from defines the initial value
  88811. * @param to defines the final value
  88812. * @param loopMode defines which loop mode you want to use (off by default)
  88813. * @param easingFunction defines the easing function to use (linear by default)
  88814. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88815. * @returns the list of animatables created for all nodes
  88816. * @example https://www.babylonjs-playground.com/#MH0VLI
  88817. */
  88818. 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[]>;
  88819. /**
  88820. * Creates a new animation, merges it with the existing animations and starts it
  88821. * @param name Name of the animation
  88822. * @param node Node which contains the scene that begins the animations
  88823. * @param targetProperty Specifies which property to animate
  88824. * @param framePerSecond The frames per second of the animation
  88825. * @param totalFrame The total number of frames
  88826. * @param from The frame at the beginning of the animation
  88827. * @param to The frame at the end of the animation
  88828. * @param loopMode Specifies the loop mode of the animation
  88829. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88830. * @param onAnimationEnd Callback to run once the animation is complete
  88831. * @returns Nullable animation
  88832. */
  88833. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88834. /**
  88835. * Transition property of an host to the target Value
  88836. * @param property The property to transition
  88837. * @param targetValue The target Value of the property
  88838. * @param host The object where the property to animate belongs
  88839. * @param scene Scene used to run the animation
  88840. * @param frameRate Framerate (in frame/s) to use
  88841. * @param transition The transition type we want to use
  88842. * @param duration The duration of the animation, in milliseconds
  88843. * @param onAnimationEnd Callback trigger at the end of the animation
  88844. * @returns Nullable animation
  88845. */
  88846. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88847. /**
  88848. * Return the array of runtime animations currently using this animation
  88849. */
  88850. readonly runtimeAnimations: RuntimeAnimation[];
  88851. /**
  88852. * Specifies if any of the runtime animations are currently running
  88853. */
  88854. readonly hasRunningRuntimeAnimations: boolean;
  88855. /**
  88856. * Initializes the animation
  88857. * @param name Name of the animation
  88858. * @param targetProperty Property to animate
  88859. * @param framePerSecond The frames per second of the animation
  88860. * @param dataType The data type of the animation
  88861. * @param loopMode The loop mode of the animation
  88862. * @param enableBlending Specifies if blending should be enabled
  88863. */
  88864. constructor(
  88865. /**Name of the animation */
  88866. name: string,
  88867. /**Property to animate */
  88868. targetProperty: string,
  88869. /**The frames per second of the animation */
  88870. framePerSecond: number,
  88871. /**The data type of the animation */
  88872. dataType: number,
  88873. /**The loop mode of the animation */
  88874. loopMode?: number | undefined,
  88875. /**Specifies if blending should be enabled */
  88876. enableBlending?: boolean | undefined);
  88877. /**
  88878. * Converts the animation to a string
  88879. * @param fullDetails support for multiple levels of logging within scene loading
  88880. * @returns String form of the animation
  88881. */
  88882. toString(fullDetails?: boolean): string;
  88883. /**
  88884. * Add an event to this animation
  88885. * @param event Event to add
  88886. */
  88887. addEvent(event: AnimationEvent): void;
  88888. /**
  88889. * Remove all events found at the given frame
  88890. * @param frame The frame to remove events from
  88891. */
  88892. removeEvents(frame: number): void;
  88893. /**
  88894. * Retrieves all the events from the animation
  88895. * @returns Events from the animation
  88896. */
  88897. getEvents(): AnimationEvent[];
  88898. /**
  88899. * Creates an animation range
  88900. * @param name Name of the animation range
  88901. * @param from Starting frame of the animation range
  88902. * @param to Ending frame of the animation
  88903. */
  88904. createRange(name: string, from: number, to: number): void;
  88905. /**
  88906. * Deletes an animation range by name
  88907. * @param name Name of the animation range to delete
  88908. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88909. */
  88910. deleteRange(name: string, deleteFrames?: boolean): void;
  88911. /**
  88912. * Gets the animation range by name, or null if not defined
  88913. * @param name Name of the animation range
  88914. * @returns Nullable animation range
  88915. */
  88916. getRange(name: string): Nullable<AnimationRange>;
  88917. /**
  88918. * Gets the key frames from the animation
  88919. * @returns The key frames of the animation
  88920. */
  88921. getKeys(): Array<IAnimationKey>;
  88922. /**
  88923. * Gets the highest frame rate of the animation
  88924. * @returns Highest frame rate of the animation
  88925. */
  88926. getHighestFrame(): number;
  88927. /**
  88928. * Gets the easing function of the animation
  88929. * @returns Easing function of the animation
  88930. */
  88931. getEasingFunction(): IEasingFunction;
  88932. /**
  88933. * Sets the easing function of the animation
  88934. * @param easingFunction A custom mathematical formula for animation
  88935. */
  88936. setEasingFunction(easingFunction: EasingFunction): void;
  88937. /**
  88938. * Interpolates a scalar linearly
  88939. * @param startValue Start value of the animation curve
  88940. * @param endValue End value of the animation curve
  88941. * @param gradient Scalar amount to interpolate
  88942. * @returns Interpolated scalar value
  88943. */
  88944. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88945. /**
  88946. * Interpolates a scalar cubically
  88947. * @param startValue Start value of the animation curve
  88948. * @param outTangent End tangent of the animation
  88949. * @param endValue End value of the animation curve
  88950. * @param inTangent Start tangent of the animation curve
  88951. * @param gradient Scalar amount to interpolate
  88952. * @returns Interpolated scalar value
  88953. */
  88954. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88955. /**
  88956. * Interpolates a quaternion using a spherical linear interpolation
  88957. * @param startValue Start value of the animation curve
  88958. * @param endValue End value of the animation curve
  88959. * @param gradient Scalar amount to interpolate
  88960. * @returns Interpolated quaternion value
  88961. */
  88962. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88963. /**
  88964. * Interpolates a quaternion cubically
  88965. * @param startValue Start value of the animation curve
  88966. * @param outTangent End tangent of the animation curve
  88967. * @param endValue End value of the animation curve
  88968. * @param inTangent Start tangent of the animation curve
  88969. * @param gradient Scalar amount to interpolate
  88970. * @returns Interpolated quaternion value
  88971. */
  88972. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88973. /**
  88974. * Interpolates a Vector3 linearl
  88975. * @param startValue Start value of the animation curve
  88976. * @param endValue End value of the animation curve
  88977. * @param gradient Scalar amount to interpolate
  88978. * @returns Interpolated scalar value
  88979. */
  88980. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88981. /**
  88982. * Interpolates a Vector3 cubically
  88983. * @param startValue Start value of the animation curve
  88984. * @param outTangent End tangent of the animation
  88985. * @param endValue End value of the animation curve
  88986. * @param inTangent Start tangent of the animation curve
  88987. * @param gradient Scalar amount to interpolate
  88988. * @returns InterpolatedVector3 value
  88989. */
  88990. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88991. /**
  88992. * Interpolates a Vector2 linearly
  88993. * @param startValue Start value of the animation curve
  88994. * @param endValue End value of the animation curve
  88995. * @param gradient Scalar amount to interpolate
  88996. * @returns Interpolated Vector2 value
  88997. */
  88998. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88999. /**
  89000. * Interpolates a Vector2 cubically
  89001. * @param startValue Start value of the animation curve
  89002. * @param outTangent End tangent of the animation
  89003. * @param endValue End value of the animation curve
  89004. * @param inTangent Start tangent of the animation curve
  89005. * @param gradient Scalar amount to interpolate
  89006. * @returns Interpolated Vector2 value
  89007. */
  89008. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  89009. /**
  89010. * Interpolates a size linearly
  89011. * @param startValue Start value of the animation curve
  89012. * @param endValue End value of the animation curve
  89013. * @param gradient Scalar amount to interpolate
  89014. * @returns Interpolated Size value
  89015. */
  89016. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  89017. /**
  89018. * Interpolates a Color3 linearly
  89019. * @param startValue Start value of the animation curve
  89020. * @param endValue End value of the animation curve
  89021. * @param gradient Scalar amount to interpolate
  89022. * @returns Interpolated Color3 value
  89023. */
  89024. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  89025. /**
  89026. * @hidden Internal use only
  89027. */
  89028. _getKeyValue(value: any): any;
  89029. /**
  89030. * @hidden Internal use only
  89031. */
  89032. _interpolate(currentFrame: number, state: _IAnimationState): any;
  89033. /**
  89034. * Defines the function to use to interpolate matrices
  89035. * @param startValue defines the start matrix
  89036. * @param endValue defines the end matrix
  89037. * @param gradient defines the gradient between both matrices
  89038. * @param result defines an optional target matrix where to store the interpolation
  89039. * @returns the interpolated matrix
  89040. */
  89041. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  89042. /**
  89043. * Makes a copy of the animation
  89044. * @returns Cloned animation
  89045. */
  89046. clone(): Animation;
  89047. /**
  89048. * Sets the key frames of the animation
  89049. * @param values The animation key frames to set
  89050. */
  89051. setKeys(values: Array<IAnimationKey>): void;
  89052. /**
  89053. * Serializes the animation to an object
  89054. * @returns Serialized object
  89055. */
  89056. serialize(): any;
  89057. /**
  89058. * Float animation type
  89059. */
  89060. private static _ANIMATIONTYPE_FLOAT;
  89061. /**
  89062. * Vector3 animation type
  89063. */
  89064. private static _ANIMATIONTYPE_VECTOR3;
  89065. /**
  89066. * Quaternion animation type
  89067. */
  89068. private static _ANIMATIONTYPE_QUATERNION;
  89069. /**
  89070. * Matrix animation type
  89071. */
  89072. private static _ANIMATIONTYPE_MATRIX;
  89073. /**
  89074. * Color3 animation type
  89075. */
  89076. private static _ANIMATIONTYPE_COLOR3;
  89077. /**
  89078. * Vector2 animation type
  89079. */
  89080. private static _ANIMATIONTYPE_VECTOR2;
  89081. /**
  89082. * Size animation type
  89083. */
  89084. private static _ANIMATIONTYPE_SIZE;
  89085. /**
  89086. * Relative Loop Mode
  89087. */
  89088. private static _ANIMATIONLOOPMODE_RELATIVE;
  89089. /**
  89090. * Cycle Loop Mode
  89091. */
  89092. private static _ANIMATIONLOOPMODE_CYCLE;
  89093. /**
  89094. * Constant Loop Mode
  89095. */
  89096. private static _ANIMATIONLOOPMODE_CONSTANT;
  89097. /**
  89098. * Get the float animation type
  89099. */
  89100. static readonly ANIMATIONTYPE_FLOAT: number;
  89101. /**
  89102. * Get the Vector3 animation type
  89103. */
  89104. static readonly ANIMATIONTYPE_VECTOR3: number;
  89105. /**
  89106. * Get the Vector2 animation type
  89107. */
  89108. static readonly ANIMATIONTYPE_VECTOR2: number;
  89109. /**
  89110. * Get the Size animation type
  89111. */
  89112. static readonly ANIMATIONTYPE_SIZE: number;
  89113. /**
  89114. * Get the Quaternion animation type
  89115. */
  89116. static readonly ANIMATIONTYPE_QUATERNION: number;
  89117. /**
  89118. * Get the Matrix animation type
  89119. */
  89120. static readonly ANIMATIONTYPE_MATRIX: number;
  89121. /**
  89122. * Get the Color3 animation type
  89123. */
  89124. static readonly ANIMATIONTYPE_COLOR3: number;
  89125. /**
  89126. * Get the Relative Loop Mode
  89127. */
  89128. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  89129. /**
  89130. * Get the Cycle Loop Mode
  89131. */
  89132. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  89133. /**
  89134. * Get the Constant Loop Mode
  89135. */
  89136. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  89137. /** @hidden */
  89138. static _UniversalLerp(left: any, right: any, amount: number): any;
  89139. /**
  89140. * Parses an animation object and creates an animation
  89141. * @param parsedAnimation Parsed animation object
  89142. * @returns Animation object
  89143. */
  89144. static Parse(parsedAnimation: any): Animation;
  89145. /**
  89146. * Appends the serialized animations from the source animations
  89147. * @param source Source containing the animations
  89148. * @param destination Target to store the animations
  89149. */
  89150. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89151. }
  89152. }
  89153. declare module BABYLON {
  89154. /**
  89155. * Base class of all the textures in babylon.
  89156. * It groups all the common properties the materials, post process, lights... might need
  89157. * in order to make a correct use of the texture.
  89158. */
  89159. export class BaseTexture implements IAnimatable {
  89160. /**
  89161. * Default anisotropic filtering level for the application.
  89162. * It is set to 4 as a good tradeoff between perf and quality.
  89163. */
  89164. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  89165. /**
  89166. * Gets or sets the unique id of the texture
  89167. */
  89168. uniqueId: number;
  89169. /**
  89170. * Define the name of the texture.
  89171. */
  89172. name: string;
  89173. /**
  89174. * Gets or sets an object used to store user defined information.
  89175. */
  89176. metadata: any;
  89177. /**
  89178. * For internal use only. Please do not use.
  89179. */
  89180. reservedDataStore: any;
  89181. private _hasAlpha;
  89182. /**
  89183. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  89184. */
  89185. hasAlpha: boolean;
  89186. /**
  89187. * Defines if the alpha value should be determined via the rgb values.
  89188. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  89189. */
  89190. getAlphaFromRGB: boolean;
  89191. /**
  89192. * Intensity or strength of the texture.
  89193. * It is commonly used by materials to fine tune the intensity of the texture
  89194. */
  89195. level: number;
  89196. /**
  89197. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89198. * This is part of the texture as textures usually maps to one uv set.
  89199. */
  89200. coordinatesIndex: number;
  89201. private _coordinatesMode;
  89202. /**
  89203. * How a texture is mapped.
  89204. *
  89205. * | Value | Type | Description |
  89206. * | ----- | ----------------------------------- | ----------- |
  89207. * | 0 | EXPLICIT_MODE | |
  89208. * | 1 | SPHERICAL_MODE | |
  89209. * | 2 | PLANAR_MODE | |
  89210. * | 3 | CUBIC_MODE | |
  89211. * | 4 | PROJECTION_MODE | |
  89212. * | 5 | SKYBOX_MODE | |
  89213. * | 6 | INVCUBIC_MODE | |
  89214. * | 7 | EQUIRECTANGULAR_MODE | |
  89215. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89216. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89217. */
  89218. coordinatesMode: number;
  89219. /**
  89220. * | Value | Type | Description |
  89221. * | ----- | ------------------ | ----------- |
  89222. * | 0 | CLAMP_ADDRESSMODE | |
  89223. * | 1 | WRAP_ADDRESSMODE | |
  89224. * | 2 | MIRROR_ADDRESSMODE | |
  89225. */
  89226. wrapU: number;
  89227. /**
  89228. * | Value | Type | Description |
  89229. * | ----- | ------------------ | ----------- |
  89230. * | 0 | CLAMP_ADDRESSMODE | |
  89231. * | 1 | WRAP_ADDRESSMODE | |
  89232. * | 2 | MIRROR_ADDRESSMODE | |
  89233. */
  89234. wrapV: number;
  89235. /**
  89236. * | Value | Type | Description |
  89237. * | ----- | ------------------ | ----------- |
  89238. * | 0 | CLAMP_ADDRESSMODE | |
  89239. * | 1 | WRAP_ADDRESSMODE | |
  89240. * | 2 | MIRROR_ADDRESSMODE | |
  89241. */
  89242. wrapR: number;
  89243. /**
  89244. * With compliant hardware and browser (supporting anisotropic filtering)
  89245. * this defines the level of anisotropic filtering in the texture.
  89246. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89247. */
  89248. anisotropicFilteringLevel: number;
  89249. /**
  89250. * Define if the texture is a cube texture or if false a 2d texture.
  89251. */
  89252. isCube: boolean;
  89253. /**
  89254. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89255. */
  89256. is3D: boolean;
  89257. /**
  89258. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89259. * HDR texture are usually stored in linear space.
  89260. * This only impacts the PBR and Background materials
  89261. */
  89262. gammaSpace: boolean;
  89263. /**
  89264. * Gets whether or not the texture contains RGBD data.
  89265. */
  89266. readonly isRGBD: boolean;
  89267. /**
  89268. * Is Z inverted in the texture (useful in a cube texture).
  89269. */
  89270. invertZ: boolean;
  89271. /**
  89272. * Are mip maps generated for this texture or not.
  89273. */
  89274. readonly noMipmap: boolean;
  89275. /**
  89276. * @hidden
  89277. */
  89278. lodLevelInAlpha: boolean;
  89279. /**
  89280. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89281. */
  89282. lodGenerationOffset: number;
  89283. /**
  89284. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89285. */
  89286. lodGenerationScale: number;
  89287. /**
  89288. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89289. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89290. * average roughness values.
  89291. */
  89292. linearSpecularLOD: boolean;
  89293. /**
  89294. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89295. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89296. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89297. */
  89298. irradianceTexture: Nullable<BaseTexture>;
  89299. /**
  89300. * Define if the texture is a render target.
  89301. */
  89302. isRenderTarget: boolean;
  89303. /**
  89304. * Define the unique id of the texture in the scene.
  89305. */
  89306. readonly uid: string;
  89307. /**
  89308. * Return a string representation of the texture.
  89309. * @returns the texture as a string
  89310. */
  89311. toString(): string;
  89312. /**
  89313. * Get the class name of the texture.
  89314. * @returns "BaseTexture"
  89315. */
  89316. getClassName(): string;
  89317. /**
  89318. * Define the list of animation attached to the texture.
  89319. */
  89320. animations: Animation[];
  89321. /**
  89322. * An event triggered when the texture is disposed.
  89323. */
  89324. onDisposeObservable: Observable<BaseTexture>;
  89325. private _onDisposeObserver;
  89326. /**
  89327. * Callback triggered when the texture has been disposed.
  89328. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89329. */
  89330. onDispose: () => void;
  89331. /**
  89332. * Define the current state of the loading sequence when in delayed load mode.
  89333. */
  89334. delayLoadState: number;
  89335. private _scene;
  89336. /** @hidden */
  89337. _texture: Nullable<InternalTexture>;
  89338. private _uid;
  89339. /**
  89340. * Define if the texture is preventinga material to render or not.
  89341. * If not and the texture is not ready, the engine will use a default black texture instead.
  89342. */
  89343. readonly isBlocking: boolean;
  89344. /**
  89345. * Instantiates a new BaseTexture.
  89346. * Base class of all the textures in babylon.
  89347. * It groups all the common properties the materials, post process, lights... might need
  89348. * in order to make a correct use of the texture.
  89349. * @param scene Define the scene the texture blongs to
  89350. */
  89351. constructor(scene: Nullable<Scene>);
  89352. /**
  89353. * Get the scene the texture belongs to.
  89354. * @returns the scene or null if undefined
  89355. */
  89356. getScene(): Nullable<Scene>;
  89357. /**
  89358. * Get the texture transform matrix used to offset tile the texture for istance.
  89359. * @returns the transformation matrix
  89360. */
  89361. getTextureMatrix(): Matrix;
  89362. /**
  89363. * Get the texture reflection matrix used to rotate/transform the reflection.
  89364. * @returns the reflection matrix
  89365. */
  89366. getReflectionTextureMatrix(): Matrix;
  89367. /**
  89368. * Get the underlying lower level texture from Babylon.
  89369. * @returns the insternal texture
  89370. */
  89371. getInternalTexture(): Nullable<InternalTexture>;
  89372. /**
  89373. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89374. * @returns true if ready or not blocking
  89375. */
  89376. isReadyOrNotBlocking(): boolean;
  89377. /**
  89378. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89379. * @returns true if fully ready
  89380. */
  89381. isReady(): boolean;
  89382. private _cachedSize;
  89383. /**
  89384. * Get the size of the texture.
  89385. * @returns the texture size.
  89386. */
  89387. getSize(): ISize;
  89388. /**
  89389. * Get the base size of the texture.
  89390. * It can be different from the size if the texture has been resized for POT for instance
  89391. * @returns the base size
  89392. */
  89393. getBaseSize(): ISize;
  89394. /**
  89395. * Update the sampling mode of the texture.
  89396. * Default is Trilinear mode.
  89397. *
  89398. * | Value | Type | Description |
  89399. * | ----- | ------------------ | ----------- |
  89400. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89401. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89402. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89403. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89404. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89405. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89406. * | 7 | NEAREST_LINEAR | |
  89407. * | 8 | NEAREST_NEAREST | |
  89408. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89409. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89410. * | 11 | LINEAR_LINEAR | |
  89411. * | 12 | LINEAR_NEAREST | |
  89412. *
  89413. * > _mag_: magnification filter (close to the viewer)
  89414. * > _min_: minification filter (far from the viewer)
  89415. * > _mip_: filter used between mip map levels
  89416. *@param samplingMode Define the new sampling mode of the texture
  89417. */
  89418. updateSamplingMode(samplingMode: number): void;
  89419. /**
  89420. * Scales the texture if is `canRescale()`
  89421. * @param ratio the resize factor we want to use to rescale
  89422. */
  89423. scale(ratio: number): void;
  89424. /**
  89425. * Get if the texture can rescale.
  89426. */
  89427. readonly canRescale: boolean;
  89428. /** @hidden */
  89429. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89430. /** @hidden */
  89431. _rebuild(): void;
  89432. /**
  89433. * Triggers the load sequence in delayed load mode.
  89434. */
  89435. delayLoad(): void;
  89436. /**
  89437. * Clones the texture.
  89438. * @returns the cloned texture
  89439. */
  89440. clone(): Nullable<BaseTexture>;
  89441. /**
  89442. * Get the texture underlying type (INT, FLOAT...)
  89443. */
  89444. readonly textureType: number;
  89445. /**
  89446. * Get the texture underlying format (RGB, RGBA...)
  89447. */
  89448. readonly textureFormat: number;
  89449. /**
  89450. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89451. * This will returns an RGBA array buffer containing either in values (0-255) or
  89452. * float values (0-1) depending of the underlying buffer type.
  89453. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89454. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89455. * @param buffer defines a user defined buffer to fill with data (can be null)
  89456. * @returns The Array buffer containing the pixels data.
  89457. */
  89458. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89459. /**
  89460. * Release and destroy the underlying lower level texture aka internalTexture.
  89461. */
  89462. releaseInternalTexture(): void;
  89463. /**
  89464. * Get the polynomial representation of the texture data.
  89465. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89466. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89467. */
  89468. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89469. /** @hidden */
  89470. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89471. /** @hidden */
  89472. readonly _lodTextureMid: Nullable<BaseTexture>;
  89473. /** @hidden */
  89474. readonly _lodTextureLow: Nullable<BaseTexture>;
  89475. /**
  89476. * Dispose the texture and release its associated resources.
  89477. */
  89478. dispose(): void;
  89479. /**
  89480. * Serialize the texture into a JSON representation that can be parsed later on.
  89481. * @returns the JSON representation of the texture
  89482. */
  89483. serialize(): any;
  89484. /**
  89485. * Helper function to be called back once a list of texture contains only ready textures.
  89486. * @param textures Define the list of textures to wait for
  89487. * @param callback Define the callback triggered once the entire list will be ready
  89488. */
  89489. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89490. }
  89491. }
  89492. declare module BABYLON {
  89493. /**
  89494. * Uniform buffer objects.
  89495. *
  89496. * Handles blocks of uniform on the GPU.
  89497. *
  89498. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89499. *
  89500. * For more information, please refer to :
  89501. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89502. */
  89503. export class UniformBuffer {
  89504. private _engine;
  89505. private _buffer;
  89506. private _data;
  89507. private _bufferData;
  89508. private _dynamic?;
  89509. private _uniformLocations;
  89510. private _uniformSizes;
  89511. private _uniformLocationPointer;
  89512. private _needSync;
  89513. private _noUBO;
  89514. private _currentEffect;
  89515. private static _MAX_UNIFORM_SIZE;
  89516. private static _tempBuffer;
  89517. /**
  89518. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89519. * This is dynamic to allow compat with webgl 1 and 2.
  89520. * You will need to pass the name of the uniform as well as the value.
  89521. */
  89522. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89523. /**
  89524. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89525. * This is dynamic to allow compat with webgl 1 and 2.
  89526. * You will need to pass the name of the uniform as well as the value.
  89527. */
  89528. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89529. /**
  89530. * Lambda to Update a single float in a uniform buffer.
  89531. * This is dynamic to allow compat with webgl 1 and 2.
  89532. * You will need to pass the name of the uniform as well as the value.
  89533. */
  89534. updateFloat: (name: string, x: number) => void;
  89535. /**
  89536. * Lambda to Update a vec2 of float in a uniform buffer.
  89537. * This is dynamic to allow compat with webgl 1 and 2.
  89538. * You will need to pass the name of the uniform as well as the value.
  89539. */
  89540. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89541. /**
  89542. * Lambda to Update a vec3 of float in a uniform buffer.
  89543. * This is dynamic to allow compat with webgl 1 and 2.
  89544. * You will need to pass the name of the uniform as well as the value.
  89545. */
  89546. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89547. /**
  89548. * Lambda to Update a vec4 of float in a uniform buffer.
  89549. * This is dynamic to allow compat with webgl 1 and 2.
  89550. * You will need to pass the name of the uniform as well as the value.
  89551. */
  89552. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89553. /**
  89554. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89555. * This is dynamic to allow compat with webgl 1 and 2.
  89556. * You will need to pass the name of the uniform as well as the value.
  89557. */
  89558. updateMatrix: (name: string, mat: Matrix) => void;
  89559. /**
  89560. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89561. * This is dynamic to allow compat with webgl 1 and 2.
  89562. * You will need to pass the name of the uniform as well as the value.
  89563. */
  89564. updateVector3: (name: string, vector: Vector3) => void;
  89565. /**
  89566. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89567. * This is dynamic to allow compat with webgl 1 and 2.
  89568. * You will need to pass the name of the uniform as well as the value.
  89569. */
  89570. updateVector4: (name: string, vector: Vector4) => void;
  89571. /**
  89572. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89573. * This is dynamic to allow compat with webgl 1 and 2.
  89574. * You will need to pass the name of the uniform as well as the value.
  89575. */
  89576. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89577. /**
  89578. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89579. * This is dynamic to allow compat with webgl 1 and 2.
  89580. * You will need to pass the name of the uniform as well as the value.
  89581. */
  89582. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89583. /**
  89584. * Instantiates a new Uniform buffer objects.
  89585. *
  89586. * Handles blocks of uniform on the GPU.
  89587. *
  89588. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89589. *
  89590. * For more information, please refer to :
  89591. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89592. * @param engine Define the engine the buffer is associated with
  89593. * @param data Define the data contained in the buffer
  89594. * @param dynamic Define if the buffer is updatable
  89595. */
  89596. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89597. /**
  89598. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89599. * or just falling back on setUniformXXX calls.
  89600. */
  89601. readonly useUbo: boolean;
  89602. /**
  89603. * Indicates if the WebGL underlying uniform buffer is in sync
  89604. * with the javascript cache data.
  89605. */
  89606. readonly isSync: boolean;
  89607. /**
  89608. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89609. * Also, a dynamic UniformBuffer will disable cache verification and always
  89610. * update the underlying WebGL uniform buffer to the GPU.
  89611. * @returns if Dynamic, otherwise false
  89612. */
  89613. isDynamic(): boolean;
  89614. /**
  89615. * The data cache on JS side.
  89616. * @returns the underlying data as a float array
  89617. */
  89618. getData(): Float32Array;
  89619. /**
  89620. * The underlying WebGL Uniform buffer.
  89621. * @returns the webgl buffer
  89622. */
  89623. getBuffer(): Nullable<DataBuffer>;
  89624. /**
  89625. * std140 layout specifies how to align data within an UBO structure.
  89626. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89627. * for specs.
  89628. */
  89629. private _fillAlignment;
  89630. /**
  89631. * Adds an uniform in the buffer.
  89632. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89633. * for the layout to be correct !
  89634. * @param name Name of the uniform, as used in the uniform block in the shader.
  89635. * @param size Data size, or data directly.
  89636. */
  89637. addUniform(name: string, size: number | number[]): void;
  89638. /**
  89639. * Adds a Matrix 4x4 to the uniform buffer.
  89640. * @param name Name of the uniform, as used in the uniform block in the shader.
  89641. * @param mat A 4x4 matrix.
  89642. */
  89643. addMatrix(name: string, mat: Matrix): void;
  89644. /**
  89645. * Adds a vec2 to the uniform buffer.
  89646. * @param name Name of the uniform, as used in the uniform block in the shader.
  89647. * @param x Define the x component value of the vec2
  89648. * @param y Define the y component value of the vec2
  89649. */
  89650. addFloat2(name: string, x: number, y: number): void;
  89651. /**
  89652. * Adds a vec3 to the uniform buffer.
  89653. * @param name Name of the uniform, as used in the uniform block in the shader.
  89654. * @param x Define the x component value of the vec3
  89655. * @param y Define the y component value of the vec3
  89656. * @param z Define the z component value of the vec3
  89657. */
  89658. addFloat3(name: string, x: number, y: number, z: number): void;
  89659. /**
  89660. * Adds a vec3 to the uniform buffer.
  89661. * @param name Name of the uniform, as used in the uniform block in the shader.
  89662. * @param color Define the vec3 from a Color
  89663. */
  89664. addColor3(name: string, color: Color3): void;
  89665. /**
  89666. * Adds a vec4 to the uniform buffer.
  89667. * @param name Name of the uniform, as used in the uniform block in the shader.
  89668. * @param color Define the rgb components from a Color
  89669. * @param alpha Define the a component of the vec4
  89670. */
  89671. addColor4(name: string, color: Color3, alpha: number): void;
  89672. /**
  89673. * Adds a vec3 to the uniform buffer.
  89674. * @param name Name of the uniform, as used in the uniform block in the shader.
  89675. * @param vector Define the vec3 components from a Vector
  89676. */
  89677. addVector3(name: string, vector: Vector3): void;
  89678. /**
  89679. * Adds a Matrix 3x3 to the uniform buffer.
  89680. * @param name Name of the uniform, as used in the uniform block in the shader.
  89681. */
  89682. addMatrix3x3(name: string): void;
  89683. /**
  89684. * Adds a Matrix 2x2 to the uniform buffer.
  89685. * @param name Name of the uniform, as used in the uniform block in the shader.
  89686. */
  89687. addMatrix2x2(name: string): void;
  89688. /**
  89689. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89690. */
  89691. create(): void;
  89692. /** @hidden */
  89693. _rebuild(): void;
  89694. /**
  89695. * Updates the WebGL Uniform Buffer on the GPU.
  89696. * If the `dynamic` flag is set to true, no cache comparison is done.
  89697. * Otherwise, the buffer will be updated only if the cache differs.
  89698. */
  89699. update(): void;
  89700. /**
  89701. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89702. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89703. * @param data Define the flattened data
  89704. * @param size Define the size of the data.
  89705. */
  89706. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89707. private _updateMatrix3x3ForUniform;
  89708. private _updateMatrix3x3ForEffect;
  89709. private _updateMatrix2x2ForEffect;
  89710. private _updateMatrix2x2ForUniform;
  89711. private _updateFloatForEffect;
  89712. private _updateFloatForUniform;
  89713. private _updateFloat2ForEffect;
  89714. private _updateFloat2ForUniform;
  89715. private _updateFloat3ForEffect;
  89716. private _updateFloat3ForUniform;
  89717. private _updateFloat4ForEffect;
  89718. private _updateFloat4ForUniform;
  89719. private _updateMatrixForEffect;
  89720. private _updateMatrixForUniform;
  89721. private _updateVector3ForEffect;
  89722. private _updateVector3ForUniform;
  89723. private _updateVector4ForEffect;
  89724. private _updateVector4ForUniform;
  89725. private _updateColor3ForEffect;
  89726. private _updateColor3ForUniform;
  89727. private _updateColor4ForEffect;
  89728. private _updateColor4ForUniform;
  89729. /**
  89730. * Sets a sampler uniform on the effect.
  89731. * @param name Define the name of the sampler.
  89732. * @param texture Define the texture to set in the sampler
  89733. */
  89734. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89735. /**
  89736. * Directly updates the value of the uniform in the cache AND on the GPU.
  89737. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89738. * @param data Define the flattened data
  89739. */
  89740. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89741. /**
  89742. * Binds this uniform buffer to an effect.
  89743. * @param effect Define the effect to bind the buffer to
  89744. * @param name Name of the uniform block in the shader.
  89745. */
  89746. bindToEffect(effect: Effect, name: string): void;
  89747. /**
  89748. * Disposes the uniform buffer.
  89749. */
  89750. dispose(): void;
  89751. }
  89752. }
  89753. declare module BABYLON {
  89754. /**
  89755. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89757. */
  89758. export class Analyser {
  89759. /**
  89760. * Gets or sets the smoothing
  89761. * @ignorenaming
  89762. */
  89763. SMOOTHING: number;
  89764. /**
  89765. * Gets or sets the FFT table size
  89766. * @ignorenaming
  89767. */
  89768. FFT_SIZE: number;
  89769. /**
  89770. * Gets or sets the bar graph amplitude
  89771. * @ignorenaming
  89772. */
  89773. BARGRAPHAMPLITUDE: number;
  89774. /**
  89775. * Gets or sets the position of the debug canvas
  89776. * @ignorenaming
  89777. */
  89778. DEBUGCANVASPOS: {
  89779. x: number;
  89780. y: number;
  89781. };
  89782. /**
  89783. * Gets or sets the debug canvas size
  89784. * @ignorenaming
  89785. */
  89786. DEBUGCANVASSIZE: {
  89787. width: number;
  89788. height: number;
  89789. };
  89790. private _byteFreqs;
  89791. private _byteTime;
  89792. private _floatFreqs;
  89793. private _webAudioAnalyser;
  89794. private _debugCanvas;
  89795. private _debugCanvasContext;
  89796. private _scene;
  89797. private _registerFunc;
  89798. private _audioEngine;
  89799. /**
  89800. * Creates a new analyser
  89801. * @param scene defines hosting scene
  89802. */
  89803. constructor(scene: Scene);
  89804. /**
  89805. * Get the number of data values you will have to play with for the visualization
  89806. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89807. * @returns a number
  89808. */
  89809. getFrequencyBinCount(): number;
  89810. /**
  89811. * Gets the current frequency data as a byte array
  89812. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89813. * @returns a Uint8Array
  89814. */
  89815. getByteFrequencyData(): Uint8Array;
  89816. /**
  89817. * Gets the current waveform as a byte array
  89818. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89819. * @returns a Uint8Array
  89820. */
  89821. getByteTimeDomainData(): Uint8Array;
  89822. /**
  89823. * Gets the current frequency data as a float array
  89824. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89825. * @returns a Float32Array
  89826. */
  89827. getFloatFrequencyData(): Float32Array;
  89828. /**
  89829. * Renders the debug canvas
  89830. */
  89831. drawDebugCanvas(): void;
  89832. /**
  89833. * Stops rendering the debug canvas and removes it
  89834. */
  89835. stopDebugCanvas(): void;
  89836. /**
  89837. * Connects two audio nodes
  89838. * @param inputAudioNode defines first node to connect
  89839. * @param outputAudioNode defines second node to connect
  89840. */
  89841. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89842. /**
  89843. * Releases all associated resources
  89844. */
  89845. dispose(): void;
  89846. }
  89847. }
  89848. declare module BABYLON {
  89849. /**
  89850. * This represents an audio engine and it is responsible
  89851. * to play, synchronize and analyse sounds throughout the application.
  89852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89853. */
  89854. export interface IAudioEngine extends IDisposable {
  89855. /**
  89856. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89857. */
  89858. readonly canUseWebAudio: boolean;
  89859. /**
  89860. * Gets the current AudioContext if available.
  89861. */
  89862. readonly audioContext: Nullable<AudioContext>;
  89863. /**
  89864. * The master gain node defines the global audio volume of your audio engine.
  89865. */
  89866. readonly masterGain: GainNode;
  89867. /**
  89868. * Gets whether or not mp3 are supported by your browser.
  89869. */
  89870. readonly isMP3supported: boolean;
  89871. /**
  89872. * Gets whether or not ogg are supported by your browser.
  89873. */
  89874. readonly isOGGsupported: boolean;
  89875. /**
  89876. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89877. * @ignoreNaming
  89878. */
  89879. WarnedWebAudioUnsupported: boolean;
  89880. /**
  89881. * Defines if the audio engine relies on a custom unlocked button.
  89882. * In this case, the embedded button will not be displayed.
  89883. */
  89884. useCustomUnlockedButton: boolean;
  89885. /**
  89886. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89887. */
  89888. readonly unlocked: boolean;
  89889. /**
  89890. * Event raised when audio has been unlocked on the browser.
  89891. */
  89892. onAudioUnlockedObservable: Observable<AudioEngine>;
  89893. /**
  89894. * Event raised when audio has been locked on the browser.
  89895. */
  89896. onAudioLockedObservable: Observable<AudioEngine>;
  89897. /**
  89898. * Flags the audio engine in Locked state.
  89899. * This happens due to new browser policies preventing audio to autoplay.
  89900. */
  89901. lock(): void;
  89902. /**
  89903. * Unlocks the audio engine once a user action has been done on the dom.
  89904. * This is helpful to resume play once browser policies have been satisfied.
  89905. */
  89906. unlock(): void;
  89907. }
  89908. /**
  89909. * This represents the default audio engine used in babylon.
  89910. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89912. */
  89913. export class AudioEngine implements IAudioEngine {
  89914. private _audioContext;
  89915. private _audioContextInitialized;
  89916. private _muteButton;
  89917. private _hostElement;
  89918. /**
  89919. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89920. */
  89921. canUseWebAudio: boolean;
  89922. /**
  89923. * The master gain node defines the global audio volume of your audio engine.
  89924. */
  89925. masterGain: GainNode;
  89926. /**
  89927. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89928. * @ignoreNaming
  89929. */
  89930. WarnedWebAudioUnsupported: boolean;
  89931. /**
  89932. * Gets whether or not mp3 are supported by your browser.
  89933. */
  89934. isMP3supported: boolean;
  89935. /**
  89936. * Gets whether or not ogg are supported by your browser.
  89937. */
  89938. isOGGsupported: boolean;
  89939. /**
  89940. * Gets whether audio has been unlocked on the device.
  89941. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89942. * a user interaction has happened.
  89943. */
  89944. unlocked: boolean;
  89945. /**
  89946. * Defines if the audio engine relies on a custom unlocked button.
  89947. * In this case, the embedded button will not be displayed.
  89948. */
  89949. useCustomUnlockedButton: boolean;
  89950. /**
  89951. * Event raised when audio has been unlocked on the browser.
  89952. */
  89953. onAudioUnlockedObservable: Observable<AudioEngine>;
  89954. /**
  89955. * Event raised when audio has been locked on the browser.
  89956. */
  89957. onAudioLockedObservable: Observable<AudioEngine>;
  89958. /**
  89959. * Gets the current AudioContext if available.
  89960. */
  89961. readonly audioContext: Nullable<AudioContext>;
  89962. private _connectedAnalyser;
  89963. /**
  89964. * Instantiates a new audio engine.
  89965. *
  89966. * There should be only one per page as some browsers restrict the number
  89967. * of audio contexts you can create.
  89968. * @param hostElement defines the host element where to display the mute icon if necessary
  89969. */
  89970. constructor(hostElement?: Nullable<HTMLElement>);
  89971. /**
  89972. * Flags the audio engine in Locked state.
  89973. * This happens due to new browser policies preventing audio to autoplay.
  89974. */
  89975. lock(): void;
  89976. /**
  89977. * Unlocks the audio engine once a user action has been done on the dom.
  89978. * This is helpful to resume play once browser policies have been satisfied.
  89979. */
  89980. unlock(): void;
  89981. private _resumeAudioContext;
  89982. private _initializeAudioContext;
  89983. private _tryToRun;
  89984. private _triggerRunningState;
  89985. private _triggerSuspendedState;
  89986. private _displayMuteButton;
  89987. private _moveButtonToTopLeft;
  89988. private _onResize;
  89989. private _hideMuteButton;
  89990. /**
  89991. * Destroy and release the resources associated with the audio ccontext.
  89992. */
  89993. dispose(): void;
  89994. /**
  89995. * Gets the global volume sets on the master gain.
  89996. * @returns the global volume if set or -1 otherwise
  89997. */
  89998. getGlobalVolume(): number;
  89999. /**
  90000. * Sets the global volume of your experience (sets on the master gain).
  90001. * @param newVolume Defines the new global volume of the application
  90002. */
  90003. setGlobalVolume(newVolume: number): void;
  90004. /**
  90005. * Connect the audio engine to an audio analyser allowing some amazing
  90006. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90008. * @param analyser The analyser to connect to the engine
  90009. */
  90010. connectToAnalyser(analyser: Analyser): void;
  90011. }
  90012. }
  90013. declare module BABYLON {
  90014. /**
  90015. * Interface used to present a loading screen while loading a scene
  90016. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90017. */
  90018. export interface ILoadingScreen {
  90019. /**
  90020. * Function called to display the loading screen
  90021. */
  90022. displayLoadingUI: () => void;
  90023. /**
  90024. * Function called to hide the loading screen
  90025. */
  90026. hideLoadingUI: () => void;
  90027. /**
  90028. * Gets or sets the color to use for the background
  90029. */
  90030. loadingUIBackgroundColor: string;
  90031. /**
  90032. * Gets or sets the text to display while loading
  90033. */
  90034. loadingUIText: string;
  90035. }
  90036. /**
  90037. * Class used for the default loading screen
  90038. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90039. */
  90040. export class DefaultLoadingScreen implements ILoadingScreen {
  90041. private _renderingCanvas;
  90042. private _loadingText;
  90043. private _loadingDivBackgroundColor;
  90044. private _loadingDiv;
  90045. private _loadingTextDiv;
  90046. /** Gets or sets the logo url to use for the default loading screen */
  90047. static DefaultLogoUrl: string;
  90048. /** Gets or sets the spinner url to use for the default loading screen */
  90049. static DefaultSpinnerUrl: string;
  90050. /**
  90051. * Creates a new default loading screen
  90052. * @param _renderingCanvas defines the canvas used to render the scene
  90053. * @param _loadingText defines the default text to display
  90054. * @param _loadingDivBackgroundColor defines the default background color
  90055. */
  90056. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  90057. /**
  90058. * Function called to display the loading screen
  90059. */
  90060. displayLoadingUI(): void;
  90061. /**
  90062. * Function called to hide the loading screen
  90063. */
  90064. hideLoadingUI(): void;
  90065. /**
  90066. * Gets or sets the text to display while loading
  90067. */
  90068. loadingUIText: string;
  90069. /**
  90070. * Gets or sets the color to use for the background
  90071. */
  90072. loadingUIBackgroundColor: string;
  90073. private _resizeLoadingUI;
  90074. }
  90075. }
  90076. declare module BABYLON {
  90077. /** @hidden */
  90078. export class WebGLPipelineContext implements IPipelineContext {
  90079. engine: Engine;
  90080. program: Nullable<WebGLProgram>;
  90081. context?: WebGLRenderingContext;
  90082. vertexShader?: WebGLShader;
  90083. fragmentShader?: WebGLShader;
  90084. isParallelCompiled: boolean;
  90085. onCompiled?: () => void;
  90086. transformFeedback?: WebGLTransformFeedback | null;
  90087. readonly isAsync: boolean;
  90088. readonly isReady: boolean;
  90089. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  90090. }
  90091. }
  90092. declare module BABYLON {
  90093. /** @hidden */
  90094. export class WebGLDataBuffer extends DataBuffer {
  90095. private _buffer;
  90096. constructor(resource: WebGLBuffer);
  90097. readonly underlyingResource: any;
  90098. }
  90099. }
  90100. declare module BABYLON {
  90101. /** @hidden */
  90102. export class WebGL2ShaderProcessor implements IShaderProcessor {
  90103. attributeProcessor(attribute: string): string;
  90104. varyingProcessor(varying: string, isFragment: boolean): string;
  90105. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  90106. }
  90107. }
  90108. declare module BABYLON {
  90109. /**
  90110. * Settings for finer control over video usage
  90111. */
  90112. export interface VideoTextureSettings {
  90113. /**
  90114. * Applies `autoplay` to video, if specified
  90115. */
  90116. autoPlay?: boolean;
  90117. /**
  90118. * Applies `loop` to video, if specified
  90119. */
  90120. loop?: boolean;
  90121. /**
  90122. * Automatically updates internal texture from video at every frame in the render loop
  90123. */
  90124. autoUpdateTexture: boolean;
  90125. /**
  90126. * Image src displayed during the video loading or until the user interacts with the video.
  90127. */
  90128. poster?: string;
  90129. }
  90130. /**
  90131. * If you want to display a video in your scene, this is the special texture for that.
  90132. * This special texture works similar to other textures, with the exception of a few parameters.
  90133. * @see https://doc.babylonjs.com/how_to/video_texture
  90134. */
  90135. export class VideoTexture extends Texture {
  90136. /**
  90137. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  90138. */
  90139. readonly autoUpdateTexture: boolean;
  90140. /**
  90141. * The video instance used by the texture internally
  90142. */
  90143. readonly video: HTMLVideoElement;
  90144. private _onUserActionRequestedObservable;
  90145. /**
  90146. * Event triggerd when a dom action is required by the user to play the video.
  90147. * This happens due to recent changes in browser policies preventing video to auto start.
  90148. */
  90149. readonly onUserActionRequestedObservable: Observable<Texture>;
  90150. private _generateMipMaps;
  90151. private _engine;
  90152. private _stillImageCaptured;
  90153. private _displayingPosterTexture;
  90154. private _settings;
  90155. private _createInternalTextureOnEvent;
  90156. /**
  90157. * Creates a video texture.
  90158. * If you want to display a video in your scene, this is the special texture for that.
  90159. * This special texture works similar to other textures, with the exception of a few parameters.
  90160. * @see https://doc.babylonjs.com/how_to/video_texture
  90161. * @param name optional name, will detect from video source, if not defined
  90162. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  90163. * @param scene is obviously the current scene.
  90164. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  90165. * @param invertY is false by default but can be used to invert video on Y axis
  90166. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  90167. * @param settings allows finer control over video usage
  90168. */
  90169. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  90170. private _getName;
  90171. private _getVideo;
  90172. private _createInternalTexture;
  90173. private reset;
  90174. /**
  90175. * @hidden Internal method to initiate `update`.
  90176. */
  90177. _rebuild(): void;
  90178. /**
  90179. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  90180. */
  90181. update(): void;
  90182. /**
  90183. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  90184. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  90185. */
  90186. updateTexture(isVisible: boolean): void;
  90187. protected _updateInternalTexture: () => void;
  90188. /**
  90189. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  90190. * @param url New url.
  90191. */
  90192. updateURL(url: string): void;
  90193. /**
  90194. * Dispose the texture and release its associated resources.
  90195. */
  90196. dispose(): void;
  90197. /**
  90198. * Creates a video texture straight from a stream.
  90199. * @param scene Define the scene the texture should be created in
  90200. * @param stream Define the stream the texture should be created from
  90201. * @returns The created video texture as a promise
  90202. */
  90203. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  90204. /**
  90205. * Creates a video texture straight from your WebCam video feed.
  90206. * @param scene Define the scene the texture should be created in
  90207. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90208. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90209. * @returns The created video texture as a promise
  90210. */
  90211. static CreateFromWebCamAsync(scene: Scene, constraints: {
  90212. minWidth: number;
  90213. maxWidth: number;
  90214. minHeight: number;
  90215. maxHeight: number;
  90216. deviceId: string;
  90217. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  90218. /**
  90219. * Creates a video texture straight from your WebCam video feed.
  90220. * @param scene Define the scene the texture should be created in
  90221. * @param onReady Define a callback to triggered once the texture will be ready
  90222. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90223. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90224. */
  90225. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  90226. minWidth: number;
  90227. maxWidth: number;
  90228. minHeight: number;
  90229. maxHeight: number;
  90230. deviceId: string;
  90231. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  90232. }
  90233. }
  90234. declare module BABYLON {
  90235. /**
  90236. * Interface for attribute information associated with buffer instanciation
  90237. */
  90238. export class InstancingAttributeInfo {
  90239. /**
  90240. * Index/offset of the attribute in the vertex shader
  90241. */
  90242. index: number;
  90243. /**
  90244. * size of the attribute, 1, 2, 3 or 4
  90245. */
  90246. attributeSize: number;
  90247. /**
  90248. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  90249. * default is FLOAT
  90250. */
  90251. attribyteType: number;
  90252. /**
  90253. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  90254. */
  90255. normalized: boolean;
  90256. /**
  90257. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  90258. */
  90259. offset: number;
  90260. /**
  90261. * Name of the GLSL attribute, for debugging purpose only
  90262. */
  90263. attributeName: string;
  90264. }
  90265. /**
  90266. * Define options used to create a depth texture
  90267. */
  90268. export class DepthTextureCreationOptions {
  90269. /** Specifies whether or not a stencil should be allocated in the texture */
  90270. generateStencil?: boolean;
  90271. /** Specifies whether or not bilinear filtering is enable on the texture */
  90272. bilinearFiltering?: boolean;
  90273. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  90274. comparisonFunction?: number;
  90275. /** Specifies if the created texture is a cube texture */
  90276. isCube?: boolean;
  90277. }
  90278. /**
  90279. * Class used to describe the capabilities of the engine relatively to the current browser
  90280. */
  90281. export class EngineCapabilities {
  90282. /** Maximum textures units per fragment shader */
  90283. maxTexturesImageUnits: number;
  90284. /** Maximum texture units per vertex shader */
  90285. maxVertexTextureImageUnits: number;
  90286. /** Maximum textures units in the entire pipeline */
  90287. maxCombinedTexturesImageUnits: number;
  90288. /** Maximum texture size */
  90289. maxTextureSize: number;
  90290. /** Maximum cube texture size */
  90291. maxCubemapTextureSize: number;
  90292. /** Maximum render texture size */
  90293. maxRenderTextureSize: number;
  90294. /** Maximum number of vertex attributes */
  90295. maxVertexAttribs: number;
  90296. /** Maximum number of varyings */
  90297. maxVaryingVectors: number;
  90298. /** Maximum number of uniforms per vertex shader */
  90299. maxVertexUniformVectors: number;
  90300. /** Maximum number of uniforms per fragment shader */
  90301. maxFragmentUniformVectors: number;
  90302. /** Defines if standard derivates (dx/dy) are supported */
  90303. standardDerivatives: boolean;
  90304. /** Defines if s3tc texture compression is supported */
  90305. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  90306. /** Defines if pvrtc texture compression is supported */
  90307. pvrtc: any;
  90308. /** Defines if etc1 texture compression is supported */
  90309. etc1: any;
  90310. /** Defines if etc2 texture compression is supported */
  90311. etc2: any;
  90312. /** Defines if astc texture compression is supported */
  90313. astc: any;
  90314. /** Defines if float textures are supported */
  90315. textureFloat: boolean;
  90316. /** Defines if vertex array objects are supported */
  90317. vertexArrayObject: boolean;
  90318. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  90319. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  90320. /** Gets the maximum level of anisotropy supported */
  90321. maxAnisotropy: number;
  90322. /** Defines if instancing is supported */
  90323. instancedArrays: boolean;
  90324. /** Defines if 32 bits indices are supported */
  90325. uintIndices: boolean;
  90326. /** Defines if high precision shaders are supported */
  90327. highPrecisionShaderSupported: boolean;
  90328. /** Defines if depth reading in the fragment shader is supported */
  90329. fragmentDepthSupported: boolean;
  90330. /** Defines if float texture linear filtering is supported*/
  90331. textureFloatLinearFiltering: boolean;
  90332. /** Defines if rendering to float textures is supported */
  90333. textureFloatRender: boolean;
  90334. /** Defines if half float textures are supported*/
  90335. textureHalfFloat: boolean;
  90336. /** Defines if half float texture linear filtering is supported*/
  90337. textureHalfFloatLinearFiltering: boolean;
  90338. /** Defines if rendering to half float textures is supported */
  90339. textureHalfFloatRender: boolean;
  90340. /** Defines if textureLOD shader command is supported */
  90341. textureLOD: boolean;
  90342. /** Defines if draw buffers extension is supported */
  90343. drawBuffersExtension: boolean;
  90344. /** Defines if depth textures are supported */
  90345. depthTextureExtension: boolean;
  90346. /** Defines if float color buffer are supported */
  90347. colorBufferFloat: boolean;
  90348. /** Gets disjoint timer query extension (null if not supported) */
  90349. timerQuery: EXT_disjoint_timer_query;
  90350. /** Defines if timestamp can be used with timer query */
  90351. canUseTimestampForTimerQuery: boolean;
  90352. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  90353. multiview: any;
  90354. /** Function used to let the system compiles shaders in background */
  90355. parallelShaderCompile: {
  90356. COMPLETION_STATUS_KHR: number;
  90357. };
  90358. }
  90359. /** Interface defining initialization parameters for Engine class */
  90360. export interface EngineOptions extends WebGLContextAttributes {
  90361. /**
  90362. * Defines if the engine should no exceed a specified device ratio
  90363. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90364. */
  90365. limitDeviceRatio?: number;
  90366. /**
  90367. * Defines if webvr should be enabled automatically
  90368. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90369. */
  90370. autoEnableWebVR?: boolean;
  90371. /**
  90372. * Defines if webgl2 should be turned off even if supported
  90373. * @see http://doc.babylonjs.com/features/webgl2
  90374. */
  90375. disableWebGL2Support?: boolean;
  90376. /**
  90377. * Defines if webaudio should be initialized as well
  90378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90379. */
  90380. audioEngine?: boolean;
  90381. /**
  90382. * Defines if animations should run using a deterministic lock step
  90383. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90384. */
  90385. deterministicLockstep?: boolean;
  90386. /** Defines the maximum steps to use with deterministic lock step mode */
  90387. lockstepMaxSteps?: number;
  90388. /**
  90389. * Defines that engine should ignore context lost events
  90390. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90391. */
  90392. doNotHandleContextLost?: boolean;
  90393. /**
  90394. * Defines that engine should ignore modifying touch action attribute and style
  90395. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90396. */
  90397. doNotHandleTouchAction?: boolean;
  90398. /**
  90399. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90400. */
  90401. useHighPrecisionFloats?: boolean;
  90402. }
  90403. /**
  90404. * Defines the interface used by display changed events
  90405. */
  90406. export interface IDisplayChangedEventArgs {
  90407. /** Gets the vrDisplay object (if any) */
  90408. vrDisplay: Nullable<any>;
  90409. /** Gets a boolean indicating if webVR is supported */
  90410. vrSupported: boolean;
  90411. }
  90412. /**
  90413. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90414. */
  90415. export class Engine {
  90416. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90417. static ExceptionList: ({
  90418. key: string;
  90419. capture: string;
  90420. captureConstraint: number;
  90421. targets: string[];
  90422. } | {
  90423. key: string;
  90424. capture: null;
  90425. captureConstraint: null;
  90426. targets: string[];
  90427. })[];
  90428. /** Gets the list of created engines */
  90429. static readonly Instances: Engine[];
  90430. /**
  90431. * Gets the latest created engine
  90432. */
  90433. static readonly LastCreatedEngine: Nullable<Engine>;
  90434. /**
  90435. * Gets the latest created scene
  90436. */
  90437. static readonly LastCreatedScene: Nullable<Scene>;
  90438. /**
  90439. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90440. * @param flag defines which part of the materials must be marked as dirty
  90441. * @param predicate defines a predicate used to filter which materials should be affected
  90442. */
  90443. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90444. /** @hidden */
  90445. static _TextureLoaders: IInternalTextureLoader[];
  90446. /** Defines that alpha blending is disabled */
  90447. static readonly ALPHA_DISABLE: number;
  90448. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90449. static readonly ALPHA_ADD: number;
  90450. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90451. static readonly ALPHA_COMBINE: number;
  90452. /** Defines that alpha blending to DEST - SRC * DEST */
  90453. static readonly ALPHA_SUBTRACT: number;
  90454. /** Defines that alpha blending to SRC * DEST */
  90455. static readonly ALPHA_MULTIPLY: number;
  90456. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90457. static readonly ALPHA_MAXIMIZED: number;
  90458. /** Defines that alpha blending to SRC + DEST */
  90459. static readonly ALPHA_ONEONE: number;
  90460. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90461. static readonly ALPHA_PREMULTIPLIED: number;
  90462. /**
  90463. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90464. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90465. */
  90466. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90467. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90468. static readonly ALPHA_INTERPOLATE: number;
  90469. /**
  90470. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90471. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90472. */
  90473. static readonly ALPHA_SCREENMODE: number;
  90474. /** Defines that the ressource is not delayed*/
  90475. static readonly DELAYLOADSTATE_NONE: number;
  90476. /** Defines that the ressource was successfully delay loaded */
  90477. static readonly DELAYLOADSTATE_LOADED: number;
  90478. /** Defines that the ressource is currently delay loading */
  90479. static readonly DELAYLOADSTATE_LOADING: number;
  90480. /** Defines that the ressource is delayed and has not started loading */
  90481. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90482. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90483. static readonly NEVER: number;
  90484. /** 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 */
  90485. static readonly ALWAYS: number;
  90486. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90487. static readonly LESS: number;
  90488. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90489. static readonly EQUAL: number;
  90490. /** 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 */
  90491. static readonly LEQUAL: number;
  90492. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90493. static readonly GREATER: number;
  90494. /** 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 */
  90495. static readonly GEQUAL: number;
  90496. /** 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 */
  90497. static readonly NOTEQUAL: number;
  90498. /** Passed to stencilOperation to specify that stencil value must be kept */
  90499. static readonly KEEP: number;
  90500. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90501. static readonly REPLACE: number;
  90502. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90503. static readonly INCR: number;
  90504. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90505. static readonly DECR: number;
  90506. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90507. static readonly INVERT: number;
  90508. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90509. static readonly INCR_WRAP: number;
  90510. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90511. static readonly DECR_WRAP: number;
  90512. /** Texture is not repeating outside of 0..1 UVs */
  90513. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90514. /** Texture is repeating outside of 0..1 UVs */
  90515. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90516. /** Texture is repeating and mirrored */
  90517. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90518. /** ALPHA */
  90519. static readonly TEXTUREFORMAT_ALPHA: number;
  90520. /** LUMINANCE */
  90521. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90522. /** LUMINANCE_ALPHA */
  90523. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90524. /** RGB */
  90525. static readonly TEXTUREFORMAT_RGB: number;
  90526. /** RGBA */
  90527. static readonly TEXTUREFORMAT_RGBA: number;
  90528. /** RED */
  90529. static readonly TEXTUREFORMAT_RED: number;
  90530. /** RED (2nd reference) */
  90531. static readonly TEXTUREFORMAT_R: number;
  90532. /** RG */
  90533. static readonly TEXTUREFORMAT_RG: number;
  90534. /** RED_INTEGER */
  90535. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90536. /** RED_INTEGER (2nd reference) */
  90537. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90538. /** RG_INTEGER */
  90539. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90540. /** RGB_INTEGER */
  90541. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90542. /** RGBA_INTEGER */
  90543. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90544. /** UNSIGNED_BYTE */
  90545. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90546. /** UNSIGNED_BYTE (2nd reference) */
  90547. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90548. /** FLOAT */
  90549. static readonly TEXTURETYPE_FLOAT: number;
  90550. /** HALF_FLOAT */
  90551. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90552. /** BYTE */
  90553. static readonly TEXTURETYPE_BYTE: number;
  90554. /** SHORT */
  90555. static readonly TEXTURETYPE_SHORT: number;
  90556. /** UNSIGNED_SHORT */
  90557. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90558. /** INT */
  90559. static readonly TEXTURETYPE_INT: number;
  90560. /** UNSIGNED_INT */
  90561. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90562. /** UNSIGNED_SHORT_4_4_4_4 */
  90563. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90564. /** UNSIGNED_SHORT_5_5_5_1 */
  90565. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90566. /** UNSIGNED_SHORT_5_6_5 */
  90567. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90568. /** UNSIGNED_INT_2_10_10_10_REV */
  90569. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90570. /** UNSIGNED_INT_24_8 */
  90571. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90572. /** UNSIGNED_INT_10F_11F_11F_REV */
  90573. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90574. /** UNSIGNED_INT_5_9_9_9_REV */
  90575. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90576. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90577. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90578. /** nearest is mag = nearest and min = nearest and mip = linear */
  90579. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90580. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90581. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90582. /** Trilinear is mag = linear and min = linear and mip = linear */
  90583. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90584. /** nearest is mag = nearest and min = nearest and mip = linear */
  90585. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90586. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90587. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90588. /** Trilinear is mag = linear and min = linear and mip = linear */
  90589. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90590. /** mag = nearest and min = nearest and mip = nearest */
  90591. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90592. /** mag = nearest and min = linear and mip = nearest */
  90593. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90594. /** mag = nearest and min = linear and mip = linear */
  90595. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90596. /** mag = nearest and min = linear and mip = none */
  90597. static readonly TEXTURE_NEAREST_LINEAR: number;
  90598. /** mag = nearest and min = nearest and mip = none */
  90599. static readonly TEXTURE_NEAREST_NEAREST: number;
  90600. /** mag = linear and min = nearest and mip = nearest */
  90601. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90602. /** mag = linear and min = nearest and mip = linear */
  90603. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90604. /** mag = linear and min = linear and mip = none */
  90605. static readonly TEXTURE_LINEAR_LINEAR: number;
  90606. /** mag = linear and min = nearest and mip = none */
  90607. static readonly TEXTURE_LINEAR_NEAREST: number;
  90608. /** Explicit coordinates mode */
  90609. static readonly TEXTURE_EXPLICIT_MODE: number;
  90610. /** Spherical coordinates mode */
  90611. static readonly TEXTURE_SPHERICAL_MODE: number;
  90612. /** Planar coordinates mode */
  90613. static readonly TEXTURE_PLANAR_MODE: number;
  90614. /** Cubic coordinates mode */
  90615. static readonly TEXTURE_CUBIC_MODE: number;
  90616. /** Projection coordinates mode */
  90617. static readonly TEXTURE_PROJECTION_MODE: number;
  90618. /** Skybox coordinates mode */
  90619. static readonly TEXTURE_SKYBOX_MODE: number;
  90620. /** Inverse Cubic coordinates mode */
  90621. static readonly TEXTURE_INVCUBIC_MODE: number;
  90622. /** Equirectangular coordinates mode */
  90623. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90624. /** Equirectangular Fixed coordinates mode */
  90625. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90626. /** Equirectangular Fixed Mirrored coordinates mode */
  90627. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90628. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90629. static readonly SCALEMODE_FLOOR: number;
  90630. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90631. static readonly SCALEMODE_NEAREST: number;
  90632. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90633. static readonly SCALEMODE_CEILING: number;
  90634. /**
  90635. * Returns the current npm package of the sdk
  90636. */
  90637. static readonly NpmPackage: string;
  90638. /**
  90639. * Returns the current version of the framework
  90640. */
  90641. static readonly Version: string;
  90642. /**
  90643. * Returns a string describing the current engine
  90644. */
  90645. readonly description: string;
  90646. /**
  90647. * Gets or sets the epsilon value used by collision engine
  90648. */
  90649. static CollisionsEpsilon: number;
  90650. /**
  90651. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90652. */
  90653. static ShadersRepository: string;
  90654. /**
  90655. * Method called to create the default loading screen.
  90656. * This can be overriden in your own app.
  90657. * @param canvas The rendering canvas element
  90658. * @returns The loading screen
  90659. */
  90660. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90661. /**
  90662. * Method called to create the default rescale post process on each engine.
  90663. */
  90664. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90665. /** @hidden */
  90666. _shaderProcessor: IShaderProcessor;
  90667. /**
  90668. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90669. */
  90670. forcePOTTextures: boolean;
  90671. /**
  90672. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90673. */
  90674. isFullscreen: boolean;
  90675. /**
  90676. * Gets a boolean indicating if the pointer is currently locked
  90677. */
  90678. isPointerLock: boolean;
  90679. /**
  90680. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90681. */
  90682. cullBackFaces: boolean;
  90683. /**
  90684. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90685. */
  90686. renderEvenInBackground: boolean;
  90687. /**
  90688. * Gets or sets a boolean indicating that cache can be kept between frames
  90689. */
  90690. preventCacheWipeBetweenFrames: boolean;
  90691. /**
  90692. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90693. **/
  90694. enableOfflineSupport: boolean;
  90695. /**
  90696. * 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)
  90697. **/
  90698. disableManifestCheck: boolean;
  90699. /**
  90700. * Gets the list of created scenes
  90701. */
  90702. scenes: Scene[];
  90703. /**
  90704. * Event raised when a new scene is created
  90705. */
  90706. onNewSceneAddedObservable: Observable<Scene>;
  90707. /**
  90708. * Gets the list of created postprocesses
  90709. */
  90710. postProcesses: PostProcess[];
  90711. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90712. validateShaderPrograms: boolean;
  90713. /**
  90714. * Observable event triggered each time the rendering canvas is resized
  90715. */
  90716. onResizeObservable: Observable<Engine>;
  90717. /**
  90718. * Observable event triggered each time the canvas loses focus
  90719. */
  90720. onCanvasBlurObservable: Observable<Engine>;
  90721. /**
  90722. * Observable event triggered each time the canvas gains focus
  90723. */
  90724. onCanvasFocusObservable: Observable<Engine>;
  90725. /**
  90726. * Observable event triggered each time the canvas receives pointerout event
  90727. */
  90728. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90729. /**
  90730. * Observable event triggered before each texture is initialized
  90731. */
  90732. onBeforeTextureInitObservable: Observable<Texture>;
  90733. /**
  90734. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90735. */
  90736. disableUniformBuffers: boolean;
  90737. /** @hidden */
  90738. _uniformBuffers: UniformBuffer[];
  90739. /**
  90740. * Gets a boolean indicating that the engine supports uniform buffers
  90741. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90742. */
  90743. readonly supportsUniformBuffers: boolean;
  90744. /**
  90745. * Observable raised when the engine begins a new frame
  90746. */
  90747. onBeginFrameObservable: Observable<Engine>;
  90748. /**
  90749. * If set, will be used to request the next animation frame for the render loop
  90750. */
  90751. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90752. /**
  90753. * Observable raised when the engine ends the current frame
  90754. */
  90755. onEndFrameObservable: Observable<Engine>;
  90756. /**
  90757. * Observable raised when the engine is about to compile a shader
  90758. */
  90759. onBeforeShaderCompilationObservable: Observable<Engine>;
  90760. /**
  90761. * Observable raised when the engine has jsut compiled a shader
  90762. */
  90763. onAfterShaderCompilationObservable: Observable<Engine>;
  90764. /** @hidden */
  90765. _gl: WebGLRenderingContext;
  90766. private _renderingCanvas;
  90767. private _windowIsBackground;
  90768. private _webGLVersion;
  90769. protected _highPrecisionShadersAllowed: boolean;
  90770. /** @hidden */
  90771. readonly _shouldUseHighPrecisionShader: boolean;
  90772. /**
  90773. * Gets a boolean indicating that only power of 2 textures are supported
  90774. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90775. */
  90776. readonly needPOTTextures: boolean;
  90777. /** @hidden */
  90778. _badOS: boolean;
  90779. /** @hidden */
  90780. _badDesktopOS: boolean;
  90781. /**
  90782. * Gets the audio engine
  90783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90784. * @ignorenaming
  90785. */
  90786. static audioEngine: IAudioEngine;
  90787. /**
  90788. * Default AudioEngine factory responsible of creating the Audio Engine.
  90789. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90790. */
  90791. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90792. /**
  90793. * Default offline support factory responsible of creating a tool used to store data locally.
  90794. * By default, this will create a Database object if the workload has been embedded.
  90795. */
  90796. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90797. private _onFocus;
  90798. private _onBlur;
  90799. private _onCanvasPointerOut;
  90800. private _onCanvasBlur;
  90801. private _onCanvasFocus;
  90802. private _onFullscreenChange;
  90803. private _onPointerLockChange;
  90804. private _hardwareScalingLevel;
  90805. /** @hidden */
  90806. _caps: EngineCapabilities;
  90807. private _pointerLockRequested;
  90808. private _isStencilEnable;
  90809. private _colorWrite;
  90810. private _loadingScreen;
  90811. /** @hidden */
  90812. _drawCalls: PerfCounter;
  90813. private _glVersion;
  90814. private _glRenderer;
  90815. private _glVendor;
  90816. private _videoTextureSupported;
  90817. private _renderingQueueLaunched;
  90818. private _activeRenderLoops;
  90819. private _deterministicLockstep;
  90820. private _lockstepMaxSteps;
  90821. /**
  90822. * Observable signaled when a context lost event is raised
  90823. */
  90824. onContextLostObservable: Observable<Engine>;
  90825. /**
  90826. * Observable signaled when a context restored event is raised
  90827. */
  90828. onContextRestoredObservable: Observable<Engine>;
  90829. private _onContextLost;
  90830. private _onContextRestored;
  90831. private _contextWasLost;
  90832. /** @hidden */
  90833. _doNotHandleContextLost: boolean;
  90834. /**
  90835. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90836. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90837. */
  90838. doNotHandleContextLost: boolean;
  90839. private _performanceMonitor;
  90840. private _fps;
  90841. private _deltaTime;
  90842. /**
  90843. * Turn this value on if you want to pause FPS computation when in background
  90844. */
  90845. disablePerformanceMonitorInBackground: boolean;
  90846. /**
  90847. * Gets the performance monitor attached to this engine
  90848. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90849. */
  90850. readonly performanceMonitor: PerformanceMonitor;
  90851. /**
  90852. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90853. */
  90854. disableVertexArrayObjects: boolean;
  90855. /** @hidden */
  90856. protected _depthCullingState: _DepthCullingState;
  90857. /** @hidden */
  90858. protected _stencilState: _StencilState;
  90859. /** @hidden */
  90860. protected _alphaState: _AlphaState;
  90861. /** @hidden */
  90862. protected _alphaMode: number;
  90863. /** @hidden */
  90864. _internalTexturesCache: InternalTexture[];
  90865. /** @hidden */
  90866. protected _activeChannel: number;
  90867. private _currentTextureChannel;
  90868. /** @hidden */
  90869. protected _boundTexturesCache: {
  90870. [key: string]: Nullable<InternalTexture>;
  90871. };
  90872. /** @hidden */
  90873. protected _currentEffect: Nullable<Effect>;
  90874. /** @hidden */
  90875. protected _currentProgram: Nullable<WebGLProgram>;
  90876. private _compiledEffects;
  90877. private _vertexAttribArraysEnabled;
  90878. /** @hidden */
  90879. protected _cachedViewport: Nullable<Viewport>;
  90880. private _cachedVertexArrayObject;
  90881. /** @hidden */
  90882. protected _cachedVertexBuffers: any;
  90883. /** @hidden */
  90884. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90885. /** @hidden */
  90886. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90887. /** @hidden */
  90888. _currentRenderTarget: Nullable<InternalTexture>;
  90889. private _uintIndicesCurrentlySet;
  90890. private _currentBoundBuffer;
  90891. /** @hidden */
  90892. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90893. private _currentBufferPointers;
  90894. private _currentInstanceLocations;
  90895. private _currentInstanceBuffers;
  90896. private _textureUnits;
  90897. /** @hidden */
  90898. _workingCanvas: Nullable<HTMLCanvasElement>;
  90899. /** @hidden */
  90900. _workingContext: Nullable<CanvasRenderingContext2D>;
  90901. private _rescalePostProcess;
  90902. private _dummyFramebuffer;
  90903. private _externalData;
  90904. /** @hidden */
  90905. _bindedRenderFunction: any;
  90906. private _vaoRecordInProgress;
  90907. private _mustWipeVertexAttributes;
  90908. private _emptyTexture;
  90909. private _emptyCubeTexture;
  90910. private _emptyTexture3D;
  90911. /** @hidden */
  90912. _frameHandler: number;
  90913. private _nextFreeTextureSlots;
  90914. private _maxSimultaneousTextures;
  90915. private _activeRequests;
  90916. private _texturesSupported;
  90917. /** @hidden */
  90918. _textureFormatInUse: Nullable<string>;
  90919. /**
  90920. * Gets the list of texture formats supported
  90921. */
  90922. readonly texturesSupported: Array<string>;
  90923. /**
  90924. * Gets the list of texture formats in use
  90925. */
  90926. readonly textureFormatInUse: Nullable<string>;
  90927. /**
  90928. * Gets the current viewport
  90929. */
  90930. readonly currentViewport: Nullable<Viewport>;
  90931. /**
  90932. * Gets the default empty texture
  90933. */
  90934. readonly emptyTexture: InternalTexture;
  90935. /**
  90936. * Gets the default empty 3D texture
  90937. */
  90938. readonly emptyTexture3D: InternalTexture;
  90939. /**
  90940. * Gets the default empty cube texture
  90941. */
  90942. readonly emptyCubeTexture: InternalTexture;
  90943. /**
  90944. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90945. */
  90946. readonly premultipliedAlpha: boolean;
  90947. /**
  90948. * Creates a new engine
  90949. * @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
  90950. * @param antialias defines enable antialiasing (default: false)
  90951. * @param options defines further options to be sent to the getContext() function
  90952. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90953. */
  90954. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90955. /**
  90956. * Initializes a webVR display and starts listening to display change events
  90957. * The onVRDisplayChangedObservable will be notified upon these changes
  90958. * @returns The onVRDisplayChangedObservable
  90959. */
  90960. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90961. /** @hidden */
  90962. _prepareVRComponent(): void;
  90963. /** @hidden */
  90964. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90965. /** @hidden */
  90966. _submitVRFrame(): void;
  90967. /**
  90968. * Call this function to leave webVR mode
  90969. * Will do nothing if webVR is not supported or if there is no webVR device
  90970. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90971. */
  90972. disableVR(): void;
  90973. /**
  90974. * Gets a boolean indicating that the system is in VR mode and is presenting
  90975. * @returns true if VR mode is engaged
  90976. */
  90977. isVRPresenting(): boolean;
  90978. /** @hidden */
  90979. _requestVRFrame(): void;
  90980. private _disableTouchAction;
  90981. private _rebuildInternalTextures;
  90982. private _rebuildEffects;
  90983. /**
  90984. * Gets a boolean indicating if all created effects are ready
  90985. * @returns true if all effects are ready
  90986. */
  90987. areAllEffectsReady(): boolean;
  90988. private _rebuildBuffers;
  90989. private _initGLContext;
  90990. /**
  90991. * Gets version of the current webGL context
  90992. */
  90993. readonly webGLVersion: number;
  90994. /**
  90995. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90996. */
  90997. readonly isStencilEnable: boolean;
  90998. /** @hidden */
  90999. _prepareWorkingCanvas(): void;
  91000. /**
  91001. * Reset the texture cache to empty state
  91002. */
  91003. resetTextureCache(): void;
  91004. /**
  91005. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  91006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91007. * @returns true if engine is in deterministic lock step mode
  91008. */
  91009. isDeterministicLockStep(): boolean;
  91010. /**
  91011. * Gets the max steps when engine is running in deterministic lock step
  91012. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91013. * @returns the max steps
  91014. */
  91015. getLockstepMaxSteps(): number;
  91016. /**
  91017. * Gets an object containing information about the current webGL context
  91018. * @returns an object containing the vender, the renderer and the version of the current webGL context
  91019. */
  91020. getGlInfo(): {
  91021. vendor: string;
  91022. renderer: string;
  91023. version: string;
  91024. };
  91025. /**
  91026. * Gets current aspect ratio
  91027. * @param camera defines the camera to use to get the aspect ratio
  91028. * @param useScreen defines if screen size must be used (or the current render target if any)
  91029. * @returns a number defining the aspect ratio
  91030. */
  91031. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  91032. /**
  91033. * Gets current screen aspect ratio
  91034. * @returns a number defining the aspect ratio
  91035. */
  91036. getScreenAspectRatio(): number;
  91037. /**
  91038. * Gets the current render width
  91039. * @param useScreen defines if screen size must be used (or the current render target if any)
  91040. * @returns a number defining the current render width
  91041. */
  91042. getRenderWidth(useScreen?: boolean): number;
  91043. /**
  91044. * Gets the current render height
  91045. * @param useScreen defines if screen size must be used (or the current render target if any)
  91046. * @returns a number defining the current render height
  91047. */
  91048. getRenderHeight(useScreen?: boolean): number;
  91049. /**
  91050. * Gets the HTML canvas attached with the current webGL context
  91051. * @returns a HTML canvas
  91052. */
  91053. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  91054. /**
  91055. * Gets the client rect of the HTML canvas attached with the current webGL context
  91056. * @returns a client rectanglee
  91057. */
  91058. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  91059. /**
  91060. * Defines the hardware scaling level.
  91061. * By default the hardware scaling level is computed from the window device ratio.
  91062. * 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.
  91063. * @param level defines the level to use
  91064. */
  91065. setHardwareScalingLevel(level: number): void;
  91066. /**
  91067. * Gets the current hardware scaling level.
  91068. * By default the hardware scaling level is computed from the window device ratio.
  91069. * 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.
  91070. * @returns a number indicating the current hardware scaling level
  91071. */
  91072. getHardwareScalingLevel(): number;
  91073. /**
  91074. * Gets the list of loaded textures
  91075. * @returns an array containing all loaded textures
  91076. */
  91077. getLoadedTexturesCache(): InternalTexture[];
  91078. /**
  91079. * Gets the object containing all engine capabilities
  91080. * @returns the EngineCapabilities object
  91081. */
  91082. getCaps(): EngineCapabilities;
  91083. /**
  91084. * Gets the current depth function
  91085. * @returns a number defining the depth function
  91086. */
  91087. getDepthFunction(): Nullable<number>;
  91088. /**
  91089. * Sets the current depth function
  91090. * @param depthFunc defines the function to use
  91091. */
  91092. setDepthFunction(depthFunc: number): void;
  91093. /**
  91094. * Sets the current depth function to GREATER
  91095. */
  91096. setDepthFunctionToGreater(): void;
  91097. /**
  91098. * Sets the current depth function to GEQUAL
  91099. */
  91100. setDepthFunctionToGreaterOrEqual(): void;
  91101. /**
  91102. * Sets the current depth function to LESS
  91103. */
  91104. setDepthFunctionToLess(): void;
  91105. private _cachedStencilBuffer;
  91106. private _cachedStencilFunction;
  91107. private _cachedStencilMask;
  91108. private _cachedStencilOperationPass;
  91109. private _cachedStencilOperationFail;
  91110. private _cachedStencilOperationDepthFail;
  91111. private _cachedStencilReference;
  91112. /**
  91113. * Caches the the state of the stencil buffer
  91114. */
  91115. cacheStencilState(): void;
  91116. /**
  91117. * Restores the state of the stencil buffer
  91118. */
  91119. restoreStencilState(): void;
  91120. /**
  91121. * Sets the current depth function to LEQUAL
  91122. */
  91123. setDepthFunctionToLessOrEqual(): void;
  91124. /**
  91125. * Gets a boolean indicating if stencil buffer is enabled
  91126. * @returns the current stencil buffer state
  91127. */
  91128. getStencilBuffer(): boolean;
  91129. /**
  91130. * Enable or disable the stencil buffer
  91131. * @param enable defines if the stencil buffer must be enabled or disabled
  91132. */
  91133. setStencilBuffer(enable: boolean): void;
  91134. /**
  91135. * Gets the current stencil mask
  91136. * @returns a number defining the new stencil mask to use
  91137. */
  91138. getStencilMask(): number;
  91139. /**
  91140. * Sets the current stencil mask
  91141. * @param mask defines the new stencil mask to use
  91142. */
  91143. setStencilMask(mask: number): void;
  91144. /**
  91145. * Gets the current stencil function
  91146. * @returns a number defining the stencil function to use
  91147. */
  91148. getStencilFunction(): number;
  91149. /**
  91150. * Gets the current stencil reference value
  91151. * @returns a number defining the stencil reference value to use
  91152. */
  91153. getStencilFunctionReference(): number;
  91154. /**
  91155. * Gets the current stencil mask
  91156. * @returns a number defining the stencil mask to use
  91157. */
  91158. getStencilFunctionMask(): number;
  91159. /**
  91160. * Sets the current stencil function
  91161. * @param stencilFunc defines the new stencil function to use
  91162. */
  91163. setStencilFunction(stencilFunc: number): void;
  91164. /**
  91165. * Sets the current stencil reference
  91166. * @param reference defines the new stencil reference to use
  91167. */
  91168. setStencilFunctionReference(reference: number): void;
  91169. /**
  91170. * Sets the current stencil mask
  91171. * @param mask defines the new stencil mask to use
  91172. */
  91173. setStencilFunctionMask(mask: number): void;
  91174. /**
  91175. * Gets the current stencil operation when stencil fails
  91176. * @returns a number defining stencil operation to use when stencil fails
  91177. */
  91178. getStencilOperationFail(): number;
  91179. /**
  91180. * Gets the current stencil operation when depth fails
  91181. * @returns a number defining stencil operation to use when depth fails
  91182. */
  91183. getStencilOperationDepthFail(): number;
  91184. /**
  91185. * Gets the current stencil operation when stencil passes
  91186. * @returns a number defining stencil operation to use when stencil passes
  91187. */
  91188. getStencilOperationPass(): number;
  91189. /**
  91190. * Sets the stencil operation to use when stencil fails
  91191. * @param operation defines the stencil operation to use when stencil fails
  91192. */
  91193. setStencilOperationFail(operation: number): void;
  91194. /**
  91195. * Sets the stencil operation to use when depth fails
  91196. * @param operation defines the stencil operation to use when depth fails
  91197. */
  91198. setStencilOperationDepthFail(operation: number): void;
  91199. /**
  91200. * Sets the stencil operation to use when stencil passes
  91201. * @param operation defines the stencil operation to use when stencil passes
  91202. */
  91203. setStencilOperationPass(operation: number): void;
  91204. /**
  91205. * Sets a boolean indicating if the dithering state is enabled or disabled
  91206. * @param value defines the dithering state
  91207. */
  91208. setDitheringState(value: boolean): void;
  91209. /**
  91210. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  91211. * @param value defines the rasterizer state
  91212. */
  91213. setRasterizerState(value: boolean): void;
  91214. /**
  91215. * stop executing a render loop function and remove it from the execution array
  91216. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  91217. */
  91218. stopRenderLoop(renderFunction?: () => void): void;
  91219. /** @hidden */
  91220. _renderLoop(): void;
  91221. /**
  91222. * Register and execute a render loop. The engine can have more than one render function
  91223. * @param renderFunction defines the function to continuously execute
  91224. */
  91225. runRenderLoop(renderFunction: () => void): void;
  91226. /**
  91227. * Toggle full screen mode
  91228. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91229. */
  91230. switchFullscreen(requestPointerLock: boolean): void;
  91231. /**
  91232. * Enters full screen mode
  91233. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91234. */
  91235. enterFullscreen(requestPointerLock: boolean): void;
  91236. /**
  91237. * Exits full screen mode
  91238. */
  91239. exitFullscreen(): void;
  91240. /**
  91241. * Enters Pointerlock mode
  91242. */
  91243. enterPointerlock(): void;
  91244. /**
  91245. * Exits Pointerlock mode
  91246. */
  91247. exitPointerlock(): void;
  91248. /**
  91249. * Clear the current render buffer or the current render target (if any is set up)
  91250. * @param color defines the color to use
  91251. * @param backBuffer defines if the back buffer must be cleared
  91252. * @param depth defines if the depth buffer must be cleared
  91253. * @param stencil defines if the stencil buffer must be cleared
  91254. */
  91255. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  91256. /**
  91257. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  91258. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91259. * @param y defines the y-coordinate of the corner of the clear rectangle
  91260. * @param width defines the width of the clear rectangle
  91261. * @param height defines the height of the clear rectangle
  91262. * @param clearColor defines the clear color
  91263. */
  91264. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  91265. /**
  91266. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  91267. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91268. * @param y defines the y-coordinate of the corner of the clear rectangle
  91269. * @param width defines the width of the clear rectangle
  91270. * @param height defines the height of the clear rectangle
  91271. */
  91272. enableScissor(x: number, y: number, width: number, height: number): void;
  91273. /**
  91274. * Disable previously set scissor test rectangle
  91275. */
  91276. disableScissor(): void;
  91277. private _viewportCached;
  91278. /** @hidden */
  91279. _viewport(x: number, y: number, width: number, height: number): void;
  91280. /**
  91281. * Set the WebGL's viewport
  91282. * @param viewport defines the viewport element to be used
  91283. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  91284. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  91285. */
  91286. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  91287. /**
  91288. * Directly set the WebGL Viewport
  91289. * @param x defines the x coordinate of the viewport (in screen space)
  91290. * @param y defines the y coordinate of the viewport (in screen space)
  91291. * @param width defines the width of the viewport (in screen space)
  91292. * @param height defines the height of the viewport (in screen space)
  91293. * @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
  91294. */
  91295. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  91296. /**
  91297. * Begin a new frame
  91298. */
  91299. beginFrame(): void;
  91300. /**
  91301. * Enf the current frame
  91302. */
  91303. endFrame(): void;
  91304. /**
  91305. * Resize the view according to the canvas' size
  91306. */
  91307. resize(): void;
  91308. /**
  91309. * Force a specific size of the canvas
  91310. * @param width defines the new canvas' width
  91311. * @param height defines the new canvas' height
  91312. */
  91313. setSize(width: number, height: number): void;
  91314. /**
  91315. * Binds the frame buffer to the specified texture.
  91316. * @param texture The texture to render to or null for the default canvas
  91317. * @param faceIndex The face of the texture to render to in case of cube texture
  91318. * @param requiredWidth The width of the target to render to
  91319. * @param requiredHeight The height of the target to render to
  91320. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  91321. * @param depthStencilTexture The depth stencil texture to use to render
  91322. * @param lodLevel defines le lod level to bind to the frame buffer
  91323. */
  91324. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  91325. /** @hidden */
  91326. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  91327. /**
  91328. * Unbind the current render target texture from the webGL context
  91329. * @param texture defines the render target texture to unbind
  91330. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  91331. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  91332. */
  91333. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  91334. /**
  91335. * Force the mipmap generation for the given render target texture
  91336. * @param texture defines the render target texture to use
  91337. */
  91338. generateMipMapsForCubemap(texture: InternalTexture): void;
  91339. /**
  91340. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  91341. */
  91342. flushFramebuffer(): void;
  91343. /**
  91344. * Unbind the current render target and bind the default framebuffer
  91345. */
  91346. restoreDefaultFramebuffer(): void;
  91347. /**
  91348. * Create an uniform buffer
  91349. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91350. * @param elements defines the content of the uniform buffer
  91351. * @returns the webGL uniform buffer
  91352. */
  91353. createUniformBuffer(elements: FloatArray): DataBuffer;
  91354. /**
  91355. * Create a dynamic uniform buffer
  91356. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91357. * @param elements defines the content of the uniform buffer
  91358. * @returns the webGL uniform buffer
  91359. */
  91360. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91361. /**
  91362. * Update an existing uniform buffer
  91363. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91364. * @param uniformBuffer defines the target uniform buffer
  91365. * @param elements defines the content to update
  91366. * @param offset defines the offset in the uniform buffer where update should start
  91367. * @param count defines the size of the data to update
  91368. */
  91369. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91370. private _resetVertexBufferBinding;
  91371. /**
  91372. * Creates a vertex buffer
  91373. * @param data the data for the vertex buffer
  91374. * @returns the new WebGL static buffer
  91375. */
  91376. createVertexBuffer(data: DataArray): DataBuffer;
  91377. /**
  91378. * Creates a dynamic vertex buffer
  91379. * @param data the data for the dynamic vertex buffer
  91380. * @returns the new WebGL dynamic buffer
  91381. */
  91382. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91383. /**
  91384. * Update a dynamic index buffer
  91385. * @param indexBuffer defines the target index buffer
  91386. * @param indices defines the data to update
  91387. * @param offset defines the offset in the target index buffer where update should start
  91388. */
  91389. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91390. /**
  91391. * Updates a dynamic vertex buffer.
  91392. * @param vertexBuffer the vertex buffer to update
  91393. * @param data the data used to update the vertex buffer
  91394. * @param byteOffset the byte offset of the data
  91395. * @param byteLength the byte length of the data
  91396. */
  91397. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91398. private _resetIndexBufferBinding;
  91399. /**
  91400. * Creates a new index buffer
  91401. * @param indices defines the content of the index buffer
  91402. * @param updatable defines if the index buffer must be updatable
  91403. * @returns a new webGL buffer
  91404. */
  91405. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91406. /**
  91407. * Bind a webGL buffer to the webGL context
  91408. * @param buffer defines the buffer to bind
  91409. */
  91410. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91411. /**
  91412. * Bind an uniform buffer to the current webGL context
  91413. * @param buffer defines the buffer to bind
  91414. */
  91415. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91416. /**
  91417. * Bind a buffer to the current webGL context at a given location
  91418. * @param buffer defines the buffer to bind
  91419. * @param location defines the index where to bind the buffer
  91420. */
  91421. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91422. /**
  91423. * Bind a specific block at a given index in a specific shader program
  91424. * @param pipelineContext defines the pipeline context to use
  91425. * @param blockName defines the block name
  91426. * @param index defines the index where to bind the block
  91427. */
  91428. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91429. private bindIndexBuffer;
  91430. private bindBuffer;
  91431. /**
  91432. * update the bound buffer with the given data
  91433. * @param data defines the data to update
  91434. */
  91435. updateArrayBuffer(data: Float32Array): void;
  91436. private _vertexAttribPointer;
  91437. private _bindIndexBufferWithCache;
  91438. private _bindVertexBuffersAttributes;
  91439. /**
  91440. * Records a vertex array object
  91441. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91442. * @param vertexBuffers defines the list of vertex buffers to store
  91443. * @param indexBuffer defines the index buffer to store
  91444. * @param effect defines the effect to store
  91445. * @returns the new vertex array object
  91446. */
  91447. recordVertexArrayObject(vertexBuffers: {
  91448. [key: string]: VertexBuffer;
  91449. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91450. /**
  91451. * Bind a specific vertex array object
  91452. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91453. * @param vertexArrayObject defines the vertex array object to bind
  91454. * @param indexBuffer defines the index buffer to bind
  91455. */
  91456. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91457. /**
  91458. * Bind webGl buffers directly to the webGL context
  91459. * @param vertexBuffer defines the vertex buffer to bind
  91460. * @param indexBuffer defines the index buffer to bind
  91461. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91462. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91463. * @param effect defines the effect associated with the vertex buffer
  91464. */
  91465. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91466. private _unbindVertexArrayObject;
  91467. /**
  91468. * Bind a list of vertex buffers to the webGL context
  91469. * @param vertexBuffers defines the list of vertex buffers to bind
  91470. * @param indexBuffer defines the index buffer to bind
  91471. * @param effect defines the effect associated with the vertex buffers
  91472. */
  91473. bindBuffers(vertexBuffers: {
  91474. [key: string]: Nullable<VertexBuffer>;
  91475. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91476. /**
  91477. * Unbind all instance attributes
  91478. */
  91479. unbindInstanceAttributes(): void;
  91480. /**
  91481. * Release and free the memory of a vertex array object
  91482. * @param vao defines the vertex array object to delete
  91483. */
  91484. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91485. /** @hidden */
  91486. _releaseBuffer(buffer: DataBuffer): boolean;
  91487. /**
  91488. * Creates a webGL buffer to use with instanciation
  91489. * @param capacity defines the size of the buffer
  91490. * @returns the webGL buffer
  91491. */
  91492. createInstancesBuffer(capacity: number): DataBuffer;
  91493. /**
  91494. * Delete a webGL buffer used with instanciation
  91495. * @param buffer defines the webGL buffer to delete
  91496. */
  91497. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91498. /**
  91499. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91500. * @param instancesBuffer defines the webGL buffer to update and bind
  91501. * @param data defines the data to store in the buffer
  91502. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91503. */
  91504. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91505. /**
  91506. * Apply all cached states (depth, culling, stencil and alpha)
  91507. */
  91508. applyStates(): void;
  91509. /**
  91510. * Send a draw order
  91511. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91512. * @param indexStart defines the starting index
  91513. * @param indexCount defines the number of index to draw
  91514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91515. */
  91516. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91517. /**
  91518. * Draw a list of points
  91519. * @param verticesStart defines the index of first vertex to draw
  91520. * @param verticesCount defines the count of vertices to draw
  91521. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91522. */
  91523. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91524. /**
  91525. * Draw a list of unindexed primitives
  91526. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91527. * @param verticesStart defines the index of first vertex to draw
  91528. * @param verticesCount defines the count of vertices to draw
  91529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91530. */
  91531. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91532. /**
  91533. * Draw a list of indexed primitives
  91534. * @param fillMode defines the primitive to use
  91535. * @param indexStart defines the starting index
  91536. * @param indexCount defines the number of index to draw
  91537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91538. */
  91539. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91540. /**
  91541. * Draw a list of unindexed primitives
  91542. * @param fillMode defines the primitive to use
  91543. * @param verticesStart defines the index of first vertex to draw
  91544. * @param verticesCount defines the count of vertices to draw
  91545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91546. */
  91547. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91548. private _drawMode;
  91549. /** @hidden */
  91550. _releaseEffect(effect: Effect): void;
  91551. /** @hidden */
  91552. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91553. /**
  91554. * Create a new effect (used to store vertex/fragment shaders)
  91555. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91556. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91557. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91558. * @param samplers defines an array of string used to represent textures
  91559. * @param defines defines the string containing the defines to use to compile the shaders
  91560. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91561. * @param onCompiled defines a function to call when the effect creation is successful
  91562. * @param onError defines a function to call when the effect creation has failed
  91563. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91564. * @returns the new Effect
  91565. */
  91566. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  91567. private _compileShader;
  91568. private _compileRawShader;
  91569. /**
  91570. * Directly creates a webGL program
  91571. * @param pipelineContext defines the pipeline context to attach to
  91572. * @param vertexCode defines the vertex shader code to use
  91573. * @param fragmentCode defines the fragment shader code to use
  91574. * @param context defines the webGL context to use (if not set, the current one will be used)
  91575. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91576. * @returns the new webGL program
  91577. */
  91578. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91579. /**
  91580. * Creates a webGL program
  91581. * @param pipelineContext defines the pipeline context to attach to
  91582. * @param vertexCode defines the vertex shader code to use
  91583. * @param fragmentCode defines the fragment shader code to use
  91584. * @param defines defines the string containing the defines to use to compile the shaders
  91585. * @param context defines the webGL context to use (if not set, the current one will be used)
  91586. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91587. * @returns the new webGL program
  91588. */
  91589. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91590. /**
  91591. * Creates a new pipeline context
  91592. * @returns the new pipeline
  91593. */
  91594. createPipelineContext(): WebGLPipelineContext;
  91595. private _createShaderProgram;
  91596. private _finalizePipelineContext;
  91597. /** @hidden */
  91598. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91599. /** @hidden */
  91600. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91601. /** @hidden */
  91602. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91603. /**
  91604. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91605. * @param pipelineContext defines the pipeline context to use
  91606. * @param uniformsNames defines the list of uniform names
  91607. * @returns an array of webGL uniform locations
  91608. */
  91609. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91610. /**
  91611. * Gets the lsit of active attributes for a given webGL program
  91612. * @param pipelineContext defines the pipeline context to use
  91613. * @param attributesNames defines the list of attribute names to get
  91614. * @returns an array of indices indicating the offset of each attribute
  91615. */
  91616. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91617. /**
  91618. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91619. * @param effect defines the effect to activate
  91620. */
  91621. enableEffect(effect: Nullable<Effect>): void;
  91622. /**
  91623. * Set the value of an uniform to an array of int32
  91624. * @param uniform defines the webGL uniform location where to store the value
  91625. * @param array defines the array of int32 to store
  91626. */
  91627. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91628. /**
  91629. * Set the value of an uniform to an array of int32 (stored as vec2)
  91630. * @param uniform defines the webGL uniform location where to store the value
  91631. * @param array defines the array of int32 to store
  91632. */
  91633. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91634. /**
  91635. * Set the value of an uniform to an array of int32 (stored as vec3)
  91636. * @param uniform defines the webGL uniform location where to store the value
  91637. * @param array defines the array of int32 to store
  91638. */
  91639. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91640. /**
  91641. * Set the value of an uniform to an array of int32 (stored as vec4)
  91642. * @param uniform defines the webGL uniform location where to store the value
  91643. * @param array defines the array of int32 to store
  91644. */
  91645. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91646. /**
  91647. * Set the value of an uniform to an array of float32
  91648. * @param uniform defines the webGL uniform location where to store the value
  91649. * @param array defines the array of float32 to store
  91650. */
  91651. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91652. /**
  91653. * Set the value of an uniform to an array of float32 (stored as vec2)
  91654. * @param uniform defines the webGL uniform location where to store the value
  91655. * @param array defines the array of float32 to store
  91656. */
  91657. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91658. /**
  91659. * Set the value of an uniform to an array of float32 (stored as vec3)
  91660. * @param uniform defines the webGL uniform location where to store the value
  91661. * @param array defines the array of float32 to store
  91662. */
  91663. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91664. /**
  91665. * Set the value of an uniform to an array of float32 (stored as vec4)
  91666. * @param uniform defines the webGL uniform location where to store the value
  91667. * @param array defines the array of float32 to store
  91668. */
  91669. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91670. /**
  91671. * Set the value of an uniform to an array of number
  91672. * @param uniform defines the webGL uniform location where to store the value
  91673. * @param array defines the array of number to store
  91674. */
  91675. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91676. /**
  91677. * Set the value of an uniform to an array of number (stored as vec2)
  91678. * @param uniform defines the webGL uniform location where to store the value
  91679. * @param array defines the array of number to store
  91680. */
  91681. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91682. /**
  91683. * Set the value of an uniform to an array of number (stored as vec3)
  91684. * @param uniform defines the webGL uniform location where to store the value
  91685. * @param array defines the array of number to store
  91686. */
  91687. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91688. /**
  91689. * Set the value of an uniform to an array of number (stored as vec4)
  91690. * @param uniform defines the webGL uniform location where to store the value
  91691. * @param array defines the array of number to store
  91692. */
  91693. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91694. /**
  91695. * Set the value of an uniform to an array of float32 (stored as matrices)
  91696. * @param uniform defines the webGL uniform location where to store the value
  91697. * @param matrices defines the array of float32 to store
  91698. */
  91699. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91700. /**
  91701. * Set the value of an uniform to a matrix
  91702. * @param uniform defines the webGL uniform location where to store the value
  91703. * @param matrix defines the matrix to store
  91704. */
  91705. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91706. /**
  91707. * Set the value of an uniform to a matrix (3x3)
  91708. * @param uniform defines the webGL uniform location where to store the value
  91709. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91710. */
  91711. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91712. /**
  91713. * Set the value of an uniform to a matrix (2x2)
  91714. * @param uniform defines the webGL uniform location where to store the value
  91715. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91716. */
  91717. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91718. /**
  91719. * Set the value of an uniform to a number (int)
  91720. * @param uniform defines the webGL uniform location where to store the value
  91721. * @param value defines the int number to store
  91722. */
  91723. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91724. /**
  91725. * Set the value of an uniform to a number (float)
  91726. * @param uniform defines the webGL uniform location where to store the value
  91727. * @param value defines the float number to store
  91728. */
  91729. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91730. /**
  91731. * Set the value of an uniform to a vec2
  91732. * @param uniform defines the webGL uniform location where to store the value
  91733. * @param x defines the 1st component of the value
  91734. * @param y defines the 2nd component of the value
  91735. */
  91736. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91737. /**
  91738. * Set the value of an uniform to a vec3
  91739. * @param uniform defines the webGL uniform location where to store the value
  91740. * @param x defines the 1st component of the value
  91741. * @param y defines the 2nd component of the value
  91742. * @param z defines the 3rd component of the value
  91743. */
  91744. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91745. /**
  91746. * Set the value of an uniform to a boolean
  91747. * @param uniform defines the webGL uniform location where to store the value
  91748. * @param bool defines the boolean to store
  91749. */
  91750. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91751. /**
  91752. * Set the value of an uniform to a vec4
  91753. * @param uniform defines the webGL uniform location where to store the value
  91754. * @param x defines the 1st component of the value
  91755. * @param y defines the 2nd component of the value
  91756. * @param z defines the 3rd component of the value
  91757. * @param w defines the 4th component of the value
  91758. */
  91759. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91760. /**
  91761. * Set the value of an uniform to a Color3
  91762. * @param uniform defines the webGL uniform location where to store the value
  91763. * @param color3 defines the color to store
  91764. */
  91765. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91766. /**
  91767. * Set the value of an uniform to a Color3 and an alpha value
  91768. * @param uniform defines the webGL uniform location where to store the value
  91769. * @param color3 defines the color to store
  91770. * @param alpha defines the alpha component to store
  91771. */
  91772. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91773. /**
  91774. * Sets a Color4 on a uniform variable
  91775. * @param uniform defines the uniform location
  91776. * @param color4 defines the value to be set
  91777. */
  91778. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91779. /**
  91780. * Set various states to the webGL context
  91781. * @param culling defines backface culling state
  91782. * @param zOffset defines the value to apply to zOffset (0 by default)
  91783. * @param force defines if states must be applied even if cache is up to date
  91784. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91785. */
  91786. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91787. /**
  91788. * Set the z offset to apply to current rendering
  91789. * @param value defines the offset to apply
  91790. */
  91791. setZOffset(value: number): void;
  91792. /**
  91793. * Gets the current value of the zOffset
  91794. * @returns the current zOffset state
  91795. */
  91796. getZOffset(): number;
  91797. /**
  91798. * Enable or disable depth buffering
  91799. * @param enable defines the state to set
  91800. */
  91801. setDepthBuffer(enable: boolean): void;
  91802. /**
  91803. * Gets a boolean indicating if depth writing is enabled
  91804. * @returns the current depth writing state
  91805. */
  91806. getDepthWrite(): boolean;
  91807. /**
  91808. * Enable or disable depth writing
  91809. * @param enable defines the state to set
  91810. */
  91811. setDepthWrite(enable: boolean): void;
  91812. /**
  91813. * Enable or disable color writing
  91814. * @param enable defines the state to set
  91815. */
  91816. setColorWrite(enable: boolean): void;
  91817. /**
  91818. * Gets a boolean indicating if color writing is enabled
  91819. * @returns the current color writing state
  91820. */
  91821. getColorWrite(): boolean;
  91822. /**
  91823. * Sets alpha constants used by some alpha blending modes
  91824. * @param r defines the red component
  91825. * @param g defines the green component
  91826. * @param b defines the blue component
  91827. * @param a defines the alpha component
  91828. */
  91829. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91830. /**
  91831. * Sets the current alpha mode
  91832. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91833. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91834. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91835. */
  91836. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91837. /**
  91838. * Gets the current alpha mode
  91839. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91840. * @returns the current alpha mode
  91841. */
  91842. getAlphaMode(): number;
  91843. /**
  91844. * Clears the list of texture accessible through engine.
  91845. * This can help preventing texture load conflict due to name collision.
  91846. */
  91847. clearInternalTexturesCache(): void;
  91848. /**
  91849. * Force the entire cache to be cleared
  91850. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91851. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91852. */
  91853. wipeCaches(bruteForce?: boolean): void;
  91854. /**
  91855. * Set the compressed texture format to use, based on the formats you have, and the formats
  91856. * supported by the hardware / browser.
  91857. *
  91858. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91859. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91860. * to API arguments needed to compressed textures. This puts the burden on the container
  91861. * generator to house the arcane code for determining these for current & future formats.
  91862. *
  91863. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91864. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91865. *
  91866. * Note: The result of this call is not taken into account when a texture is base64.
  91867. *
  91868. * @param formatsAvailable defines the list of those format families you have created
  91869. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91870. *
  91871. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91872. * @returns The extension selected.
  91873. */
  91874. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91875. /** @hidden */
  91876. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91877. min: number;
  91878. mag: number;
  91879. };
  91880. /** @hidden */
  91881. _createTexture(): WebGLTexture;
  91882. /**
  91883. * Usually called from Texture.ts.
  91884. * Passed information to create a WebGLTexture
  91885. * @param urlArg defines a value which contains one of the following:
  91886. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91887. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91888. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91889. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91890. * @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)
  91891. * @param scene needed for loading to the correct scene
  91892. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91893. * @param onLoad optional callback to be called upon successful completion
  91894. * @param onError optional callback to be called upon failure
  91895. * @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
  91896. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91897. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91898. * @param forcedExtension defines the extension to use to pick the right loader
  91899. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91900. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91901. */
  91902. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  91903. /**
  91904. * @hidden
  91905. * Rescales a texture
  91906. * @param source input texutre
  91907. * @param destination destination texture
  91908. * @param scene scene to use to render the resize
  91909. * @param internalFormat format to use when resizing
  91910. * @param onComplete callback to be called when resize has completed
  91911. */
  91912. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91913. private _unpackFlipYCached;
  91914. /**
  91915. * In case you are sharing the context with other applications, it might
  91916. * be interested to not cache the unpack flip y state to ensure a consistent
  91917. * value would be set.
  91918. */
  91919. enableUnpackFlipYCached: boolean;
  91920. /** @hidden */
  91921. _unpackFlipY(value: boolean): void;
  91922. /** @hidden */
  91923. _getUnpackAlignement(): number;
  91924. /**
  91925. * Creates a dynamic texture
  91926. * @param width defines the width of the texture
  91927. * @param height defines the height of the texture
  91928. * @param generateMipMaps defines if the engine should generate the mip levels
  91929. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91930. * @returns the dynamic texture inside an InternalTexture
  91931. */
  91932. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91933. /**
  91934. * Update the sampling mode of a given texture
  91935. * @param samplingMode defines the required sampling mode
  91936. * @param texture defines the texture to update
  91937. */
  91938. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91939. /**
  91940. * Update the content of a dynamic texture
  91941. * @param texture defines the texture to update
  91942. * @param canvas defines the canvas containing the source
  91943. * @param invertY defines if data must be stored with Y axis inverted
  91944. * @param premulAlpha defines if alpha is stored as premultiplied
  91945. * @param format defines the format of the data
  91946. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91947. */
  91948. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91949. /**
  91950. * Update a video texture
  91951. * @param texture defines the texture to update
  91952. * @param video defines the video element to use
  91953. * @param invertY defines if data must be stored with Y axis inverted
  91954. */
  91955. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91956. /**
  91957. * Updates a depth texture Comparison Mode and Function.
  91958. * If the comparison Function is equal to 0, the mode will be set to none.
  91959. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91960. * @param texture The texture to set the comparison function for
  91961. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91962. */
  91963. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91964. /** @hidden */
  91965. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91966. width: number;
  91967. height: number;
  91968. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91969. /**
  91970. * Creates a depth stencil texture.
  91971. * This is only available in WebGL 2 or with the depth texture extension available.
  91972. * @param size The size of face edge in the texture.
  91973. * @param options The options defining the texture.
  91974. * @returns The texture
  91975. */
  91976. createDepthStencilTexture(size: number | {
  91977. width: number;
  91978. height: number;
  91979. }, options: DepthTextureCreationOptions): InternalTexture;
  91980. /**
  91981. * Creates a depth stencil texture.
  91982. * This is only available in WebGL 2 or with the depth texture extension available.
  91983. * @param size The size of face edge in the texture.
  91984. * @param options The options defining the texture.
  91985. * @returns The texture
  91986. */
  91987. private _createDepthStencilTexture;
  91988. /**
  91989. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91990. * @param renderTarget The render target to set the frame buffer for
  91991. */
  91992. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91993. /**
  91994. * Creates a new render target texture
  91995. * @param size defines the size of the texture
  91996. * @param options defines the options used to create the texture
  91997. * @returns a new render target texture stored in an InternalTexture
  91998. */
  91999. createRenderTargetTexture(size: number | {
  92000. width: number;
  92001. height: number;
  92002. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  92003. /** @hidden */
  92004. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  92005. /**
  92006. * Updates the sample count of a render target texture
  92007. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  92008. * @param texture defines the texture to update
  92009. * @param samples defines the sample count to set
  92010. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  92011. */
  92012. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  92013. /** @hidden */
  92014. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92015. /** @hidden */
  92016. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  92017. /** @hidden */
  92018. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  92019. /** @hidden */
  92020. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  92021. /**
  92022. * @hidden
  92023. */
  92024. _setCubeMapTextureParams(loadMipmap: boolean): void;
  92025. private _prepareWebGLTextureContinuation;
  92026. private _prepareWebGLTexture;
  92027. /** @hidden */
  92028. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  92029. /** @hidden */
  92030. _releaseFramebufferObjects(texture: InternalTexture): void;
  92031. /** @hidden */
  92032. _releaseTexture(texture: InternalTexture): void;
  92033. private setProgram;
  92034. private _boundUniforms;
  92035. /**
  92036. * Binds an effect to the webGL context
  92037. * @param effect defines the effect to bind
  92038. */
  92039. bindSamplers(effect: Effect): void;
  92040. private _activateCurrentTexture;
  92041. /** @hidden */
  92042. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  92043. /** @hidden */
  92044. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  92045. /**
  92046. * Sets a texture to the webGL context from a postprocess
  92047. * @param channel defines the channel to use
  92048. * @param postProcess defines the source postprocess
  92049. */
  92050. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  92051. /**
  92052. * Binds the output of the passed in post process to the texture channel specified
  92053. * @param channel The channel the texture should be bound to
  92054. * @param postProcess The post process which's output should be bound
  92055. */
  92056. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  92057. /**
  92058. * Unbind all textures from the webGL context
  92059. */
  92060. unbindAllTextures(): void;
  92061. /**
  92062. * Sets a texture to the according uniform.
  92063. * @param channel The texture channel
  92064. * @param uniform The uniform to set
  92065. * @param texture The texture to apply
  92066. */
  92067. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  92068. /**
  92069. * Sets a depth stencil texture from a render target to the according uniform.
  92070. * @param channel The texture channel
  92071. * @param uniform The uniform to set
  92072. * @param texture The render target texture containing the depth stencil texture to apply
  92073. */
  92074. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  92075. private _bindSamplerUniformToChannel;
  92076. private _getTextureWrapMode;
  92077. private _setTexture;
  92078. /**
  92079. * Sets an array of texture to the webGL context
  92080. * @param channel defines the channel where the texture array must be set
  92081. * @param uniform defines the associated uniform location
  92082. * @param textures defines the array of textures to bind
  92083. */
  92084. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  92085. /** @hidden */
  92086. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  92087. private _setTextureParameterFloat;
  92088. private _setTextureParameterInteger;
  92089. /**
  92090. * Reads pixels from the current frame buffer. Please note that this function can be slow
  92091. * @param x defines the x coordinate of the rectangle where pixels must be read
  92092. * @param y defines the y coordinate of the rectangle where pixels must be read
  92093. * @param width defines the width of the rectangle where pixels must be read
  92094. * @param height defines the height of the rectangle where pixels must be read
  92095. * @returns a Uint8Array containing RGBA colors
  92096. */
  92097. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  92098. /**
  92099. * Add an externaly attached data from its key.
  92100. * This method call will fail and return false, if such key already exists.
  92101. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92102. * @param key the unique key that identifies the data
  92103. * @param data the data object to associate to the key for this Engine instance
  92104. * @return true if no such key were already present and the data was added successfully, false otherwise
  92105. */
  92106. addExternalData<T>(key: string, data: T): boolean;
  92107. /**
  92108. * Get an externaly attached data from its key
  92109. * @param key the unique key that identifies the data
  92110. * @return the associated data, if present (can be null), or undefined if not present
  92111. */
  92112. getExternalData<T>(key: string): T;
  92113. /**
  92114. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92115. * @param key the unique key that identifies the data
  92116. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92117. * @return the associated data, can be null if the factory returned null.
  92118. */
  92119. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92120. /**
  92121. * Remove an externaly attached data from the Engine instance
  92122. * @param key the unique key that identifies the data
  92123. * @return true if the data was successfully removed, false if it doesn't exist
  92124. */
  92125. removeExternalData(key: string): boolean;
  92126. /**
  92127. * Unbind all vertex attributes from the webGL context
  92128. */
  92129. unbindAllAttributes(): void;
  92130. /**
  92131. * 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
  92132. */
  92133. releaseEffects(): void;
  92134. /**
  92135. * Dispose and release all associated resources
  92136. */
  92137. dispose(): void;
  92138. /**
  92139. * Display the loading screen
  92140. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92141. */
  92142. displayLoadingUI(): void;
  92143. /**
  92144. * Hide the loading screen
  92145. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92146. */
  92147. hideLoadingUI(): void;
  92148. /**
  92149. * Gets the current loading screen object
  92150. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92151. */
  92152. /**
  92153. * Sets the current loading screen object
  92154. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92155. */
  92156. loadingScreen: ILoadingScreen;
  92157. /**
  92158. * Sets the current loading screen text
  92159. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92160. */
  92161. loadingUIText: string;
  92162. /**
  92163. * Sets the current loading screen background color
  92164. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92165. */
  92166. loadingUIBackgroundColor: string;
  92167. /**
  92168. * Attach a new callback raised when context lost event is fired
  92169. * @param callback defines the callback to call
  92170. */
  92171. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92172. /**
  92173. * Attach a new callback raised when context restored event is fired
  92174. * @param callback defines the callback to call
  92175. */
  92176. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92177. /**
  92178. * Gets the source code of the vertex shader associated with a specific webGL program
  92179. * @param program defines the program to use
  92180. * @returns a string containing the source code of the vertex shader associated with the program
  92181. */
  92182. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  92183. /**
  92184. * Gets the source code of the fragment shader associated with a specific webGL program
  92185. * @param program defines the program to use
  92186. * @returns a string containing the source code of the fragment shader associated with the program
  92187. */
  92188. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  92189. /**
  92190. * Get the current error code of the webGL context
  92191. * @returns the error code
  92192. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  92193. */
  92194. getError(): number;
  92195. /**
  92196. * Gets the current framerate
  92197. * @returns a number representing the framerate
  92198. */
  92199. getFps(): number;
  92200. /**
  92201. * Gets the time spent between current and previous frame
  92202. * @returns a number representing the delta time in ms
  92203. */
  92204. getDeltaTime(): number;
  92205. private _measureFps;
  92206. /** @hidden */
  92207. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  92208. private _canRenderToFloatFramebuffer;
  92209. private _canRenderToHalfFloatFramebuffer;
  92210. private _canRenderToFramebuffer;
  92211. /** @hidden */
  92212. _getWebGLTextureType(type: number): number;
  92213. /** @hidden */
  92214. _getInternalFormat(format: number): number;
  92215. /** @hidden */
  92216. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  92217. /** @hidden */
  92218. _getRGBAMultiSampleBufferFormat(type: number): number;
  92219. /** @hidden */
  92220. _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;
  92221. /** @hidden */
  92222. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92223. /**
  92224. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  92225. * @returns true if the engine can be created
  92226. * @ignorenaming
  92227. */
  92228. static isSupported(): boolean;
  92229. }
  92230. }
  92231. declare module BABYLON {
  92232. /**
  92233. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92234. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92235. */
  92236. export class EffectFallbacks {
  92237. private _defines;
  92238. private _currentRank;
  92239. private _maxRank;
  92240. private _mesh;
  92241. /**
  92242. * Removes the fallback from the bound mesh.
  92243. */
  92244. unBindMesh(): void;
  92245. /**
  92246. * Adds a fallback on the specified property.
  92247. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92248. * @param define The name of the define in the shader
  92249. */
  92250. addFallback(rank: number, define: string): void;
  92251. /**
  92252. * Sets the mesh to use CPU skinning when needing to fallback.
  92253. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92254. * @param mesh The mesh to use the fallbacks.
  92255. */
  92256. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92257. /**
  92258. * Checks to see if more fallbacks are still availible.
  92259. */
  92260. readonly isMoreFallbacks: boolean;
  92261. /**
  92262. * Removes the defines that should be removed when falling back.
  92263. * @param currentDefines defines the current define statements for the shader.
  92264. * @param effect defines the current effect we try to compile
  92265. * @returns The resulting defines with defines of the current rank removed.
  92266. */
  92267. reduce(currentDefines: string, effect: Effect): string;
  92268. }
  92269. /**
  92270. * Options to be used when creating an effect.
  92271. */
  92272. export class EffectCreationOptions {
  92273. /**
  92274. * Atrributes that will be used in the shader.
  92275. */
  92276. attributes: string[];
  92277. /**
  92278. * Uniform varible names that will be set in the shader.
  92279. */
  92280. uniformsNames: string[];
  92281. /**
  92282. * Uniform buffer varible names that will be set in the shader.
  92283. */
  92284. uniformBuffersNames: string[];
  92285. /**
  92286. * Sampler texture variable names that will be set in the shader.
  92287. */
  92288. samplers: string[];
  92289. /**
  92290. * Define statements that will be set in the shader.
  92291. */
  92292. defines: any;
  92293. /**
  92294. * Possible fallbacks for this effect to improve performance when needed.
  92295. */
  92296. fallbacks: Nullable<EffectFallbacks>;
  92297. /**
  92298. * Callback that will be called when the shader is compiled.
  92299. */
  92300. onCompiled: Nullable<(effect: Effect) => void>;
  92301. /**
  92302. * Callback that will be called if an error occurs during shader compilation.
  92303. */
  92304. onError: Nullable<(effect: Effect, errors: string) => void>;
  92305. /**
  92306. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92307. */
  92308. indexParameters: any;
  92309. /**
  92310. * Max number of lights that can be used in the shader.
  92311. */
  92312. maxSimultaneousLights: number;
  92313. /**
  92314. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92315. */
  92316. transformFeedbackVaryings: Nullable<string[]>;
  92317. }
  92318. /**
  92319. * Effect containing vertex and fragment shader that can be executed on an object.
  92320. */
  92321. export class Effect implements IDisposable {
  92322. /**
  92323. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92324. */
  92325. static ShadersRepository: string;
  92326. /**
  92327. * Name of the effect.
  92328. */
  92329. name: any;
  92330. /**
  92331. * String container all the define statements that should be set on the shader.
  92332. */
  92333. defines: string;
  92334. /**
  92335. * Callback that will be called when the shader is compiled.
  92336. */
  92337. onCompiled: Nullable<(effect: Effect) => void>;
  92338. /**
  92339. * Callback that will be called if an error occurs during shader compilation.
  92340. */
  92341. onError: Nullable<(effect: Effect, errors: string) => void>;
  92342. /**
  92343. * Callback that will be called when effect is bound.
  92344. */
  92345. onBind: Nullable<(effect: Effect) => void>;
  92346. /**
  92347. * Unique ID of the effect.
  92348. */
  92349. uniqueId: number;
  92350. /**
  92351. * Observable that will be called when the shader is compiled.
  92352. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92353. */
  92354. onCompileObservable: Observable<Effect>;
  92355. /**
  92356. * Observable that will be called if an error occurs during shader compilation.
  92357. */
  92358. onErrorObservable: Observable<Effect>;
  92359. /** @hidden */
  92360. _onBindObservable: Nullable<Observable<Effect>>;
  92361. /**
  92362. * Observable that will be called when effect is bound.
  92363. */
  92364. readonly onBindObservable: Observable<Effect>;
  92365. /** @hidden */
  92366. _bonesComputationForcedToCPU: boolean;
  92367. private static _uniqueIdSeed;
  92368. private _engine;
  92369. private _uniformBuffersNames;
  92370. private _uniformsNames;
  92371. private _samplerList;
  92372. private _samplers;
  92373. private _isReady;
  92374. private _compilationError;
  92375. private _attributesNames;
  92376. private _attributes;
  92377. private _uniforms;
  92378. /**
  92379. * Key for the effect.
  92380. * @hidden
  92381. */
  92382. _key: string;
  92383. private _indexParameters;
  92384. private _fallbacks;
  92385. private _vertexSourceCode;
  92386. private _fragmentSourceCode;
  92387. private _vertexSourceCodeOverride;
  92388. private _fragmentSourceCodeOverride;
  92389. private _transformFeedbackVaryings;
  92390. /**
  92391. * Compiled shader to webGL program.
  92392. * @hidden
  92393. */
  92394. _pipelineContext: Nullable<IPipelineContext>;
  92395. private _valueCache;
  92396. private static _baseCache;
  92397. /**
  92398. * Instantiates an effect.
  92399. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92400. * @param baseName Name of the effect.
  92401. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92402. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92403. * @param samplers List of sampler variables that will be passed to the shader.
  92404. * @param engine Engine to be used to render the effect
  92405. * @param defines Define statements to be added to the shader.
  92406. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92407. * @param onCompiled Callback that will be called when the shader is compiled.
  92408. * @param onError Callback that will be called if an error occurs during shader compilation.
  92409. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92410. */
  92411. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  92412. private _useFinalCode;
  92413. /**
  92414. * Unique key for this effect
  92415. */
  92416. readonly key: string;
  92417. /**
  92418. * If the effect has been compiled and prepared.
  92419. * @returns if the effect is compiled and prepared.
  92420. */
  92421. isReady(): boolean;
  92422. /**
  92423. * The engine the effect was initialized with.
  92424. * @returns the engine.
  92425. */
  92426. getEngine(): Engine;
  92427. /**
  92428. * The pipeline context for this effect
  92429. * @returns the associated pipeline context
  92430. */
  92431. getPipelineContext(): Nullable<IPipelineContext>;
  92432. /**
  92433. * The set of names of attribute variables for the shader.
  92434. * @returns An array of attribute names.
  92435. */
  92436. getAttributesNames(): string[];
  92437. /**
  92438. * Returns the attribute at the given index.
  92439. * @param index The index of the attribute.
  92440. * @returns The location of the attribute.
  92441. */
  92442. getAttributeLocation(index: number): number;
  92443. /**
  92444. * Returns the attribute based on the name of the variable.
  92445. * @param name of the attribute to look up.
  92446. * @returns the attribute location.
  92447. */
  92448. getAttributeLocationByName(name: string): number;
  92449. /**
  92450. * The number of attributes.
  92451. * @returns the numnber of attributes.
  92452. */
  92453. getAttributesCount(): number;
  92454. /**
  92455. * Gets the index of a uniform variable.
  92456. * @param uniformName of the uniform to look up.
  92457. * @returns the index.
  92458. */
  92459. getUniformIndex(uniformName: string): number;
  92460. /**
  92461. * Returns the attribute based on the name of the variable.
  92462. * @param uniformName of the uniform to look up.
  92463. * @returns the location of the uniform.
  92464. */
  92465. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92466. /**
  92467. * Returns an array of sampler variable names
  92468. * @returns The array of sampler variable neames.
  92469. */
  92470. getSamplers(): string[];
  92471. /**
  92472. * The error from the last compilation.
  92473. * @returns the error string.
  92474. */
  92475. getCompilationError(): string;
  92476. /**
  92477. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92478. * @param func The callback to be used.
  92479. */
  92480. executeWhenCompiled(func: (effect: Effect) => void): void;
  92481. private _checkIsReady;
  92482. /** @hidden */
  92483. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92484. /** @hidden */
  92485. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92486. /** @hidden */
  92487. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92488. /**
  92489. * Recompiles the webGL program
  92490. * @param vertexSourceCode The source code for the vertex shader.
  92491. * @param fragmentSourceCode The source code for the fragment shader.
  92492. * @param onCompiled Callback called when completed.
  92493. * @param onError Callback called on error.
  92494. * @hidden
  92495. */
  92496. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92497. /**
  92498. * Prepares the effect
  92499. * @hidden
  92500. */
  92501. _prepareEffect(): void;
  92502. /**
  92503. * Checks if the effect is supported. (Must be called after compilation)
  92504. */
  92505. readonly isSupported: boolean;
  92506. /**
  92507. * Binds a texture to the engine to be used as output of the shader.
  92508. * @param channel Name of the output variable.
  92509. * @param texture Texture to bind.
  92510. * @hidden
  92511. */
  92512. _bindTexture(channel: string, texture: InternalTexture): void;
  92513. /**
  92514. * Sets a texture on the engine to be used in the shader.
  92515. * @param channel Name of the sampler variable.
  92516. * @param texture Texture to set.
  92517. */
  92518. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92519. /**
  92520. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92521. * @param channel Name of the sampler variable.
  92522. * @param texture Texture to set.
  92523. */
  92524. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92525. /**
  92526. * Sets an array of textures on the engine to be used in the shader.
  92527. * @param channel Name of the variable.
  92528. * @param textures Textures to set.
  92529. */
  92530. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92531. /**
  92532. * 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)
  92533. * @param channel Name of the sampler variable.
  92534. * @param postProcess Post process to get the input texture from.
  92535. */
  92536. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92537. /**
  92538. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92539. * 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)
  92540. * @param channel Name of the sampler variable.
  92541. * @param postProcess Post process to get the output texture from.
  92542. */
  92543. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92544. /** @hidden */
  92545. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92546. /** @hidden */
  92547. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92548. /** @hidden */
  92549. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92550. /** @hidden */
  92551. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92552. /**
  92553. * Binds a buffer to a uniform.
  92554. * @param buffer Buffer to bind.
  92555. * @param name Name of the uniform variable to bind to.
  92556. */
  92557. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92558. /**
  92559. * Binds block to a uniform.
  92560. * @param blockName Name of the block to bind.
  92561. * @param index Index to bind.
  92562. */
  92563. bindUniformBlock(blockName: string, index: number): void;
  92564. /**
  92565. * Sets an interger value on a uniform variable.
  92566. * @param uniformName Name of the variable.
  92567. * @param value Value to be set.
  92568. * @returns this effect.
  92569. */
  92570. setInt(uniformName: string, value: number): Effect;
  92571. /**
  92572. * Sets an int array on a uniform variable.
  92573. * @param uniformName Name of the variable.
  92574. * @param array array to be set.
  92575. * @returns this effect.
  92576. */
  92577. setIntArray(uniformName: string, array: Int32Array): Effect;
  92578. /**
  92579. * 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)
  92580. * @param uniformName Name of the variable.
  92581. * @param array array to be set.
  92582. * @returns this effect.
  92583. */
  92584. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92585. /**
  92586. * 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)
  92587. * @param uniformName Name of the variable.
  92588. * @param array array to be set.
  92589. * @returns this effect.
  92590. */
  92591. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92592. /**
  92593. * 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)
  92594. * @param uniformName Name of the variable.
  92595. * @param array array to be set.
  92596. * @returns this effect.
  92597. */
  92598. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92599. /**
  92600. * Sets an float array on a uniform variable.
  92601. * @param uniformName Name of the variable.
  92602. * @param array array to be set.
  92603. * @returns this effect.
  92604. */
  92605. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92606. /**
  92607. * 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)
  92608. * @param uniformName Name of the variable.
  92609. * @param array array to be set.
  92610. * @returns this effect.
  92611. */
  92612. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92613. /**
  92614. * 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)
  92615. * @param uniformName Name of the variable.
  92616. * @param array array to be set.
  92617. * @returns this effect.
  92618. */
  92619. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92620. /**
  92621. * 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)
  92622. * @param uniformName Name of the variable.
  92623. * @param array array to be set.
  92624. * @returns this effect.
  92625. */
  92626. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92627. /**
  92628. * Sets an array on a uniform variable.
  92629. * @param uniformName Name of the variable.
  92630. * @param array array to be set.
  92631. * @returns this effect.
  92632. */
  92633. setArray(uniformName: string, array: number[]): Effect;
  92634. /**
  92635. * 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)
  92636. * @param uniformName Name of the variable.
  92637. * @param array array to be set.
  92638. * @returns this effect.
  92639. */
  92640. setArray2(uniformName: string, array: number[]): Effect;
  92641. /**
  92642. * 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)
  92643. * @param uniformName Name of the variable.
  92644. * @param array array to be set.
  92645. * @returns this effect.
  92646. */
  92647. setArray3(uniformName: string, array: number[]): Effect;
  92648. /**
  92649. * 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)
  92650. * @param uniformName Name of the variable.
  92651. * @param array array to be set.
  92652. * @returns this effect.
  92653. */
  92654. setArray4(uniformName: string, array: number[]): Effect;
  92655. /**
  92656. * Sets matrices on a uniform variable.
  92657. * @param uniformName Name of the variable.
  92658. * @param matrices matrices to be set.
  92659. * @returns this effect.
  92660. */
  92661. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92662. /**
  92663. * Sets matrix on a uniform variable.
  92664. * @param uniformName Name of the variable.
  92665. * @param matrix matrix to be set.
  92666. * @returns this effect.
  92667. */
  92668. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92669. /**
  92670. * 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)
  92671. * @param uniformName Name of the variable.
  92672. * @param matrix matrix to be set.
  92673. * @returns this effect.
  92674. */
  92675. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92676. /**
  92677. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92678. * @param uniformName Name of the variable.
  92679. * @param matrix matrix to be set.
  92680. * @returns this effect.
  92681. */
  92682. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92683. /**
  92684. * Sets a float on a uniform variable.
  92685. * @param uniformName Name of the variable.
  92686. * @param value value to be set.
  92687. * @returns this effect.
  92688. */
  92689. setFloat(uniformName: string, value: number): Effect;
  92690. /**
  92691. * Sets a boolean on a uniform variable.
  92692. * @param uniformName Name of the variable.
  92693. * @param bool value to be set.
  92694. * @returns this effect.
  92695. */
  92696. setBool(uniformName: string, bool: boolean): Effect;
  92697. /**
  92698. * Sets a Vector2 on a uniform variable.
  92699. * @param uniformName Name of the variable.
  92700. * @param vector2 vector2 to be set.
  92701. * @returns this effect.
  92702. */
  92703. setVector2(uniformName: string, vector2: Vector2): Effect;
  92704. /**
  92705. * Sets a float2 on a uniform variable.
  92706. * @param uniformName Name of the variable.
  92707. * @param x First float in float2.
  92708. * @param y Second float in float2.
  92709. * @returns this effect.
  92710. */
  92711. setFloat2(uniformName: string, x: number, y: number): Effect;
  92712. /**
  92713. * Sets a Vector3 on a uniform variable.
  92714. * @param uniformName Name of the variable.
  92715. * @param vector3 Value to be set.
  92716. * @returns this effect.
  92717. */
  92718. setVector3(uniformName: string, vector3: Vector3): Effect;
  92719. /**
  92720. * Sets a float3 on a uniform variable.
  92721. * @param uniformName Name of the variable.
  92722. * @param x First float in float3.
  92723. * @param y Second float in float3.
  92724. * @param z Third float in float3.
  92725. * @returns this effect.
  92726. */
  92727. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92728. /**
  92729. * Sets a Vector4 on a uniform variable.
  92730. * @param uniformName Name of the variable.
  92731. * @param vector4 Value to be set.
  92732. * @returns this effect.
  92733. */
  92734. setVector4(uniformName: string, vector4: Vector4): Effect;
  92735. /**
  92736. * Sets a float4 on a uniform variable.
  92737. * @param uniformName Name of the variable.
  92738. * @param x First float in float4.
  92739. * @param y Second float in float4.
  92740. * @param z Third float in float4.
  92741. * @param w Fourth float in float4.
  92742. * @returns this effect.
  92743. */
  92744. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92745. /**
  92746. * Sets a Color3 on a uniform variable.
  92747. * @param uniformName Name of the variable.
  92748. * @param color3 Value to be set.
  92749. * @returns this effect.
  92750. */
  92751. setColor3(uniformName: string, color3: Color3): Effect;
  92752. /**
  92753. * Sets a Color4 on a uniform variable.
  92754. * @param uniformName Name of the variable.
  92755. * @param color3 Value to be set.
  92756. * @param alpha Alpha value to be set.
  92757. * @returns this effect.
  92758. */
  92759. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92760. /**
  92761. * Sets a Color4 on a uniform variable
  92762. * @param uniformName defines the name of the variable
  92763. * @param color4 defines the value to be set
  92764. * @returns this effect.
  92765. */
  92766. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92767. /** Release all associated resources */
  92768. dispose(): void;
  92769. /**
  92770. * This function will add a new shader to the shader store
  92771. * @param name the name of the shader
  92772. * @param pixelShader optional pixel shader content
  92773. * @param vertexShader optional vertex shader content
  92774. */
  92775. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92776. /**
  92777. * Store of each shader (The can be looked up using effect.key)
  92778. */
  92779. static ShadersStore: {
  92780. [key: string]: string;
  92781. };
  92782. /**
  92783. * Store of each included file for a shader (The can be looked up using effect.key)
  92784. */
  92785. static IncludesShadersStore: {
  92786. [key: string]: string;
  92787. };
  92788. /**
  92789. * Resets the cache of effects.
  92790. */
  92791. static ResetCache(): void;
  92792. }
  92793. }
  92794. declare module BABYLON {
  92795. /**
  92796. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92797. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92798. * 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;
  92799. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92800. */
  92801. export class ColorCurves {
  92802. private _dirty;
  92803. private _tempColor;
  92804. private _globalCurve;
  92805. private _highlightsCurve;
  92806. private _midtonesCurve;
  92807. private _shadowsCurve;
  92808. private _positiveCurve;
  92809. private _negativeCurve;
  92810. private _globalHue;
  92811. private _globalDensity;
  92812. private _globalSaturation;
  92813. private _globalExposure;
  92814. /**
  92815. * Gets the global Hue value.
  92816. * 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).
  92817. */
  92818. /**
  92819. * Sets the global Hue value.
  92820. * 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).
  92821. */
  92822. globalHue: number;
  92823. /**
  92824. * Gets the global Density value.
  92825. * 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.
  92826. * Values less than zero provide a filter of opposite hue.
  92827. */
  92828. /**
  92829. * Sets the global Density value.
  92830. * 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.
  92831. * Values less than zero provide a filter of opposite hue.
  92832. */
  92833. globalDensity: number;
  92834. /**
  92835. * Gets the global Saturation value.
  92836. * 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.
  92837. */
  92838. /**
  92839. * Sets the global Saturation value.
  92840. * 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.
  92841. */
  92842. globalSaturation: number;
  92843. /**
  92844. * Gets the global Exposure value.
  92845. * 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.
  92846. */
  92847. /**
  92848. * Sets the global Exposure value.
  92849. * 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.
  92850. */
  92851. globalExposure: number;
  92852. private _highlightsHue;
  92853. private _highlightsDensity;
  92854. private _highlightsSaturation;
  92855. private _highlightsExposure;
  92856. /**
  92857. * Gets the highlights Hue value.
  92858. * 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).
  92859. */
  92860. /**
  92861. * Sets the highlights Hue value.
  92862. * 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).
  92863. */
  92864. highlightsHue: number;
  92865. /**
  92866. * Gets the highlights Density value.
  92867. * 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.
  92868. * Values less than zero provide a filter of opposite hue.
  92869. */
  92870. /**
  92871. * Sets the highlights Density value.
  92872. * 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.
  92873. * Values less than zero provide a filter of opposite hue.
  92874. */
  92875. highlightsDensity: number;
  92876. /**
  92877. * Gets the highlights Saturation value.
  92878. * 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.
  92879. */
  92880. /**
  92881. * Sets the highlights Saturation value.
  92882. * 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.
  92883. */
  92884. highlightsSaturation: number;
  92885. /**
  92886. * Gets the highlights Exposure value.
  92887. * 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.
  92888. */
  92889. /**
  92890. * Sets the highlights Exposure value.
  92891. * 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.
  92892. */
  92893. highlightsExposure: number;
  92894. private _midtonesHue;
  92895. private _midtonesDensity;
  92896. private _midtonesSaturation;
  92897. private _midtonesExposure;
  92898. /**
  92899. * Gets the midtones Hue value.
  92900. * 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).
  92901. */
  92902. /**
  92903. * Sets the midtones Hue value.
  92904. * 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).
  92905. */
  92906. midtonesHue: number;
  92907. /**
  92908. * Gets the midtones Density value.
  92909. * 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.
  92910. * Values less than zero provide a filter of opposite hue.
  92911. */
  92912. /**
  92913. * Sets the midtones Density value.
  92914. * 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.
  92915. * Values less than zero provide a filter of opposite hue.
  92916. */
  92917. midtonesDensity: number;
  92918. /**
  92919. * Gets the midtones Saturation value.
  92920. * 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.
  92921. */
  92922. /**
  92923. * Sets the midtones Saturation value.
  92924. * 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.
  92925. */
  92926. midtonesSaturation: number;
  92927. /**
  92928. * Gets the midtones Exposure value.
  92929. * 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.
  92930. */
  92931. /**
  92932. * Sets the midtones Exposure value.
  92933. * 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.
  92934. */
  92935. midtonesExposure: number;
  92936. private _shadowsHue;
  92937. private _shadowsDensity;
  92938. private _shadowsSaturation;
  92939. private _shadowsExposure;
  92940. /**
  92941. * Gets the shadows Hue value.
  92942. * 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).
  92943. */
  92944. /**
  92945. * Sets the shadows Hue value.
  92946. * 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).
  92947. */
  92948. shadowsHue: number;
  92949. /**
  92950. * Gets the shadows Density value.
  92951. * 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.
  92952. * Values less than zero provide a filter of opposite hue.
  92953. */
  92954. /**
  92955. * Sets the shadows Density value.
  92956. * 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.
  92957. * Values less than zero provide a filter of opposite hue.
  92958. */
  92959. shadowsDensity: number;
  92960. /**
  92961. * Gets the shadows Saturation value.
  92962. * 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.
  92963. */
  92964. /**
  92965. * Sets the shadows Saturation value.
  92966. * 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.
  92967. */
  92968. shadowsSaturation: number;
  92969. /**
  92970. * Gets the shadows Exposure value.
  92971. * 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.
  92972. */
  92973. /**
  92974. * Sets the shadows Exposure value.
  92975. * 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.
  92976. */
  92977. shadowsExposure: number;
  92978. /**
  92979. * Returns the class name
  92980. * @returns The class name
  92981. */
  92982. getClassName(): string;
  92983. /**
  92984. * Binds the color curves to the shader.
  92985. * @param colorCurves The color curve to bind
  92986. * @param effect The effect to bind to
  92987. * @param positiveUniform The positive uniform shader parameter
  92988. * @param neutralUniform The neutral uniform shader parameter
  92989. * @param negativeUniform The negative uniform shader parameter
  92990. */
  92991. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92992. /**
  92993. * Prepare the list of uniforms associated with the ColorCurves effects.
  92994. * @param uniformsList The list of uniforms used in the effect
  92995. */
  92996. static PrepareUniforms(uniformsList: string[]): void;
  92997. /**
  92998. * Returns color grading data based on a hue, density, saturation and exposure value.
  92999. * @param filterHue The hue of the color filter.
  93000. * @param filterDensity The density of the color filter.
  93001. * @param saturation The saturation.
  93002. * @param exposure The exposure.
  93003. * @param result The result data container.
  93004. */
  93005. private getColorGradingDataToRef;
  93006. /**
  93007. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  93008. * @param value The input slider value in range [-100,100].
  93009. * @returns Adjusted value.
  93010. */
  93011. private static applyColorGradingSliderNonlinear;
  93012. /**
  93013. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  93014. * @param hue The hue (H) input.
  93015. * @param saturation The saturation (S) input.
  93016. * @param brightness The brightness (B) input.
  93017. * @result An RGBA color represented as Vector4.
  93018. */
  93019. private static fromHSBToRef;
  93020. /**
  93021. * Returns a value clamped between min and max
  93022. * @param value The value to clamp
  93023. * @param min The minimum of value
  93024. * @param max The maximum of value
  93025. * @returns The clamped value.
  93026. */
  93027. private static clamp;
  93028. /**
  93029. * Clones the current color curve instance.
  93030. * @return The cloned curves
  93031. */
  93032. clone(): ColorCurves;
  93033. /**
  93034. * Serializes the current color curve instance to a json representation.
  93035. * @return a JSON representation
  93036. */
  93037. serialize(): any;
  93038. /**
  93039. * Parses the color curve from a json representation.
  93040. * @param source the JSON source to parse
  93041. * @return The parsed curves
  93042. */
  93043. static Parse(source: any): ColorCurves;
  93044. }
  93045. }
  93046. declare module BABYLON {
  93047. /**
  93048. * Interface to follow in your material defines to integrate easily the
  93049. * Image proccessing functions.
  93050. * @hidden
  93051. */
  93052. export interface IImageProcessingConfigurationDefines {
  93053. IMAGEPROCESSING: boolean;
  93054. VIGNETTE: boolean;
  93055. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93056. VIGNETTEBLENDMODEOPAQUE: boolean;
  93057. TONEMAPPING: boolean;
  93058. TONEMAPPING_ACES: boolean;
  93059. CONTRAST: boolean;
  93060. EXPOSURE: boolean;
  93061. COLORCURVES: boolean;
  93062. COLORGRADING: boolean;
  93063. COLORGRADING3D: boolean;
  93064. SAMPLER3DGREENDEPTH: boolean;
  93065. SAMPLER3DBGRMAP: boolean;
  93066. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93067. }
  93068. /**
  93069. * @hidden
  93070. */
  93071. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93072. IMAGEPROCESSING: boolean;
  93073. VIGNETTE: boolean;
  93074. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93075. VIGNETTEBLENDMODEOPAQUE: boolean;
  93076. TONEMAPPING: boolean;
  93077. TONEMAPPING_ACES: boolean;
  93078. CONTRAST: boolean;
  93079. COLORCURVES: boolean;
  93080. COLORGRADING: boolean;
  93081. COLORGRADING3D: boolean;
  93082. SAMPLER3DGREENDEPTH: boolean;
  93083. SAMPLER3DBGRMAP: boolean;
  93084. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93085. EXPOSURE: boolean;
  93086. constructor();
  93087. }
  93088. /**
  93089. * This groups together the common properties used for image processing either in direct forward pass
  93090. * or through post processing effect depending on the use of the image processing pipeline in your scene
  93091. * or not.
  93092. */
  93093. export class ImageProcessingConfiguration {
  93094. /**
  93095. * Default tone mapping applied in BabylonJS.
  93096. */
  93097. static readonly TONEMAPPING_STANDARD: number;
  93098. /**
  93099. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  93100. * to other engines rendering to increase portability.
  93101. */
  93102. static readonly TONEMAPPING_ACES: number;
  93103. /**
  93104. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  93105. */
  93106. colorCurves: Nullable<ColorCurves>;
  93107. private _colorCurvesEnabled;
  93108. /**
  93109. * Gets wether the color curves effect is enabled.
  93110. */
  93111. /**
  93112. * Sets wether the color curves effect is enabled.
  93113. */
  93114. colorCurvesEnabled: boolean;
  93115. private _colorGradingTexture;
  93116. /**
  93117. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93118. */
  93119. /**
  93120. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93121. */
  93122. colorGradingTexture: Nullable<BaseTexture>;
  93123. private _colorGradingEnabled;
  93124. /**
  93125. * Gets wether the color grading effect is enabled.
  93126. */
  93127. /**
  93128. * Sets wether the color grading effect is enabled.
  93129. */
  93130. colorGradingEnabled: boolean;
  93131. private _colorGradingWithGreenDepth;
  93132. /**
  93133. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  93134. */
  93135. /**
  93136. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  93137. */
  93138. colorGradingWithGreenDepth: boolean;
  93139. private _colorGradingBGR;
  93140. /**
  93141. * Gets wether the color grading texture contains BGR values.
  93142. */
  93143. /**
  93144. * Sets wether the color grading texture contains BGR values.
  93145. */
  93146. colorGradingBGR: boolean;
  93147. /** @hidden */
  93148. _exposure: number;
  93149. /**
  93150. * Gets the Exposure used in the effect.
  93151. */
  93152. /**
  93153. * Sets the Exposure used in the effect.
  93154. */
  93155. exposure: number;
  93156. private _toneMappingEnabled;
  93157. /**
  93158. * Gets wether the tone mapping effect is enabled.
  93159. */
  93160. /**
  93161. * Sets wether the tone mapping effect is enabled.
  93162. */
  93163. toneMappingEnabled: boolean;
  93164. private _toneMappingType;
  93165. /**
  93166. * Gets the type of tone mapping effect.
  93167. */
  93168. /**
  93169. * Sets the type of tone mapping effect used in BabylonJS.
  93170. */
  93171. toneMappingType: number;
  93172. protected _contrast: number;
  93173. /**
  93174. * Gets the contrast used in the effect.
  93175. */
  93176. /**
  93177. * Sets the contrast used in the effect.
  93178. */
  93179. contrast: number;
  93180. /**
  93181. * Vignette stretch size.
  93182. */
  93183. vignetteStretch: number;
  93184. /**
  93185. * Vignette centre X Offset.
  93186. */
  93187. vignetteCentreX: number;
  93188. /**
  93189. * Vignette centre Y Offset.
  93190. */
  93191. vignetteCentreY: number;
  93192. /**
  93193. * Vignette weight or intensity of the vignette effect.
  93194. */
  93195. vignetteWeight: number;
  93196. /**
  93197. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  93198. * if vignetteEnabled is set to true.
  93199. */
  93200. vignetteColor: Color4;
  93201. /**
  93202. * Camera field of view used by the Vignette effect.
  93203. */
  93204. vignetteCameraFov: number;
  93205. private _vignetteBlendMode;
  93206. /**
  93207. * Gets the vignette blend mode allowing different kind of effect.
  93208. */
  93209. /**
  93210. * Sets the vignette blend mode allowing different kind of effect.
  93211. */
  93212. vignetteBlendMode: number;
  93213. private _vignetteEnabled;
  93214. /**
  93215. * Gets wether the vignette effect is enabled.
  93216. */
  93217. /**
  93218. * Sets wether the vignette effect is enabled.
  93219. */
  93220. vignetteEnabled: boolean;
  93221. private _applyByPostProcess;
  93222. /**
  93223. * Gets wether the image processing is applied through a post process or not.
  93224. */
  93225. /**
  93226. * Sets wether the image processing is applied through a post process or not.
  93227. */
  93228. applyByPostProcess: boolean;
  93229. private _isEnabled;
  93230. /**
  93231. * Gets wether the image processing is enabled or not.
  93232. */
  93233. /**
  93234. * Sets wether the image processing is enabled or not.
  93235. */
  93236. isEnabled: boolean;
  93237. /**
  93238. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93239. */
  93240. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93241. /**
  93242. * Method called each time the image processing information changes requires to recompile the effect.
  93243. */
  93244. protected _updateParameters(): void;
  93245. /**
  93246. * Gets the current class name.
  93247. * @return "ImageProcessingConfiguration"
  93248. */
  93249. getClassName(): string;
  93250. /**
  93251. * Prepare the list of uniforms associated with the Image Processing effects.
  93252. * @param uniforms The list of uniforms used in the effect
  93253. * @param defines the list of defines currently in use
  93254. */
  93255. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93256. /**
  93257. * Prepare the list of samplers associated with the Image Processing effects.
  93258. * @param samplersList The list of uniforms used in the effect
  93259. * @param defines the list of defines currently in use
  93260. */
  93261. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93262. /**
  93263. * Prepare the list of defines associated to the shader.
  93264. * @param defines the list of defines to complete
  93265. * @param forPostProcess Define if we are currently in post process mode or not
  93266. */
  93267. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93268. /**
  93269. * Returns true if all the image processing information are ready.
  93270. * @returns True if ready, otherwise, false
  93271. */
  93272. isReady(): boolean;
  93273. /**
  93274. * Binds the image processing to the shader.
  93275. * @param effect The effect to bind to
  93276. * @param aspectRatio Define the current aspect ratio of the effect
  93277. */
  93278. bind(effect: Effect, aspectRatio?: number): void;
  93279. /**
  93280. * Clones the current image processing instance.
  93281. * @return The cloned image processing
  93282. */
  93283. clone(): ImageProcessingConfiguration;
  93284. /**
  93285. * Serializes the current image processing instance to a json representation.
  93286. * @return a JSON representation
  93287. */
  93288. serialize(): any;
  93289. /**
  93290. * Parses the image processing from a json representation.
  93291. * @param source the JSON source to parse
  93292. * @return The parsed image processing
  93293. */
  93294. static Parse(source: any): ImageProcessingConfiguration;
  93295. private static _VIGNETTEMODE_MULTIPLY;
  93296. private static _VIGNETTEMODE_OPAQUE;
  93297. /**
  93298. * Used to apply the vignette as a mix with the pixel color.
  93299. */
  93300. static readonly VIGNETTEMODE_MULTIPLY: number;
  93301. /**
  93302. * Used to apply the vignette as a replacement of the pixel color.
  93303. */
  93304. static readonly VIGNETTEMODE_OPAQUE: number;
  93305. }
  93306. }
  93307. declare module BABYLON {
  93308. /**
  93309. * This represents all the required information to add a fresnel effect on a material:
  93310. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93311. */
  93312. export class FresnelParameters {
  93313. private _isEnabled;
  93314. /**
  93315. * Define if the fresnel effect is enable or not.
  93316. */
  93317. isEnabled: boolean;
  93318. /**
  93319. * Define the color used on edges (grazing angle)
  93320. */
  93321. leftColor: Color3;
  93322. /**
  93323. * Define the color used on center
  93324. */
  93325. rightColor: Color3;
  93326. /**
  93327. * Define bias applied to computed fresnel term
  93328. */
  93329. bias: number;
  93330. /**
  93331. * Defined the power exponent applied to fresnel term
  93332. */
  93333. power: number;
  93334. /**
  93335. * Clones the current fresnel and its valuues
  93336. * @returns a clone fresnel configuration
  93337. */
  93338. clone(): FresnelParameters;
  93339. /**
  93340. * Serializes the current fresnel parameters to a JSON representation.
  93341. * @return the JSON serialization
  93342. */
  93343. serialize(): any;
  93344. /**
  93345. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93346. * @param parsedFresnelParameters Define the JSON representation
  93347. * @returns the parsed parameters
  93348. */
  93349. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93350. }
  93351. }
  93352. declare module BABYLON {
  93353. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93354. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93355. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93356. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93357. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93358. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93359. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93360. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93361. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93362. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93363. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93364. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93365. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93366. /**
  93367. * Decorator used to define property that can be serialized as reference to a camera
  93368. * @param sourceName defines the name of the property to decorate
  93369. */
  93370. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93371. /**
  93372. * Class used to help serialization objects
  93373. */
  93374. export class SerializationHelper {
  93375. /** @hidden */
  93376. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93377. /** @hidden */
  93378. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93379. /** @hidden */
  93380. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93381. /** @hidden */
  93382. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93383. /**
  93384. * Appends the serialized animations from the source animations
  93385. * @param source Source containing the animations
  93386. * @param destination Target to store the animations
  93387. */
  93388. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93389. /**
  93390. * Static function used to serialized a specific entity
  93391. * @param entity defines the entity to serialize
  93392. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93393. * @returns a JSON compatible object representing the serialization of the entity
  93394. */
  93395. static Serialize<T>(entity: T, serializationObject?: any): any;
  93396. /**
  93397. * Creates a new entity from a serialization data object
  93398. * @param creationFunction defines a function used to instanciated the new entity
  93399. * @param source defines the source serialization data
  93400. * @param scene defines the hosting scene
  93401. * @param rootUrl defines the root url for resources
  93402. * @returns a new entity
  93403. */
  93404. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93405. /**
  93406. * Clones an object
  93407. * @param creationFunction defines the function used to instanciate the new object
  93408. * @param source defines the source object
  93409. * @returns the cloned object
  93410. */
  93411. static Clone<T>(creationFunction: () => T, source: T): T;
  93412. /**
  93413. * Instanciates a new object based on a source one (some data will be shared between both object)
  93414. * @param creationFunction defines the function used to instanciate the new object
  93415. * @param source defines the source object
  93416. * @returns the new object
  93417. */
  93418. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93419. }
  93420. }
  93421. declare module BABYLON {
  93422. /**
  93423. * This is the base class of all the camera used in the application.
  93424. * @see http://doc.babylonjs.com/features/cameras
  93425. */
  93426. export class Camera extends Node {
  93427. /** @hidden */
  93428. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93429. /**
  93430. * This is the default projection mode used by the cameras.
  93431. * It helps recreating a feeling of perspective and better appreciate depth.
  93432. * This is the best way to simulate real life cameras.
  93433. */
  93434. static readonly PERSPECTIVE_CAMERA: number;
  93435. /**
  93436. * This helps creating camera with an orthographic mode.
  93437. * 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.
  93438. */
  93439. static readonly ORTHOGRAPHIC_CAMERA: number;
  93440. /**
  93441. * This is the default FOV mode for perspective cameras.
  93442. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93443. */
  93444. static readonly FOVMODE_VERTICAL_FIXED: number;
  93445. /**
  93446. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93447. */
  93448. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93449. /**
  93450. * This specifies ther is no need for a camera rig.
  93451. * Basically only one eye is rendered corresponding to the camera.
  93452. */
  93453. static readonly RIG_MODE_NONE: number;
  93454. /**
  93455. * Simulates a camera Rig with one blue eye and one red eye.
  93456. * This can be use with 3d blue and red glasses.
  93457. */
  93458. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93459. /**
  93460. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93461. */
  93462. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93463. /**
  93464. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93465. */
  93466. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93467. /**
  93468. * Defines that both eyes of the camera will be rendered over under each other.
  93469. */
  93470. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93471. /**
  93472. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93473. */
  93474. static readonly RIG_MODE_VR: number;
  93475. /**
  93476. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93477. */
  93478. static readonly RIG_MODE_WEBVR: number;
  93479. /**
  93480. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93481. */
  93482. static readonly RIG_MODE_CUSTOM: number;
  93483. /**
  93484. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93485. */
  93486. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93487. /**
  93488. * Define the input manager associated with the camera.
  93489. */
  93490. inputs: CameraInputsManager<Camera>;
  93491. /** @hidden */
  93492. _position: Vector3;
  93493. /**
  93494. * Define the current local position of the camera in the scene
  93495. */
  93496. position: Vector3;
  93497. /**
  93498. * The vector the camera should consider as up.
  93499. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93500. */
  93501. upVector: Vector3;
  93502. /**
  93503. * Define the current limit on the left side for an orthographic camera
  93504. * In scene unit
  93505. */
  93506. orthoLeft: Nullable<number>;
  93507. /**
  93508. * Define the current limit on the right side for an orthographic camera
  93509. * In scene unit
  93510. */
  93511. orthoRight: Nullable<number>;
  93512. /**
  93513. * Define the current limit on the bottom side for an orthographic camera
  93514. * In scene unit
  93515. */
  93516. orthoBottom: Nullable<number>;
  93517. /**
  93518. * Define the current limit on the top side for an orthographic camera
  93519. * In scene unit
  93520. */
  93521. orthoTop: Nullable<number>;
  93522. /**
  93523. * Field Of View is set in Radians. (default is 0.8)
  93524. */
  93525. fov: number;
  93526. /**
  93527. * Define the minimum distance the camera can see from.
  93528. * This is important to note that the depth buffer are not infinite and the closer it starts
  93529. * the more your scene might encounter depth fighting issue.
  93530. */
  93531. minZ: number;
  93532. /**
  93533. * Define the maximum distance the camera can see to.
  93534. * This is important to note that the depth buffer are not infinite and the further it end
  93535. * the more your scene might encounter depth fighting issue.
  93536. */
  93537. maxZ: number;
  93538. /**
  93539. * Define the default inertia of the camera.
  93540. * This helps giving a smooth feeling to the camera movement.
  93541. */
  93542. inertia: number;
  93543. /**
  93544. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  93545. */
  93546. mode: number;
  93547. /**
  93548. * Define wether the camera is intermediate.
  93549. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93550. */
  93551. isIntermediate: boolean;
  93552. /**
  93553. * Define the viewport of the camera.
  93554. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93555. */
  93556. viewport: Viewport;
  93557. /**
  93558. * Restricts the camera to viewing objects with the same layerMask.
  93559. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93560. */
  93561. layerMask: number;
  93562. /**
  93563. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93564. */
  93565. fovMode: number;
  93566. /**
  93567. * Rig mode of the camera.
  93568. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93569. * This is normally controlled byt the camera themselves as internal use.
  93570. */
  93571. cameraRigMode: number;
  93572. /**
  93573. * Defines the distance between both "eyes" in case of a RIG
  93574. */
  93575. interaxialDistance: number;
  93576. /**
  93577. * Defines if stereoscopic rendering is done side by side or over under.
  93578. */
  93579. isStereoscopicSideBySide: boolean;
  93580. /**
  93581. * 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
  93582. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93583. * else in the scene.
  93584. */
  93585. customRenderTargets: RenderTargetTexture[];
  93586. /**
  93587. * When set, the camera will render to this render target instead of the default canvas
  93588. */
  93589. outputRenderTarget: Nullable<RenderTargetTexture>;
  93590. /**
  93591. * Observable triggered when the camera view matrix has changed.
  93592. */
  93593. onViewMatrixChangedObservable: Observable<Camera>;
  93594. /**
  93595. * Observable triggered when the camera Projection matrix has changed.
  93596. */
  93597. onProjectionMatrixChangedObservable: Observable<Camera>;
  93598. /**
  93599. * Observable triggered when the inputs have been processed.
  93600. */
  93601. onAfterCheckInputsObservable: Observable<Camera>;
  93602. /**
  93603. * Observable triggered when reset has been called and applied to the camera.
  93604. */
  93605. onRestoreStateObservable: Observable<Camera>;
  93606. /** @hidden */
  93607. _cameraRigParams: any;
  93608. /** @hidden */
  93609. _rigCameras: Camera[];
  93610. /** @hidden */
  93611. _rigPostProcess: Nullable<PostProcess>;
  93612. protected _webvrViewMatrix: Matrix;
  93613. /** @hidden */
  93614. _skipRendering: boolean;
  93615. /** @hidden */
  93616. _projectionMatrix: Matrix;
  93617. /** @hidden */
  93618. _postProcesses: Nullable<PostProcess>[];
  93619. /** @hidden */
  93620. _activeMeshes: SmartArray<AbstractMesh>;
  93621. protected _globalPosition: Vector3;
  93622. /** @hidden */
  93623. _computedViewMatrix: Matrix;
  93624. private _doNotComputeProjectionMatrix;
  93625. private _transformMatrix;
  93626. private _frustumPlanes;
  93627. private _refreshFrustumPlanes;
  93628. private _storedFov;
  93629. private _stateStored;
  93630. /**
  93631. * Instantiates a new camera object.
  93632. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93633. * @see http://doc.babylonjs.com/features/cameras
  93634. * @param name Defines the name of the camera in the scene
  93635. * @param position Defines the position of the camera
  93636. * @param scene Defines the scene the camera belongs too
  93637. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93638. */
  93639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93640. /**
  93641. * Store current camera state (fov, position, etc..)
  93642. * @returns the camera
  93643. */
  93644. storeState(): Camera;
  93645. /**
  93646. * Restores the camera state values if it has been stored. You must call storeState() first
  93647. */
  93648. protected _restoreStateValues(): boolean;
  93649. /**
  93650. * Restored camera state. You must call storeState() first.
  93651. * @returns true if restored and false otherwise
  93652. */
  93653. restoreState(): boolean;
  93654. /**
  93655. * Gets the class name of the camera.
  93656. * @returns the class name
  93657. */
  93658. getClassName(): string;
  93659. /** @hidden */
  93660. readonly _isCamera: boolean;
  93661. /**
  93662. * Gets a string representation of the camera useful for debug purpose.
  93663. * @param fullDetails Defines that a more verboe level of logging is required
  93664. * @returns the string representation
  93665. */
  93666. toString(fullDetails?: boolean): string;
  93667. /**
  93668. * Gets the current world space position of the camera.
  93669. */
  93670. readonly globalPosition: Vector3;
  93671. /**
  93672. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93673. * @returns the active meshe list
  93674. */
  93675. getActiveMeshes(): SmartArray<AbstractMesh>;
  93676. /**
  93677. * Check wether a mesh is part of the current active mesh list of the camera
  93678. * @param mesh Defines the mesh to check
  93679. * @returns true if active, false otherwise
  93680. */
  93681. isActiveMesh(mesh: Mesh): boolean;
  93682. /**
  93683. * Is this camera ready to be used/rendered
  93684. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93685. * @return true if the camera is ready
  93686. */
  93687. isReady(completeCheck?: boolean): boolean;
  93688. /** @hidden */
  93689. _initCache(): void;
  93690. /** @hidden */
  93691. _updateCache(ignoreParentClass?: boolean): void;
  93692. /** @hidden */
  93693. _isSynchronized(): boolean;
  93694. /** @hidden */
  93695. _isSynchronizedViewMatrix(): boolean;
  93696. /** @hidden */
  93697. _isSynchronizedProjectionMatrix(): boolean;
  93698. /**
  93699. * Attach the input controls to a specific dom element to get the input from.
  93700. * @param element Defines the element the controls should be listened from
  93701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93702. */
  93703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93704. /**
  93705. * Detach the current controls from the specified dom element.
  93706. * @param element Defines the element to stop listening the inputs from
  93707. */
  93708. detachControl(element: HTMLElement): void;
  93709. /**
  93710. * Update the camera state according to the different inputs gathered during the frame.
  93711. */
  93712. update(): void;
  93713. /** @hidden */
  93714. _checkInputs(): void;
  93715. /** @hidden */
  93716. readonly rigCameras: Camera[];
  93717. /**
  93718. * Gets the post process used by the rig cameras
  93719. */
  93720. readonly rigPostProcess: Nullable<PostProcess>;
  93721. /**
  93722. * Internal, gets the first post proces.
  93723. * @returns the first post process to be run on this camera.
  93724. */
  93725. _getFirstPostProcess(): Nullable<PostProcess>;
  93726. private _cascadePostProcessesToRigCams;
  93727. /**
  93728. * Attach a post process to the camera.
  93729. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93730. * @param postProcess The post process to attach to the camera
  93731. * @param insertAt The position of the post process in case several of them are in use in the scene
  93732. * @returns the position the post process has been inserted at
  93733. */
  93734. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93735. /**
  93736. * Detach a post process to the camera.
  93737. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93738. * @param postProcess The post process to detach from the camera
  93739. */
  93740. detachPostProcess(postProcess: PostProcess): void;
  93741. /**
  93742. * Gets the current world matrix of the camera
  93743. */
  93744. getWorldMatrix(): Matrix;
  93745. /** @hidden */
  93746. _getViewMatrix(): Matrix;
  93747. /**
  93748. * Gets the current view matrix of the camera.
  93749. * @param force forces the camera to recompute the matrix without looking at the cached state
  93750. * @returns the view matrix
  93751. */
  93752. getViewMatrix(force?: boolean): Matrix;
  93753. /**
  93754. * Freeze the projection matrix.
  93755. * It will prevent the cache check of the camera projection compute and can speed up perf
  93756. * if no parameter of the camera are meant to change
  93757. * @param projection Defines manually a projection if necessary
  93758. */
  93759. freezeProjectionMatrix(projection?: Matrix): void;
  93760. /**
  93761. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93762. */
  93763. unfreezeProjectionMatrix(): void;
  93764. /**
  93765. * Gets the current projection matrix of the camera.
  93766. * @param force forces the camera to recompute the matrix without looking at the cached state
  93767. * @returns the projection matrix
  93768. */
  93769. getProjectionMatrix(force?: boolean): Matrix;
  93770. /**
  93771. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93772. * @returns a Matrix
  93773. */
  93774. getTransformationMatrix(): Matrix;
  93775. private _updateFrustumPlanes;
  93776. /**
  93777. * Checks if a cullable object (mesh...) is in the camera frustum
  93778. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93779. * @param target The object to check
  93780. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93781. * @returns true if the object is in frustum otherwise false
  93782. */
  93783. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93784. /**
  93785. * Checks if a cullable object (mesh...) is in the camera frustum
  93786. * Unlike isInFrustum this cheks the full bounding box
  93787. * @param target The object to check
  93788. * @returns true if the object is in frustum otherwise false
  93789. */
  93790. isCompletelyInFrustum(target: ICullable): boolean;
  93791. /**
  93792. * Gets a ray in the forward direction from the camera.
  93793. * @param length Defines the length of the ray to create
  93794. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93795. * @param origin Defines the start point of the ray which defaults to the camera position
  93796. * @returns the forward ray
  93797. */
  93798. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93799. /**
  93800. * Releases resources associated with this node.
  93801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93803. */
  93804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93805. /** @hidden */
  93806. _isLeftCamera: boolean;
  93807. /**
  93808. * Gets the left camera of a rig setup in case of Rigged Camera
  93809. */
  93810. readonly isLeftCamera: boolean;
  93811. /** @hidden */
  93812. _isRightCamera: boolean;
  93813. /**
  93814. * Gets the right camera of a rig setup in case of Rigged Camera
  93815. */
  93816. readonly isRightCamera: boolean;
  93817. /**
  93818. * Gets the left camera of a rig setup in case of Rigged Camera
  93819. */
  93820. readonly leftCamera: Nullable<FreeCamera>;
  93821. /**
  93822. * Gets the right camera of a rig setup in case of Rigged Camera
  93823. */
  93824. readonly rightCamera: Nullable<FreeCamera>;
  93825. /**
  93826. * Gets the left camera target of a rig setup in case of Rigged Camera
  93827. * @returns the target position
  93828. */
  93829. getLeftTarget(): Nullable<Vector3>;
  93830. /**
  93831. * Gets the right camera target of a rig setup in case of Rigged Camera
  93832. * @returns the target position
  93833. */
  93834. getRightTarget(): Nullable<Vector3>;
  93835. /**
  93836. * @hidden
  93837. */
  93838. setCameraRigMode(mode: number, rigParams: any): void;
  93839. /** @hidden */
  93840. static _setStereoscopicRigMode(camera: Camera): void;
  93841. /** @hidden */
  93842. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93843. /** @hidden */
  93844. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93845. /** @hidden */
  93846. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93847. /** @hidden */
  93848. _getVRProjectionMatrix(): Matrix;
  93849. protected _updateCameraRotationMatrix(): void;
  93850. protected _updateWebVRCameraRotationMatrix(): void;
  93851. /**
  93852. * This function MUST be overwritten by the different WebVR cameras available.
  93853. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93854. * @hidden
  93855. */
  93856. _getWebVRProjectionMatrix(): Matrix;
  93857. /**
  93858. * This function MUST be overwritten by the different WebVR cameras available.
  93859. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93860. * @hidden
  93861. */
  93862. _getWebVRViewMatrix(): Matrix;
  93863. /** @hidden */
  93864. setCameraRigParameter(name: string, value: any): void;
  93865. /**
  93866. * needs to be overridden by children so sub has required properties to be copied
  93867. * @hidden
  93868. */
  93869. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93870. /**
  93871. * May need to be overridden by children
  93872. * @hidden
  93873. */
  93874. _updateRigCameras(): void;
  93875. /** @hidden */
  93876. _setupInputs(): void;
  93877. /**
  93878. * Serialiaze the camera setup to a json represention
  93879. * @returns the JSON representation
  93880. */
  93881. serialize(): any;
  93882. /**
  93883. * Clones the current camera.
  93884. * @param name The cloned camera name
  93885. * @returns the cloned camera
  93886. */
  93887. clone(name: string): Camera;
  93888. /**
  93889. * Gets the direction of the camera relative to a given local axis.
  93890. * @param localAxis Defines the reference axis to provide a relative direction.
  93891. * @return the direction
  93892. */
  93893. getDirection(localAxis: Vector3): Vector3;
  93894. /**
  93895. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93896. * @param localAxis Defines the reference axis to provide a relative direction.
  93897. * @param result Defines the vector to store the result in
  93898. */
  93899. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93900. /**
  93901. * Gets a camera constructor for a given camera type
  93902. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93903. * @param name The name of the camera the result will be able to instantiate
  93904. * @param scene The scene the result will construct the camera in
  93905. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93906. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93907. * @returns a factory method to construc the camera
  93908. */
  93909. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93910. /**
  93911. * Compute the world matrix of the camera.
  93912. * @returns the camera workd matrix
  93913. */
  93914. computeWorldMatrix(): Matrix;
  93915. /**
  93916. * Parse a JSON and creates the camera from the parsed information
  93917. * @param parsedCamera The JSON to parse
  93918. * @param scene The scene to instantiate the camera in
  93919. * @returns the newly constructed camera
  93920. */
  93921. static Parse(parsedCamera: any, scene: Scene): Camera;
  93922. }
  93923. }
  93924. declare module BABYLON {
  93925. /**
  93926. * Interface for any object that can request an animation frame
  93927. */
  93928. export interface ICustomAnimationFrameRequester {
  93929. /**
  93930. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93931. */
  93932. renderFunction?: Function;
  93933. /**
  93934. * Called to request the next frame to render to
  93935. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93936. */
  93937. requestAnimationFrame: Function;
  93938. /**
  93939. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93940. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93941. */
  93942. requestID?: number;
  93943. }
  93944. /**
  93945. * Interface containing an array of animations
  93946. */
  93947. export interface IAnimatable {
  93948. /**
  93949. * Array of animations
  93950. */
  93951. animations: Nullable<Array<Animation>>;
  93952. }
  93953. /** Interface used by value gradients (color, factor, ...) */
  93954. export interface IValueGradient {
  93955. /**
  93956. * Gets or sets the gradient value (between 0 and 1)
  93957. */
  93958. gradient: number;
  93959. }
  93960. /** Class used to store color4 gradient */
  93961. export class ColorGradient implements IValueGradient {
  93962. /**
  93963. * Gets or sets the gradient value (between 0 and 1)
  93964. */
  93965. gradient: number;
  93966. /**
  93967. * Gets or sets first associated color
  93968. */
  93969. color1: Color4;
  93970. /**
  93971. * Gets or sets second associated color
  93972. */
  93973. color2?: Color4;
  93974. /**
  93975. * Will get a color picked randomly between color1 and color2.
  93976. * If color2 is undefined then color1 will be used
  93977. * @param result defines the target Color4 to store the result in
  93978. */
  93979. getColorToRef(result: Color4): void;
  93980. }
  93981. /** Class used to store color 3 gradient */
  93982. export class Color3Gradient implements IValueGradient {
  93983. /**
  93984. * Gets or sets the gradient value (between 0 and 1)
  93985. */
  93986. gradient: number;
  93987. /**
  93988. * Gets or sets the associated color
  93989. */
  93990. color: Color3;
  93991. }
  93992. /** Class used to store factor gradient */
  93993. export class FactorGradient implements IValueGradient {
  93994. /**
  93995. * Gets or sets the gradient value (between 0 and 1)
  93996. */
  93997. gradient: number;
  93998. /**
  93999. * Gets or sets first associated factor
  94000. */
  94001. factor1: number;
  94002. /**
  94003. * Gets or sets second associated factor
  94004. */
  94005. factor2?: number;
  94006. /**
  94007. * Will get a number picked randomly between factor1 and factor2.
  94008. * If factor2 is undefined then factor1 will be used
  94009. * @returns the picked number
  94010. */
  94011. getFactor(): number;
  94012. }
  94013. /**
  94014. * @ignore
  94015. * Application error to support additional information when loading a file
  94016. */
  94017. export class LoadFileError extends Error {
  94018. /** defines the optional web request */
  94019. request?: WebRequest | undefined;
  94020. private static _setPrototypeOf;
  94021. /**
  94022. * Creates a new LoadFileError
  94023. * @param message defines the message of the error
  94024. * @param request defines the optional web request
  94025. */
  94026. constructor(message: string,
  94027. /** defines the optional web request */
  94028. request?: WebRequest | undefined);
  94029. }
  94030. /**
  94031. * Class used to define a retry strategy when error happens while loading assets
  94032. */
  94033. export class RetryStrategy {
  94034. /**
  94035. * Function used to defines an exponential back off strategy
  94036. * @param maxRetries defines the maximum number of retries (3 by default)
  94037. * @param baseInterval defines the interval between retries
  94038. * @returns the strategy function to use
  94039. */
  94040. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  94041. }
  94042. /**
  94043. * File request interface
  94044. */
  94045. export interface IFileRequest {
  94046. /**
  94047. * Raised when the request is complete (success or error).
  94048. */
  94049. onCompleteObservable: Observable<IFileRequest>;
  94050. /**
  94051. * Aborts the request for a file.
  94052. */
  94053. abort: () => void;
  94054. }
  94055. /**
  94056. * Class containing a set of static utilities functions
  94057. */
  94058. export class Tools {
  94059. /**
  94060. * Gets or sets the base URL to use to load assets
  94061. */
  94062. static BaseUrl: string;
  94063. /**
  94064. * Enable/Disable Custom HTTP Request Headers globally.
  94065. * default = false
  94066. * @see CustomRequestHeaders
  94067. */
  94068. static UseCustomRequestHeaders: boolean;
  94069. /**
  94070. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  94071. * i.e. when loading files, where the server/service expects an Authorization header
  94072. */
  94073. static CustomRequestHeaders: {
  94074. [key: string]: string;
  94075. };
  94076. /**
  94077. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  94078. */
  94079. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  94080. /**
  94081. * Default behaviour for cors in the application.
  94082. * It can be a string if the expected behavior is identical in the entire app.
  94083. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  94084. */
  94085. static CorsBehavior: string | ((url: string | string[]) => string);
  94086. /**
  94087. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  94088. * @ignorenaming
  94089. */
  94090. static UseFallbackTexture: boolean;
  94091. /**
  94092. * Use this object to register external classes like custom textures or material
  94093. * to allow the laoders to instantiate them
  94094. */
  94095. static RegisteredExternalClasses: {
  94096. [key: string]: Object;
  94097. };
  94098. /**
  94099. * Texture content used if a texture cannot loaded
  94100. * @ignorenaming
  94101. */
  94102. static fallbackTexture: string;
  94103. /**
  94104. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  94105. * @param u defines the coordinate on X axis
  94106. * @param v defines the coordinate on Y axis
  94107. * @param width defines the width of the source data
  94108. * @param height defines the height of the source data
  94109. * @param pixels defines the source byte array
  94110. * @param color defines the output color
  94111. */
  94112. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  94113. /**
  94114. * Interpolates between a and b via alpha
  94115. * @param a The lower value (returned when alpha = 0)
  94116. * @param b The upper value (returned when alpha = 1)
  94117. * @param alpha The interpolation-factor
  94118. * @return The mixed value
  94119. */
  94120. static Mix(a: number, b: number, alpha: number): number;
  94121. /**
  94122. * Tries to instantiate a new object from a given class name
  94123. * @param className defines the class name to instantiate
  94124. * @returns the new object or null if the system was not able to do the instantiation
  94125. */
  94126. static Instantiate(className: string): any;
  94127. /**
  94128. * Provides a slice function that will work even on IE
  94129. * @param data defines the array to slice
  94130. * @param start defines the start of the data (optional)
  94131. * @param end defines the end of the data (optional)
  94132. * @returns the new sliced array
  94133. */
  94134. static Slice<T>(data: T, start?: number, end?: number): T;
  94135. /**
  94136. * Polyfill for setImmediate
  94137. * @param action defines the action to execute after the current execution block
  94138. */
  94139. static SetImmediate(action: () => void): void;
  94140. /**
  94141. * Function indicating if a number is an exponent of 2
  94142. * @param value defines the value to test
  94143. * @returns true if the value is an exponent of 2
  94144. */
  94145. static IsExponentOfTwo(value: number): boolean;
  94146. private static _tmpFloatArray;
  94147. /**
  94148. * Returns the nearest 32-bit single precision float representation of a Number
  94149. * @param value A Number. If the parameter is of a different type, it will get converted
  94150. * to a number or to NaN if it cannot be converted
  94151. * @returns number
  94152. */
  94153. static FloatRound(value: number): number;
  94154. /**
  94155. * Find the next highest power of two.
  94156. * @param x Number to start search from.
  94157. * @return Next highest power of two.
  94158. */
  94159. static CeilingPOT(x: number): number;
  94160. /**
  94161. * Find the next lowest power of two.
  94162. * @param x Number to start search from.
  94163. * @return Next lowest power of two.
  94164. */
  94165. static FloorPOT(x: number): number;
  94166. /**
  94167. * Find the nearest power of two.
  94168. * @param x Number to start search from.
  94169. * @return Next nearest power of two.
  94170. */
  94171. static NearestPOT(x: number): number;
  94172. /**
  94173. * Get the closest exponent of two
  94174. * @param value defines the value to approximate
  94175. * @param max defines the maximum value to return
  94176. * @param mode defines how to define the closest value
  94177. * @returns closest exponent of two of the given value
  94178. */
  94179. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  94180. /**
  94181. * Extracts the filename from a path
  94182. * @param path defines the path to use
  94183. * @returns the filename
  94184. */
  94185. static GetFilename(path: string): string;
  94186. /**
  94187. * Extracts the "folder" part of a path (everything before the filename).
  94188. * @param uri The URI to extract the info from
  94189. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  94190. * @returns The "folder" part of the path
  94191. */
  94192. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  94193. /**
  94194. * Extracts text content from a DOM element hierarchy
  94195. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  94196. */
  94197. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  94198. /**
  94199. * Convert an angle in radians to degrees
  94200. * @param angle defines the angle to convert
  94201. * @returns the angle in degrees
  94202. */
  94203. static ToDegrees(angle: number): number;
  94204. /**
  94205. * Convert an angle in degrees to radians
  94206. * @param angle defines the angle to convert
  94207. * @returns the angle in radians
  94208. */
  94209. static ToRadians(angle: number): number;
  94210. /**
  94211. * Encode a buffer to a base64 string
  94212. * @param buffer defines the buffer to encode
  94213. * @returns the encoded string
  94214. */
  94215. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  94216. /**
  94217. * Extracts minimum and maximum values from a list of indexed positions
  94218. * @param positions defines the positions to use
  94219. * @param indices defines the indices to the positions
  94220. * @param indexStart defines the start index
  94221. * @param indexCount defines the end index
  94222. * @param bias defines bias value to add to the result
  94223. * @return minimum and maximum values
  94224. */
  94225. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  94226. minimum: Vector3;
  94227. maximum: Vector3;
  94228. };
  94229. /**
  94230. * Extracts minimum and maximum values from a list of positions
  94231. * @param positions defines the positions to use
  94232. * @param start defines the start index in the positions array
  94233. * @param count defines the number of positions to handle
  94234. * @param bias defines bias value to add to the result
  94235. * @param stride defines the stride size to use (distance between two positions in the positions array)
  94236. * @return minimum and maximum values
  94237. */
  94238. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  94239. minimum: Vector3;
  94240. maximum: Vector3;
  94241. };
  94242. /**
  94243. * Returns an array if obj is not an array
  94244. * @param obj defines the object to evaluate as an array
  94245. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  94246. * @returns either obj directly if obj is an array or a new array containing obj
  94247. */
  94248. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  94249. /**
  94250. * Gets the pointer prefix to use
  94251. * @returns "pointer" if touch is enabled. Else returns "mouse"
  94252. */
  94253. static GetPointerPrefix(): string;
  94254. /**
  94255. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  94256. * @param func - the function to be called
  94257. * @param requester - the object that will request the next frame. Falls back to window.
  94258. * @returns frame number
  94259. */
  94260. static QueueNewFrame(func: () => void, requester?: any): number;
  94261. /**
  94262. * Ask the browser to promote the current element to fullscreen rendering mode
  94263. * @param element defines the DOM element to promote
  94264. */
  94265. static RequestFullscreen(element: HTMLElement): void;
  94266. /**
  94267. * Asks the browser to exit fullscreen mode
  94268. */
  94269. static ExitFullscreen(): void;
  94270. /**
  94271. * Ask the browser to promote the current element to pointerlock mode
  94272. * @param element defines the DOM element to promote
  94273. */
  94274. static RequestPointerlock(element: HTMLElement): void;
  94275. /**
  94276. * Asks the browser to exit pointerlock mode
  94277. */
  94278. static ExitPointerlock(): void;
  94279. /**
  94280. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  94281. * @param url define the url we are trying
  94282. * @param element define the dom element where to configure the cors policy
  94283. */
  94284. static SetCorsBehavior(url: string | string[], element: {
  94285. crossOrigin: string | null;
  94286. }): void;
  94287. /**
  94288. * Removes unwanted characters from an url
  94289. * @param url defines the url to clean
  94290. * @returns the cleaned url
  94291. */
  94292. static CleanUrl(url: string): string;
  94293. /**
  94294. * Gets or sets a function used to pre-process url before using them to load assets
  94295. */
  94296. static PreprocessUrl: (url: string) => string;
  94297. /**
  94298. * Loads an image as an HTMLImageElement.
  94299. * @param input url string, ArrayBuffer, or Blob to load
  94300. * @param onLoad callback called when the image successfully loads
  94301. * @param onError callback called when the image fails to load
  94302. * @param offlineProvider offline provider for caching
  94303. * @returns the HTMLImageElement of the loaded image
  94304. */
  94305. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  94306. /**
  94307. * Loads a file
  94308. * @param url url string, ArrayBuffer, or Blob to load
  94309. * @param onSuccess callback called when the file successfully loads
  94310. * @param onProgress callback called while file is loading (if the server supports this mode)
  94311. * @param offlineProvider defines the offline provider for caching
  94312. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94313. * @param onError callback called when the file fails to load
  94314. * @returns a file request object
  94315. */
  94316. 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;
  94317. /**
  94318. * Loads a file from a url
  94319. * @param url the file url to load
  94320. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94321. */
  94322. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94323. /**
  94324. * Load a script (identified by an url). When the url returns, the
  94325. * content of this file is added into a new script element, attached to the DOM (body element)
  94326. * @param scriptUrl defines the url of the script to laod
  94327. * @param onSuccess defines the callback called when the script is loaded
  94328. * @param onError defines the callback to call if an error occurs
  94329. * @param scriptId defines the id of the script element
  94330. */
  94331. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94332. /**
  94333. * Load an asynchronous script (identified by an url). When the url returns, the
  94334. * content of this file is added into a new script element, attached to the DOM (body element)
  94335. * @param scriptUrl defines the url of the script to laod
  94336. * @param scriptId defines the id of the script element
  94337. * @returns a promise request object
  94338. */
  94339. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94340. /**
  94341. * Loads a file from a blob
  94342. * @param fileToLoad defines the blob to use
  94343. * @param callback defines the callback to call when data is loaded
  94344. * @param progressCallback defines the callback to call during loading process
  94345. * @returns a file request object
  94346. */
  94347. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94348. /**
  94349. * Loads a file
  94350. * @param fileToLoad defines the file to load
  94351. * @param callback defines the callback to call when data is loaded
  94352. * @param progressCallBack defines the callback to call during loading process
  94353. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94354. * @returns a file request object
  94355. */
  94356. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94357. /**
  94358. * Creates a data url from a given string content
  94359. * @param content defines the content to convert
  94360. * @returns the new data url link
  94361. */
  94362. static FileAsURL(content: string): string;
  94363. /**
  94364. * Format the given number to a specific decimal format
  94365. * @param value defines the number to format
  94366. * @param decimals defines the number of decimals to use
  94367. * @returns the formatted string
  94368. */
  94369. static Format(value: number, decimals?: number): string;
  94370. /**
  94371. * Checks if a given vector is inside a specific range
  94372. * @param v defines the vector to test
  94373. * @param min defines the minimum range
  94374. * @param max defines the maximum range
  94375. */
  94376. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94377. /**
  94378. * Tries to copy an object by duplicating every property
  94379. * @param source defines the source object
  94380. * @param destination defines the target object
  94381. * @param doNotCopyList defines a list of properties to avoid
  94382. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94383. */
  94384. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94385. /**
  94386. * Gets a boolean indicating if the given object has no own property
  94387. * @param obj defines the object to test
  94388. * @returns true if object has no own property
  94389. */
  94390. static IsEmpty(obj: any): boolean;
  94391. /**
  94392. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94393. * @param str Source string
  94394. * @param suffix Suffix to search for in the source string
  94395. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94396. */
  94397. static EndsWith(str: string, suffix: string): boolean;
  94398. /**
  94399. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94400. * @param str Source string
  94401. * @param suffix Suffix to search for in the source string
  94402. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94403. */
  94404. static StartsWith(str: string, suffix: string): boolean;
  94405. /**
  94406. * Function used to register events at window level
  94407. * @param events defines the events to register
  94408. */
  94409. static RegisterTopRootEvents(events: {
  94410. name: string;
  94411. handler: Nullable<(e: FocusEvent) => any>;
  94412. }[]): void;
  94413. /**
  94414. * Function used to unregister events from window level
  94415. * @param events defines the events to unregister
  94416. */
  94417. static UnregisterTopRootEvents(events: {
  94418. name: string;
  94419. handler: Nullable<(e: FocusEvent) => any>;
  94420. }[]): void;
  94421. /**
  94422. * @ignore
  94423. */
  94424. static _ScreenshotCanvas: HTMLCanvasElement;
  94425. /**
  94426. * Dumps the current bound framebuffer
  94427. * @param width defines the rendering width
  94428. * @param height defines the rendering height
  94429. * @param engine defines the hosting engine
  94430. * @param successCallback defines the callback triggered once the data are available
  94431. * @param mimeType defines the mime type of the result
  94432. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94433. */
  94434. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94435. /**
  94436. * Converts the canvas data to blob.
  94437. * This acts as a polyfill for browsers not supporting the to blob function.
  94438. * @param canvas Defines the canvas to extract the data from
  94439. * @param successCallback Defines the callback triggered once the data are available
  94440. * @param mimeType Defines the mime type of the result
  94441. */
  94442. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94443. /**
  94444. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94445. * @param successCallback defines the callback triggered once the data are available
  94446. * @param mimeType defines the mime type of the result
  94447. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94448. */
  94449. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94450. /**
  94451. * Downloads a blob in the browser
  94452. * @param blob defines the blob to download
  94453. * @param fileName defines the name of the downloaded file
  94454. */
  94455. static Download(blob: Blob, fileName: string): void;
  94456. /**
  94457. * Captures a screenshot of the current rendering
  94458. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94459. * @param engine defines the rendering engine
  94460. * @param camera defines the source camera
  94461. * @param size This parameter can be set to a single number or to an object with the
  94462. * following (optional) properties: precision, width, height. If a single number is passed,
  94463. * it will be used for both width and height. If an object is passed, the screenshot size
  94464. * will be derived from the parameters. The precision property is a multiplier allowing
  94465. * rendering at a higher or lower resolution
  94466. * @param successCallback defines the callback receives a single parameter which contains the
  94467. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94468. * src parameter of an <img> to display it
  94469. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94470. * Check your browser for supported MIME types
  94471. */
  94472. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94473. /**
  94474. * Generates an image screenshot from the specified camera.
  94475. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94476. * @param engine The engine to use for rendering
  94477. * @param camera The camera to use for rendering
  94478. * @param size This parameter can be set to a single number or to an object with the
  94479. * following (optional) properties: precision, width, height. If a single number is passed,
  94480. * it will be used for both width and height. If an object is passed, the screenshot size
  94481. * will be derived from the parameters. The precision property is a multiplier allowing
  94482. * rendering at a higher or lower resolution
  94483. * @param successCallback The callback receives a single parameter which contains the
  94484. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94485. * src parameter of an <img> to display it
  94486. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94487. * Check your browser for supported MIME types
  94488. * @param samples Texture samples (default: 1)
  94489. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94490. * @param fileName A name for for the downloaded file.
  94491. */
  94492. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94493. /**
  94494. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94495. * Be aware Math.random() could cause collisions, but:
  94496. * "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"
  94497. * @returns a pseudo random id
  94498. */
  94499. static RandomId(): string;
  94500. /**
  94501. * Test if the given uri is a base64 string
  94502. * @param uri The uri to test
  94503. * @return True if the uri is a base64 string or false otherwise
  94504. */
  94505. static IsBase64(uri: string): boolean;
  94506. /**
  94507. * Decode the given base64 uri.
  94508. * @param uri The uri to decode
  94509. * @return The decoded base64 data.
  94510. */
  94511. static DecodeBase64(uri: string): ArrayBuffer;
  94512. /**
  94513. * Gets the absolute url.
  94514. * @param url the input url
  94515. * @return the absolute url
  94516. */
  94517. static GetAbsoluteUrl(url: string): string;
  94518. /**
  94519. * No log
  94520. */
  94521. static readonly NoneLogLevel: number;
  94522. /**
  94523. * Only message logs
  94524. */
  94525. static readonly MessageLogLevel: number;
  94526. /**
  94527. * Only warning logs
  94528. */
  94529. static readonly WarningLogLevel: number;
  94530. /**
  94531. * Only error logs
  94532. */
  94533. static readonly ErrorLogLevel: number;
  94534. /**
  94535. * All logs
  94536. */
  94537. static readonly AllLogLevel: number;
  94538. /**
  94539. * Gets a value indicating the number of loading errors
  94540. * @ignorenaming
  94541. */
  94542. static readonly errorsCount: number;
  94543. /**
  94544. * Callback called when a new log is added
  94545. */
  94546. static OnNewCacheEntry: (entry: string) => void;
  94547. /**
  94548. * Log a message to the console
  94549. * @param message defines the message to log
  94550. */
  94551. static Log(message: string): void;
  94552. /**
  94553. * Write a warning message to the console
  94554. * @param message defines the message to log
  94555. */
  94556. static Warn(message: string): void;
  94557. /**
  94558. * Write an error message to the console
  94559. * @param message defines the message to log
  94560. */
  94561. static Error(message: string): void;
  94562. /**
  94563. * Gets current log cache (list of logs)
  94564. */
  94565. static readonly LogCache: string;
  94566. /**
  94567. * Clears the log cache
  94568. */
  94569. static ClearLogCache(): void;
  94570. /**
  94571. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94572. */
  94573. static LogLevels: number;
  94574. /**
  94575. * Checks if the loaded document was accessed via `file:`-Protocol.
  94576. * @returns boolean
  94577. */
  94578. static IsFileURL(): boolean;
  94579. /**
  94580. * Checks if the window object exists
  94581. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94582. */
  94583. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94584. /**
  94585. * No performance log
  94586. */
  94587. static readonly PerformanceNoneLogLevel: number;
  94588. /**
  94589. * Use user marks to log performance
  94590. */
  94591. static readonly PerformanceUserMarkLogLevel: number;
  94592. /**
  94593. * Log performance to the console
  94594. */
  94595. static readonly PerformanceConsoleLogLevel: number;
  94596. private static _performance;
  94597. /**
  94598. * Sets the current performance log level
  94599. */
  94600. static PerformanceLogLevel: number;
  94601. private static _StartPerformanceCounterDisabled;
  94602. private static _EndPerformanceCounterDisabled;
  94603. private static _StartUserMark;
  94604. private static _EndUserMark;
  94605. private static _StartPerformanceConsole;
  94606. private static _EndPerformanceConsole;
  94607. /**
  94608. * Starts a performance counter
  94609. */
  94610. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94611. /**
  94612. * Ends a specific performance coutner
  94613. */
  94614. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94615. /**
  94616. * Gets either window.performance.now() if supported or Date.now() else
  94617. */
  94618. static readonly Now: number;
  94619. /**
  94620. * This method will return the name of the class used to create the instance of the given object.
  94621. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94622. * @param object the object to get the class name from
  94623. * @param isType defines if the object is actually a type
  94624. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94625. */
  94626. static GetClassName(object: any, isType?: boolean): string;
  94627. /**
  94628. * Gets the first element of an array satisfying a given predicate
  94629. * @param array defines the array to browse
  94630. * @param predicate defines the predicate to use
  94631. * @returns null if not found or the element
  94632. */
  94633. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94634. /**
  94635. * This method will return the name of the full name of the class, including its owning module (if any).
  94636. * 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).
  94637. * @param object the object to get the class name from
  94638. * @param isType defines if the object is actually a type
  94639. * @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.
  94640. * @ignorenaming
  94641. */
  94642. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94643. /**
  94644. * Returns a promise that resolves after the given amount of time.
  94645. * @param delay Number of milliseconds to delay
  94646. * @returns Promise that resolves after the given amount of time
  94647. */
  94648. static DelayAsync(delay: number): Promise<void>;
  94649. /**
  94650. * Gets the current gradient from an array of IValueGradient
  94651. * @param ratio defines the current ratio to get
  94652. * @param gradients defines the array of IValueGradient
  94653. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94654. */
  94655. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94656. }
  94657. /**
  94658. * This class is used to track a performance counter which is number based.
  94659. * The user has access to many properties which give statistics of different nature.
  94660. *
  94661. * The implementer can track two kinds of Performance Counter: time and count.
  94662. * 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.
  94663. * 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.
  94664. */
  94665. export class PerfCounter {
  94666. /**
  94667. * Gets or sets a global boolean to turn on and off all the counters
  94668. */
  94669. static Enabled: boolean;
  94670. /**
  94671. * Returns the smallest value ever
  94672. */
  94673. readonly min: number;
  94674. /**
  94675. * Returns the biggest value ever
  94676. */
  94677. readonly max: number;
  94678. /**
  94679. * Returns the average value since the performance counter is running
  94680. */
  94681. readonly average: number;
  94682. /**
  94683. * Returns the average value of the last second the counter was monitored
  94684. */
  94685. readonly lastSecAverage: number;
  94686. /**
  94687. * Returns the current value
  94688. */
  94689. readonly current: number;
  94690. /**
  94691. * Gets the accumulated total
  94692. */
  94693. readonly total: number;
  94694. /**
  94695. * Gets the total value count
  94696. */
  94697. readonly count: number;
  94698. /**
  94699. * Creates a new counter
  94700. */
  94701. constructor();
  94702. /**
  94703. * Call this method to start monitoring a new frame.
  94704. * 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.
  94705. */
  94706. fetchNewFrame(): void;
  94707. /**
  94708. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94709. * @param newCount the count value to add to the monitored count
  94710. * @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.
  94711. */
  94712. addCount(newCount: number, fetchResult: boolean): void;
  94713. /**
  94714. * Start monitoring this performance counter
  94715. */
  94716. beginMonitoring(): void;
  94717. /**
  94718. * Compute the time lapsed since the previous beginMonitoring() call.
  94719. * @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
  94720. */
  94721. endMonitoring(newFrame?: boolean): void;
  94722. private _fetchResult;
  94723. private _startMonitoringTime;
  94724. private _min;
  94725. private _max;
  94726. private _average;
  94727. private _current;
  94728. private _totalValueCount;
  94729. private _totalAccumulated;
  94730. private _lastSecAverage;
  94731. private _lastSecAccumulated;
  94732. private _lastSecTime;
  94733. private _lastSecValueCount;
  94734. }
  94735. /**
  94736. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94737. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94738. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94739. * @param name The name of the class, case should be preserved
  94740. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94741. */
  94742. export function className(name: string, module?: string): (target: Object) => void;
  94743. /**
  94744. * An implementation of a loop for asynchronous functions.
  94745. */
  94746. export class AsyncLoop {
  94747. /**
  94748. * Defines the number of iterations for the loop
  94749. */
  94750. iterations: number;
  94751. /**
  94752. * Defines the current index of the loop.
  94753. */
  94754. index: number;
  94755. private _done;
  94756. private _fn;
  94757. private _successCallback;
  94758. /**
  94759. * Constructor.
  94760. * @param iterations the number of iterations.
  94761. * @param func the function to run each iteration
  94762. * @param successCallback the callback that will be called upon succesful execution
  94763. * @param offset starting offset.
  94764. */
  94765. constructor(
  94766. /**
  94767. * Defines the number of iterations for the loop
  94768. */
  94769. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94770. /**
  94771. * Execute the next iteration. Must be called after the last iteration was finished.
  94772. */
  94773. executeNext(): void;
  94774. /**
  94775. * Break the loop and run the success callback.
  94776. */
  94777. breakLoop(): void;
  94778. /**
  94779. * Create and run an async loop.
  94780. * @param iterations the number of iterations.
  94781. * @param fn the function to run each iteration
  94782. * @param successCallback the callback that will be called upon succesful execution
  94783. * @param offset starting offset.
  94784. * @returns the created async loop object
  94785. */
  94786. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94787. /**
  94788. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94789. * @param iterations total number of iterations
  94790. * @param syncedIterations number of synchronous iterations in each async iteration.
  94791. * @param fn the function to call each iteration.
  94792. * @param callback a success call back that will be called when iterating stops.
  94793. * @param breakFunction a break condition (optional)
  94794. * @param timeout timeout settings for the setTimeout function. default - 0.
  94795. * @returns the created async loop object
  94796. */
  94797. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94798. }
  94799. }
  94800. declare module BABYLON {
  94801. /** @hidden */
  94802. export interface ICollisionCoordinator {
  94803. createCollider(): Collider;
  94804. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94805. init(scene: Scene): void;
  94806. }
  94807. /** @hidden */
  94808. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94809. private _scene;
  94810. private _scaledPosition;
  94811. private _scaledVelocity;
  94812. private _finalPosition;
  94813. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94814. createCollider(): Collider;
  94815. init(scene: Scene): void;
  94816. private _collideWithWorld;
  94817. }
  94818. }
  94819. declare module BABYLON {
  94820. /**
  94821. * Class used to manage all inputs for the scene.
  94822. */
  94823. export class InputManager {
  94824. /** The distance in pixel that you have to move to prevent some events */
  94825. static DragMovementThreshold: number;
  94826. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94827. static LongPressDelay: number;
  94828. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94829. static DoubleClickDelay: number;
  94830. /** If you need to check double click without raising a single click at first click, enable this flag */
  94831. static ExclusiveDoubleClickMode: boolean;
  94832. private _wheelEventName;
  94833. private _onPointerMove;
  94834. private _onPointerDown;
  94835. private _onPointerUp;
  94836. private _initClickEvent;
  94837. private _initActionManager;
  94838. private _delayedSimpleClick;
  94839. private _delayedSimpleClickTimeout;
  94840. private _previousDelayedSimpleClickTimeout;
  94841. private _meshPickProceed;
  94842. private _previousButtonPressed;
  94843. private _currentPickResult;
  94844. private _previousPickResult;
  94845. private _totalPointersPressed;
  94846. private _doubleClickOccured;
  94847. private _pointerOverMesh;
  94848. private _pickedDownMesh;
  94849. private _pickedUpMesh;
  94850. private _pointerX;
  94851. private _pointerY;
  94852. private _unTranslatedPointerX;
  94853. private _unTranslatedPointerY;
  94854. private _startingPointerPosition;
  94855. private _previousStartingPointerPosition;
  94856. private _startingPointerTime;
  94857. private _previousStartingPointerTime;
  94858. private _pointerCaptures;
  94859. private _onKeyDown;
  94860. private _onKeyUp;
  94861. private _onCanvasFocusObserver;
  94862. private _onCanvasBlurObserver;
  94863. private _scene;
  94864. /**
  94865. * Creates a new InputManager
  94866. * @param scene defines the hosting scene
  94867. */
  94868. constructor(scene: Scene);
  94869. /**
  94870. * Gets the mesh that is currently under the pointer
  94871. */
  94872. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94873. /**
  94874. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94875. */
  94876. readonly unTranslatedPointer: Vector2;
  94877. /**
  94878. * Gets or sets the current on-screen X position of the pointer
  94879. */
  94880. pointerX: number;
  94881. /**
  94882. * Gets or sets the current on-screen Y position of the pointer
  94883. */
  94884. pointerY: number;
  94885. private _updatePointerPosition;
  94886. private _processPointerMove;
  94887. private _setRayOnPointerInfo;
  94888. private _checkPrePointerObservable;
  94889. /**
  94890. * Use this method to simulate a pointer move on a mesh
  94891. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94892. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94893. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94894. */
  94895. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94896. /**
  94897. * Use this method to simulate a pointer down on a mesh
  94898. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94899. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94900. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94901. */
  94902. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94903. private _processPointerDown;
  94904. /** @hidden */
  94905. _isPointerSwiping(): boolean;
  94906. /**
  94907. * Use this method to simulate a pointer up on a mesh
  94908. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94909. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94910. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94911. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94912. */
  94913. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94914. private _processPointerUp;
  94915. /**
  94916. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94917. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94918. * @returns true if the pointer was captured
  94919. */
  94920. isPointerCaptured(pointerId?: number): boolean;
  94921. /**
  94922. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94923. * @param attachUp defines if you want to attach events to pointerup
  94924. * @param attachDown defines if you want to attach events to pointerdown
  94925. * @param attachMove defines if you want to attach events to pointermove
  94926. */
  94927. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94928. /**
  94929. * Detaches all event handlers
  94930. */
  94931. detachControl(): void;
  94932. /**
  94933. * Force the value of meshUnderPointer
  94934. * @param mesh defines the mesh to use
  94935. */
  94936. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94937. /**
  94938. * Gets the mesh under the pointer
  94939. * @returns a Mesh or null if no mesh is under the pointer
  94940. */
  94941. getPointerOverMesh(): Nullable<AbstractMesh>;
  94942. }
  94943. }
  94944. declare module BABYLON {
  94945. /**
  94946. * This class defines the direct association between an animation and a target
  94947. */
  94948. export class TargetedAnimation {
  94949. /**
  94950. * Animation to perform
  94951. */
  94952. animation: Animation;
  94953. /**
  94954. * Target to animate
  94955. */
  94956. target: any;
  94957. /**
  94958. * Serialize the object
  94959. * @returns the JSON object representing the current entity
  94960. */
  94961. serialize(): any;
  94962. }
  94963. /**
  94964. * Use this class to create coordinated animations on multiple targets
  94965. */
  94966. export class AnimationGroup implements IDisposable {
  94967. /** The name of the animation group */
  94968. name: string;
  94969. private _scene;
  94970. private _targetedAnimations;
  94971. private _animatables;
  94972. private _from;
  94973. private _to;
  94974. private _isStarted;
  94975. private _isPaused;
  94976. private _speedRatio;
  94977. private _loopAnimation;
  94978. /**
  94979. * Gets or sets the unique id of the node
  94980. */
  94981. uniqueId: number;
  94982. /**
  94983. * This observable will notify when one animation have ended
  94984. */
  94985. onAnimationEndObservable: Observable<TargetedAnimation>;
  94986. /**
  94987. * Observer raised when one animation loops
  94988. */
  94989. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94990. /**
  94991. * This observable will notify when all animations have ended.
  94992. */
  94993. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94994. /**
  94995. * This observable will notify when all animations have paused.
  94996. */
  94997. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94998. /**
  94999. * This observable will notify when all animations are playing.
  95000. */
  95001. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  95002. /**
  95003. * Gets the first frame
  95004. */
  95005. readonly from: number;
  95006. /**
  95007. * Gets the last frame
  95008. */
  95009. readonly to: number;
  95010. /**
  95011. * Define if the animations are started
  95012. */
  95013. readonly isStarted: boolean;
  95014. /**
  95015. * Gets a value indicating that the current group is playing
  95016. */
  95017. readonly isPlaying: boolean;
  95018. /**
  95019. * Gets or sets the speed ratio to use for all animations
  95020. */
  95021. /**
  95022. * Gets or sets the speed ratio to use for all animations
  95023. */
  95024. speedRatio: number;
  95025. /**
  95026. * Gets or sets if all animations should loop or not
  95027. */
  95028. loopAnimation: boolean;
  95029. /**
  95030. * Gets the targeted animations for this animation group
  95031. */
  95032. readonly targetedAnimations: Array<TargetedAnimation>;
  95033. /**
  95034. * returning the list of animatables controlled by this animation group.
  95035. */
  95036. readonly animatables: Array<Animatable>;
  95037. /**
  95038. * Instantiates a new Animation Group.
  95039. * This helps managing several animations at once.
  95040. * @see http://doc.babylonjs.com/how_to/group
  95041. * @param name Defines the name of the group
  95042. * @param scene Defines the scene the group belongs to
  95043. */
  95044. constructor(
  95045. /** The name of the animation group */
  95046. name: string, scene?: Nullable<Scene>);
  95047. /**
  95048. * Add an animation (with its target) in the group
  95049. * @param animation defines the animation we want to add
  95050. * @param target defines the target of the animation
  95051. * @returns the TargetedAnimation object
  95052. */
  95053. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  95054. /**
  95055. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  95056. * It can add constant keys at begin or end
  95057. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  95058. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  95059. * @returns the animation group
  95060. */
  95061. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  95062. /**
  95063. * Start all animations on given targets
  95064. * @param loop defines if animations must loop
  95065. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  95066. * @param from defines the from key (optional)
  95067. * @param to defines the to key (optional)
  95068. * @returns the current animation group
  95069. */
  95070. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  95071. /**
  95072. * Pause all animations
  95073. * @returns the animation group
  95074. */
  95075. pause(): AnimationGroup;
  95076. /**
  95077. * Play all animations to initial state
  95078. * This function will start() the animations if they were not started or will restart() them if they were paused
  95079. * @param loop defines if animations must loop
  95080. * @returns the animation group
  95081. */
  95082. play(loop?: boolean): AnimationGroup;
  95083. /**
  95084. * Reset all animations to initial state
  95085. * @returns the animation group
  95086. */
  95087. reset(): AnimationGroup;
  95088. /**
  95089. * Restart animations from key 0
  95090. * @returns the animation group
  95091. */
  95092. restart(): AnimationGroup;
  95093. /**
  95094. * Stop all animations
  95095. * @returns the animation group
  95096. */
  95097. stop(): AnimationGroup;
  95098. /**
  95099. * Set animation weight for all animatables
  95100. * @param weight defines the weight to use
  95101. * @return the animationGroup
  95102. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95103. */
  95104. setWeightForAllAnimatables(weight: number): AnimationGroup;
  95105. /**
  95106. * Synchronize and normalize all animatables with a source animatable
  95107. * @param root defines the root animatable to synchronize with
  95108. * @return the animationGroup
  95109. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95110. */
  95111. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  95112. /**
  95113. * Goes to a specific frame in this animation group
  95114. * @param frame the frame number to go to
  95115. * @return the animationGroup
  95116. */
  95117. goToFrame(frame: number): AnimationGroup;
  95118. /**
  95119. * Dispose all associated resources
  95120. */
  95121. dispose(): void;
  95122. private _checkAnimationGroupEnded;
  95123. /**
  95124. * Clone the current animation group and returns a copy
  95125. * @param newName defines the name of the new group
  95126. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  95127. * @returns the new aniamtion group
  95128. */
  95129. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  95130. /**
  95131. * Serializes the animationGroup to an object
  95132. * @returns Serialized object
  95133. */
  95134. serialize(): any;
  95135. /**
  95136. * Returns a new AnimationGroup object parsed from the source provided.
  95137. * @param parsedAnimationGroup defines the source
  95138. * @param scene defines the scene that will receive the animationGroup
  95139. * @returns a new AnimationGroup
  95140. */
  95141. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  95142. /**
  95143. * Returns the string "AnimationGroup"
  95144. * @returns "AnimationGroup"
  95145. */
  95146. getClassName(): string;
  95147. /**
  95148. * Creates a detailled string about the object
  95149. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  95150. * @returns a string representing the object
  95151. */
  95152. toString(fullDetails?: boolean): string;
  95153. }
  95154. }
  95155. declare module BABYLON {
  95156. /**
  95157. * Define an interface for all classes that will hold resources
  95158. */
  95159. export interface IDisposable {
  95160. /**
  95161. * Releases all held resources
  95162. */
  95163. dispose(): void;
  95164. }
  95165. /** Interface defining initialization parameters for Scene class */
  95166. export interface SceneOptions {
  95167. /**
  95168. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  95169. * It will improve performance when the number of geometries becomes important.
  95170. */
  95171. useGeometryUniqueIdsMap?: boolean;
  95172. /**
  95173. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  95174. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95175. */
  95176. useMaterialMeshMap?: boolean;
  95177. /**
  95178. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  95179. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95180. */
  95181. useClonedMeshhMap?: boolean;
  95182. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  95183. virtual?: boolean;
  95184. }
  95185. /**
  95186. * Represents a scene to be rendered by the engine.
  95187. * @see http://doc.babylonjs.com/features/scene
  95188. */
  95189. export class Scene extends AbstractScene implements IAnimatable {
  95190. private static _uniqueIdCounter;
  95191. /** The fog is deactivated */
  95192. static readonly FOGMODE_NONE: number;
  95193. /** The fog density is following an exponential function */
  95194. static readonly FOGMODE_EXP: number;
  95195. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  95196. static readonly FOGMODE_EXP2: number;
  95197. /** The fog density is following a linear function. */
  95198. static readonly FOGMODE_LINEAR: number;
  95199. /**
  95200. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  95201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95202. */
  95203. static MinDeltaTime: number;
  95204. /**
  95205. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  95206. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95207. */
  95208. static MaxDeltaTime: number;
  95209. /**
  95210. * Factory used to create the default material.
  95211. * @param name The name of the material to create
  95212. * @param scene The scene to create the material for
  95213. * @returns The default material
  95214. */
  95215. static DefaultMaterialFactory(scene: Scene): Material;
  95216. /**
  95217. * Factory used to create the a collision coordinator.
  95218. * @returns The collision coordinator
  95219. */
  95220. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  95221. /** @hidden */
  95222. _inputManager: InputManager;
  95223. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  95224. cameraToUseForPointers: Nullable<Camera>;
  95225. /** @hidden */
  95226. readonly _isScene: boolean;
  95227. /**
  95228. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  95229. */
  95230. autoClear: boolean;
  95231. /**
  95232. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  95233. */
  95234. autoClearDepthAndStencil: boolean;
  95235. /**
  95236. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  95237. */
  95238. clearColor: Color4;
  95239. /**
  95240. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  95241. */
  95242. ambientColor: Color3;
  95243. /**
  95244. * This is use to store the default BRDF lookup for PBR materials in your scene.
  95245. * It should only be one of the following (if not the default embedded one):
  95246. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  95247. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  95248. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  95249. * The material properties need to be setup according to the type of texture in use.
  95250. */
  95251. environmentBRDFTexture: BaseTexture;
  95252. /** @hidden */
  95253. protected _environmentTexture: Nullable<BaseTexture>;
  95254. /**
  95255. * Texture used in all pbr material as the reflection texture.
  95256. * As in the majority of the scene they are the same (exception for multi room and so on),
  95257. * this is easier to reference from here than from all the materials.
  95258. */
  95259. /**
  95260. * Texture used in all pbr material as the reflection texture.
  95261. * As in the majority of the scene they are the same (exception for multi room and so on),
  95262. * this is easier to set here than in all the materials.
  95263. */
  95264. environmentTexture: Nullable<BaseTexture>;
  95265. /** @hidden */
  95266. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95267. /**
  95268. * Default image processing configuration used either in the rendering
  95269. * Forward main pass or through the imageProcessingPostProcess if present.
  95270. * As in the majority of the scene they are the same (exception for multi camera),
  95271. * this is easier to reference from here than from all the materials and post process.
  95272. *
  95273. * No setter as we it is a shared configuration, you can set the values instead.
  95274. */
  95275. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  95276. private _forceWireframe;
  95277. /**
  95278. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  95279. */
  95280. forceWireframe: boolean;
  95281. private _forcePointsCloud;
  95282. /**
  95283. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  95284. */
  95285. forcePointsCloud: boolean;
  95286. /**
  95287. * Gets or sets the active clipplane 1
  95288. */
  95289. clipPlane: Nullable<Plane>;
  95290. /**
  95291. * Gets or sets the active clipplane 2
  95292. */
  95293. clipPlane2: Nullable<Plane>;
  95294. /**
  95295. * Gets or sets the active clipplane 3
  95296. */
  95297. clipPlane3: Nullable<Plane>;
  95298. /**
  95299. * Gets or sets the active clipplane 4
  95300. */
  95301. clipPlane4: Nullable<Plane>;
  95302. /**
  95303. * Gets or sets a boolean indicating if animations are enabled
  95304. */
  95305. animationsEnabled: boolean;
  95306. private _animationPropertiesOverride;
  95307. /**
  95308. * Gets or sets the animation properties override
  95309. */
  95310. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95311. /**
  95312. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95313. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95314. */
  95315. useConstantAnimationDeltaTime: boolean;
  95316. /**
  95317. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95318. * Please note that it requires to run a ray cast through the scene on every frame
  95319. */
  95320. constantlyUpdateMeshUnderPointer: boolean;
  95321. /**
  95322. * Defines the HTML cursor to use when hovering over interactive elements
  95323. */
  95324. hoverCursor: string;
  95325. /**
  95326. * Defines the HTML default cursor to use (empty by default)
  95327. */
  95328. defaultCursor: string;
  95329. /**
  95330. * This is used to call preventDefault() on pointer down
  95331. * in order to block unwanted artifacts like system double clicks
  95332. */
  95333. preventDefaultOnPointerDown: boolean;
  95334. /**
  95335. * This is used to call preventDefault() on pointer up
  95336. * in order to block unwanted artifacts like system double clicks
  95337. */
  95338. preventDefaultOnPointerUp: boolean;
  95339. /**
  95340. * Gets or sets user defined metadata
  95341. */
  95342. metadata: any;
  95343. /**
  95344. * For internal use only. Please do not use.
  95345. */
  95346. reservedDataStore: any;
  95347. /**
  95348. * Gets the name of the plugin used to load this scene (null by default)
  95349. */
  95350. loadingPluginName: string;
  95351. /**
  95352. * Use this array to add regular expressions used to disable offline support for specific urls
  95353. */
  95354. disableOfflineSupportExceptionRules: RegExp[];
  95355. /**
  95356. * An event triggered when the scene is disposed.
  95357. */
  95358. onDisposeObservable: Observable<Scene>;
  95359. private _onDisposeObserver;
  95360. /** Sets a function to be executed when this scene is disposed. */
  95361. onDispose: () => void;
  95362. /**
  95363. * An event triggered before rendering the scene (right after animations and physics)
  95364. */
  95365. onBeforeRenderObservable: Observable<Scene>;
  95366. private _onBeforeRenderObserver;
  95367. /** Sets a function to be executed before rendering this scene */
  95368. beforeRender: Nullable<() => void>;
  95369. /**
  95370. * An event triggered after rendering the scene
  95371. */
  95372. onAfterRenderObservable: Observable<Scene>;
  95373. /**
  95374. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95375. */
  95376. onAfterRenderCameraObservable: Observable<Camera>;
  95377. private _onAfterRenderObserver;
  95378. /** Sets a function to be executed after rendering this scene */
  95379. afterRender: Nullable<() => void>;
  95380. /**
  95381. * An event triggered before animating the scene
  95382. */
  95383. onBeforeAnimationsObservable: Observable<Scene>;
  95384. /**
  95385. * An event triggered after animations processing
  95386. */
  95387. onAfterAnimationsObservable: Observable<Scene>;
  95388. /**
  95389. * An event triggered before draw calls are ready to be sent
  95390. */
  95391. onBeforeDrawPhaseObservable: Observable<Scene>;
  95392. /**
  95393. * An event triggered after draw calls have been sent
  95394. */
  95395. onAfterDrawPhaseObservable: Observable<Scene>;
  95396. /**
  95397. * An event triggered when the scene is ready
  95398. */
  95399. onReadyObservable: Observable<Scene>;
  95400. /**
  95401. * An event triggered before rendering a camera
  95402. */
  95403. onBeforeCameraRenderObservable: Observable<Camera>;
  95404. private _onBeforeCameraRenderObserver;
  95405. /** Sets a function to be executed before rendering a camera*/
  95406. beforeCameraRender: () => void;
  95407. /**
  95408. * An event triggered after rendering a camera
  95409. */
  95410. onAfterCameraRenderObservable: Observable<Camera>;
  95411. private _onAfterCameraRenderObserver;
  95412. /** Sets a function to be executed after rendering a camera*/
  95413. afterCameraRender: () => void;
  95414. /**
  95415. * An event triggered when active meshes evaluation is about to start
  95416. */
  95417. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95418. /**
  95419. * An event triggered when active meshes evaluation is done
  95420. */
  95421. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95422. /**
  95423. * An event triggered when particles rendering is about to start
  95424. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95425. */
  95426. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95427. /**
  95428. * An event triggered when particles rendering is done
  95429. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95430. */
  95431. onAfterParticlesRenderingObservable: Observable<Scene>;
  95432. /**
  95433. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95434. */
  95435. onDataLoadedObservable: Observable<Scene>;
  95436. /**
  95437. * An event triggered when a camera is created
  95438. */
  95439. onNewCameraAddedObservable: Observable<Camera>;
  95440. /**
  95441. * An event triggered when a camera is removed
  95442. */
  95443. onCameraRemovedObservable: Observable<Camera>;
  95444. /**
  95445. * An event triggered when a light is created
  95446. */
  95447. onNewLightAddedObservable: Observable<Light>;
  95448. /**
  95449. * An event triggered when a light is removed
  95450. */
  95451. onLightRemovedObservable: Observable<Light>;
  95452. /**
  95453. * An event triggered when a geometry is created
  95454. */
  95455. onNewGeometryAddedObservable: Observable<Geometry>;
  95456. /**
  95457. * An event triggered when a geometry is removed
  95458. */
  95459. onGeometryRemovedObservable: Observable<Geometry>;
  95460. /**
  95461. * An event triggered when a transform node is created
  95462. */
  95463. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95464. /**
  95465. * An event triggered when a transform node is removed
  95466. */
  95467. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95468. /**
  95469. * An event triggered when a mesh is created
  95470. */
  95471. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95472. /**
  95473. * An event triggered when a mesh is removed
  95474. */
  95475. onMeshRemovedObservable: Observable<AbstractMesh>;
  95476. /**
  95477. * An event triggered when a skeleton is created
  95478. */
  95479. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95480. /**
  95481. * An event triggered when a skeleton is removed
  95482. */
  95483. onSkeletonRemovedObservable: Observable<Skeleton>;
  95484. /**
  95485. * An event triggered when a material is created
  95486. */
  95487. onNewMaterialAddedObservable: Observable<Material>;
  95488. /**
  95489. * An event triggered when a material is removed
  95490. */
  95491. onMaterialRemovedObservable: Observable<Material>;
  95492. /**
  95493. * An event triggered when a texture is created
  95494. */
  95495. onNewTextureAddedObservable: Observable<BaseTexture>;
  95496. /**
  95497. * An event triggered when a texture is removed
  95498. */
  95499. onTextureRemovedObservable: Observable<BaseTexture>;
  95500. /**
  95501. * An event triggered when render targets are about to be rendered
  95502. * Can happen multiple times per frame.
  95503. */
  95504. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95505. /**
  95506. * An event triggered when render targets were rendered.
  95507. * Can happen multiple times per frame.
  95508. */
  95509. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95510. /**
  95511. * An event triggered before calculating deterministic simulation step
  95512. */
  95513. onBeforeStepObservable: Observable<Scene>;
  95514. /**
  95515. * An event triggered after calculating deterministic simulation step
  95516. */
  95517. onAfterStepObservable: Observable<Scene>;
  95518. /**
  95519. * An event triggered when the activeCamera property is updated
  95520. */
  95521. onActiveCameraChanged: Observable<Scene>;
  95522. /**
  95523. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95524. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95525. * 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)
  95526. */
  95527. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95528. /**
  95529. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95530. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95531. * 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)
  95532. */
  95533. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95534. /**
  95535. * This Observable will when a mesh has been imported into the scene.
  95536. */
  95537. onMeshImportedObservable: Observable<AbstractMesh>;
  95538. /**
  95539. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95540. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95541. */
  95542. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95543. /** @hidden */
  95544. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95545. /**
  95546. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95547. */
  95548. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95549. /**
  95550. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95551. */
  95552. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95553. /**
  95554. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95555. */
  95556. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95557. /** Callback called when a pointer move is detected */
  95558. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95559. /** Callback called when a pointer down is detected */
  95560. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95561. /** Callback called when a pointer up is detected */
  95562. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95563. /** Callback called when a pointer pick is detected */
  95564. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95565. /**
  95566. * 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).
  95567. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95568. */
  95569. onPrePointerObservable: Observable<PointerInfoPre>;
  95570. /**
  95571. * Observable event triggered each time an input event is received from the rendering canvas
  95572. */
  95573. onPointerObservable: Observable<PointerInfo>;
  95574. /**
  95575. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95576. */
  95577. readonly unTranslatedPointer: Vector2;
  95578. /**
  95579. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95580. */
  95581. static DragMovementThreshold: number;
  95582. /**
  95583. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95584. */
  95585. static LongPressDelay: number;
  95586. /**
  95587. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95588. */
  95589. static DoubleClickDelay: number;
  95590. /** If you need to check double click without raising a single click at first click, enable this flag */
  95591. static ExclusiveDoubleClickMode: boolean;
  95592. /** @hidden */
  95593. _mirroredCameraPosition: Nullable<Vector3>;
  95594. /**
  95595. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95596. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95597. */
  95598. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95599. /**
  95600. * Observable event triggered each time an keyboard event is received from the hosting window
  95601. */
  95602. onKeyboardObservable: Observable<KeyboardInfo>;
  95603. private _useRightHandedSystem;
  95604. /**
  95605. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95606. */
  95607. useRightHandedSystem: boolean;
  95608. private _timeAccumulator;
  95609. private _currentStepId;
  95610. private _currentInternalStep;
  95611. /**
  95612. * Sets the step Id used by deterministic lock step
  95613. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95614. * @param newStepId defines the step Id
  95615. */
  95616. setStepId(newStepId: number): void;
  95617. /**
  95618. * Gets the step Id used by deterministic lock step
  95619. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95620. * @returns the step Id
  95621. */
  95622. getStepId(): number;
  95623. /**
  95624. * Gets the internal step used by deterministic lock step
  95625. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95626. * @returns the internal step
  95627. */
  95628. getInternalStep(): number;
  95629. private _fogEnabled;
  95630. /**
  95631. * Gets or sets a boolean indicating if fog is enabled on this scene
  95632. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95633. * (Default is true)
  95634. */
  95635. fogEnabled: boolean;
  95636. private _fogMode;
  95637. /**
  95638. * Gets or sets the fog mode to use
  95639. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95640. * | mode | value |
  95641. * | --- | --- |
  95642. * | FOGMODE_NONE | 0 |
  95643. * | FOGMODE_EXP | 1 |
  95644. * | FOGMODE_EXP2 | 2 |
  95645. * | FOGMODE_LINEAR | 3 |
  95646. */
  95647. fogMode: number;
  95648. /**
  95649. * Gets or sets the fog color to use
  95650. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95651. * (Default is Color3(0.2, 0.2, 0.3))
  95652. */
  95653. fogColor: Color3;
  95654. /**
  95655. * Gets or sets the fog density to use
  95656. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95657. * (Default is 0.1)
  95658. */
  95659. fogDensity: number;
  95660. /**
  95661. * Gets or sets the fog start distance to use
  95662. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95663. * (Default is 0)
  95664. */
  95665. fogStart: number;
  95666. /**
  95667. * Gets or sets the fog end distance to use
  95668. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95669. * (Default is 1000)
  95670. */
  95671. fogEnd: number;
  95672. private _shadowsEnabled;
  95673. /**
  95674. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95675. */
  95676. shadowsEnabled: boolean;
  95677. private _lightsEnabled;
  95678. /**
  95679. * Gets or sets a boolean indicating if lights are enabled on this scene
  95680. */
  95681. lightsEnabled: boolean;
  95682. /** All of the active cameras added to this scene. */
  95683. activeCameras: Camera[];
  95684. /** @hidden */
  95685. _activeCamera: Nullable<Camera>;
  95686. /** Gets or sets the current active camera */
  95687. activeCamera: Nullable<Camera>;
  95688. private _defaultMaterial;
  95689. /** The default material used on meshes when no material is affected */
  95690. /** The default material used on meshes when no material is affected */
  95691. defaultMaterial: Material;
  95692. private _texturesEnabled;
  95693. /**
  95694. * Gets or sets a boolean indicating if textures are enabled on this scene
  95695. */
  95696. texturesEnabled: boolean;
  95697. /**
  95698. * Gets or sets a boolean indicating if particles are enabled on this scene
  95699. */
  95700. particlesEnabled: boolean;
  95701. /**
  95702. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95703. */
  95704. spritesEnabled: boolean;
  95705. private _skeletonsEnabled;
  95706. /**
  95707. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95708. */
  95709. skeletonsEnabled: boolean;
  95710. /**
  95711. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95712. */
  95713. lensFlaresEnabled: boolean;
  95714. /**
  95715. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95717. */
  95718. collisionsEnabled: boolean;
  95719. private _collisionCoordinator;
  95720. /** @hidden */
  95721. readonly collisionCoordinator: ICollisionCoordinator;
  95722. /**
  95723. * Defines the gravity applied to this scene (used only for collisions)
  95724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95725. */
  95726. gravity: Vector3;
  95727. /**
  95728. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95729. */
  95730. postProcessesEnabled: boolean;
  95731. /**
  95732. * The list of postprocesses added to the scene
  95733. */
  95734. postProcesses: PostProcess[];
  95735. /**
  95736. * Gets the current postprocess manager
  95737. */
  95738. postProcessManager: PostProcessManager;
  95739. /**
  95740. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95741. */
  95742. renderTargetsEnabled: boolean;
  95743. /**
  95744. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95745. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95746. */
  95747. dumpNextRenderTargets: boolean;
  95748. /**
  95749. * The list of user defined render targets added to the scene
  95750. */
  95751. customRenderTargets: RenderTargetTexture[];
  95752. /**
  95753. * Defines if texture loading must be delayed
  95754. * If true, textures will only be loaded when they need to be rendered
  95755. */
  95756. useDelayedTextureLoading: boolean;
  95757. /**
  95758. * Gets the list of meshes imported to the scene through SceneLoader
  95759. */
  95760. importedMeshesFiles: String[];
  95761. /**
  95762. * Gets or sets a boolean indicating if probes are enabled on this scene
  95763. */
  95764. probesEnabled: boolean;
  95765. /**
  95766. * Gets or sets the current offline provider to use to store scene data
  95767. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95768. */
  95769. offlineProvider: IOfflineProvider;
  95770. /**
  95771. * Gets or sets the action manager associated with the scene
  95772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95773. */
  95774. actionManager: AbstractActionManager;
  95775. private _meshesForIntersections;
  95776. /**
  95777. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95778. */
  95779. proceduralTexturesEnabled: boolean;
  95780. private _engine;
  95781. private _totalVertices;
  95782. /** @hidden */
  95783. _activeIndices: PerfCounter;
  95784. /** @hidden */
  95785. _activeParticles: PerfCounter;
  95786. /** @hidden */
  95787. _activeBones: PerfCounter;
  95788. private _animationRatio;
  95789. /** @hidden */
  95790. _animationTimeLast: number;
  95791. /** @hidden */
  95792. _animationTime: number;
  95793. /**
  95794. * Gets or sets a general scale for animation speed
  95795. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95796. */
  95797. animationTimeScale: number;
  95798. /** @hidden */
  95799. _cachedMaterial: Nullable<Material>;
  95800. /** @hidden */
  95801. _cachedEffect: Nullable<Effect>;
  95802. /** @hidden */
  95803. _cachedVisibility: Nullable<number>;
  95804. private _renderId;
  95805. private _frameId;
  95806. private _executeWhenReadyTimeoutId;
  95807. private _intermediateRendering;
  95808. private _viewUpdateFlag;
  95809. private _projectionUpdateFlag;
  95810. /** @hidden */
  95811. _toBeDisposed: Nullable<IDisposable>[];
  95812. private _activeRequests;
  95813. /** @hidden */
  95814. _pendingData: any[];
  95815. private _isDisposed;
  95816. /**
  95817. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95818. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95819. */
  95820. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95821. private _activeMeshes;
  95822. private _processedMaterials;
  95823. private _renderTargets;
  95824. /** @hidden */
  95825. _activeParticleSystems: SmartArray<IParticleSystem>;
  95826. private _activeSkeletons;
  95827. private _softwareSkinnedMeshes;
  95828. private _renderingManager;
  95829. /** @hidden */
  95830. _activeAnimatables: Animatable[];
  95831. private _transformMatrix;
  95832. private _sceneUbo;
  95833. /** @hidden */
  95834. _viewMatrix: Matrix;
  95835. private _projectionMatrix;
  95836. /** @hidden */
  95837. _forcedViewPosition: Nullable<Vector3>;
  95838. /** @hidden */
  95839. _frustumPlanes: Plane[];
  95840. /**
  95841. * Gets the list of frustum planes (built from the active camera)
  95842. */
  95843. readonly frustumPlanes: Plane[];
  95844. /**
  95845. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95846. * This is useful if there are more lights that the maximum simulteanous authorized
  95847. */
  95848. requireLightSorting: boolean;
  95849. /** @hidden */
  95850. readonly useMaterialMeshMap: boolean;
  95851. /** @hidden */
  95852. readonly useClonedMeshhMap: boolean;
  95853. private _externalData;
  95854. private _uid;
  95855. /**
  95856. * @hidden
  95857. * Backing store of defined scene components.
  95858. */
  95859. _components: ISceneComponent[];
  95860. /**
  95861. * @hidden
  95862. * Backing store of defined scene components.
  95863. */
  95864. _serializableComponents: ISceneSerializableComponent[];
  95865. /**
  95866. * List of components to register on the next registration step.
  95867. */
  95868. private _transientComponents;
  95869. /**
  95870. * Registers the transient components if needed.
  95871. */
  95872. private _registerTransientComponents;
  95873. /**
  95874. * @hidden
  95875. * Add a component to the scene.
  95876. * Note that the ccomponent could be registered on th next frame if this is called after
  95877. * the register component stage.
  95878. * @param component Defines the component to add to the scene
  95879. */
  95880. _addComponent(component: ISceneComponent): void;
  95881. /**
  95882. * @hidden
  95883. * Gets a component from the scene.
  95884. * @param name defines the name of the component to retrieve
  95885. * @returns the component or null if not present
  95886. */
  95887. _getComponent(name: string): Nullable<ISceneComponent>;
  95888. /**
  95889. * @hidden
  95890. * Defines the actions happening before camera updates.
  95891. */
  95892. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95893. /**
  95894. * @hidden
  95895. * Defines the actions happening before clear the canvas.
  95896. */
  95897. _beforeClearStage: Stage<SimpleStageAction>;
  95898. /**
  95899. * @hidden
  95900. * Defines the actions when collecting render targets for the frame.
  95901. */
  95902. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95903. /**
  95904. * @hidden
  95905. * Defines the actions happening for one camera in the frame.
  95906. */
  95907. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95908. /**
  95909. * @hidden
  95910. * Defines the actions happening during the per mesh ready checks.
  95911. */
  95912. _isReadyForMeshStage: Stage<MeshStageAction>;
  95913. /**
  95914. * @hidden
  95915. * Defines the actions happening before evaluate active mesh checks.
  95916. */
  95917. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95918. /**
  95919. * @hidden
  95920. * Defines the actions happening during the evaluate sub mesh checks.
  95921. */
  95922. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95923. /**
  95924. * @hidden
  95925. * Defines the actions happening during the active mesh stage.
  95926. */
  95927. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95928. /**
  95929. * @hidden
  95930. * Defines the actions happening during the per camera render target step.
  95931. */
  95932. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95933. /**
  95934. * @hidden
  95935. * Defines the actions happening just before the active camera is drawing.
  95936. */
  95937. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95938. /**
  95939. * @hidden
  95940. * Defines the actions happening just before a render target is drawing.
  95941. */
  95942. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95943. /**
  95944. * @hidden
  95945. * Defines the actions happening just before a rendering group is drawing.
  95946. */
  95947. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95948. /**
  95949. * @hidden
  95950. * Defines the actions happening just before a mesh is drawing.
  95951. */
  95952. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95953. /**
  95954. * @hidden
  95955. * Defines the actions happening just after a mesh has been drawn.
  95956. */
  95957. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95958. /**
  95959. * @hidden
  95960. * Defines the actions happening just after a rendering group has been drawn.
  95961. */
  95962. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95963. /**
  95964. * @hidden
  95965. * Defines the actions happening just after the active camera has been drawn.
  95966. */
  95967. _afterCameraDrawStage: Stage<CameraStageAction>;
  95968. /**
  95969. * @hidden
  95970. * Defines the actions happening just after a render target has been drawn.
  95971. */
  95972. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95973. /**
  95974. * @hidden
  95975. * Defines the actions happening just after rendering all cameras and computing intersections.
  95976. */
  95977. _afterRenderStage: Stage<SimpleStageAction>;
  95978. /**
  95979. * @hidden
  95980. * Defines the actions happening when a pointer move event happens.
  95981. */
  95982. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95983. /**
  95984. * @hidden
  95985. * Defines the actions happening when a pointer down event happens.
  95986. */
  95987. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95988. /**
  95989. * @hidden
  95990. * Defines the actions happening when a pointer up event happens.
  95991. */
  95992. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95993. /**
  95994. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95995. */
  95996. private geometriesByUniqueId;
  95997. /**
  95998. * Creates a new Scene
  95999. * @param engine defines the engine to use to render this scene
  96000. * @param options defines the scene options
  96001. */
  96002. constructor(engine: Engine, options?: SceneOptions);
  96003. /**
  96004. * Gets a string idenfifying the name of the class
  96005. * @returns "Scene" string
  96006. */
  96007. getClassName(): string;
  96008. private _defaultMeshCandidates;
  96009. /**
  96010. * @hidden
  96011. */
  96012. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96013. private _defaultSubMeshCandidates;
  96014. /**
  96015. * @hidden
  96016. */
  96017. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96018. /**
  96019. * Sets the default candidate providers for the scene.
  96020. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  96021. * and getCollidingSubMeshCandidates to their default function
  96022. */
  96023. setDefaultCandidateProviders(): void;
  96024. /**
  96025. * Gets the mesh that is currently under the pointer
  96026. */
  96027. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96028. /**
  96029. * Gets or sets the current on-screen X position of the pointer
  96030. */
  96031. pointerX: number;
  96032. /**
  96033. * Gets or sets the current on-screen Y position of the pointer
  96034. */
  96035. pointerY: number;
  96036. /**
  96037. * Gets the cached material (ie. the latest rendered one)
  96038. * @returns the cached material
  96039. */
  96040. getCachedMaterial(): Nullable<Material>;
  96041. /**
  96042. * Gets the cached effect (ie. the latest rendered one)
  96043. * @returns the cached effect
  96044. */
  96045. getCachedEffect(): Nullable<Effect>;
  96046. /**
  96047. * Gets the cached visibility state (ie. the latest rendered one)
  96048. * @returns the cached visibility state
  96049. */
  96050. getCachedVisibility(): Nullable<number>;
  96051. /**
  96052. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  96053. * @param material defines the current material
  96054. * @param effect defines the current effect
  96055. * @param visibility defines the current visibility state
  96056. * @returns true if one parameter is not cached
  96057. */
  96058. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  96059. /**
  96060. * Gets the engine associated with the scene
  96061. * @returns an Engine
  96062. */
  96063. getEngine(): Engine;
  96064. /**
  96065. * Gets the total number of vertices rendered per frame
  96066. * @returns the total number of vertices rendered per frame
  96067. */
  96068. getTotalVertices(): number;
  96069. /**
  96070. * Gets the performance counter for total vertices
  96071. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96072. */
  96073. readonly totalVerticesPerfCounter: PerfCounter;
  96074. /**
  96075. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  96076. * @returns the total number of active indices rendered per frame
  96077. */
  96078. getActiveIndices(): number;
  96079. /**
  96080. * Gets the performance counter for active indices
  96081. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96082. */
  96083. readonly totalActiveIndicesPerfCounter: PerfCounter;
  96084. /**
  96085. * Gets the total number of active particles rendered per frame
  96086. * @returns the total number of active particles rendered per frame
  96087. */
  96088. getActiveParticles(): number;
  96089. /**
  96090. * Gets the performance counter for active particles
  96091. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96092. */
  96093. readonly activeParticlesPerfCounter: PerfCounter;
  96094. /**
  96095. * Gets the total number of active bones rendered per frame
  96096. * @returns the total number of active bones rendered per frame
  96097. */
  96098. getActiveBones(): number;
  96099. /**
  96100. * Gets the performance counter for active bones
  96101. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96102. */
  96103. readonly activeBonesPerfCounter: PerfCounter;
  96104. /**
  96105. * Gets the array of active meshes
  96106. * @returns an array of AbstractMesh
  96107. */
  96108. getActiveMeshes(): SmartArray<AbstractMesh>;
  96109. /**
  96110. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  96111. * @returns a number
  96112. */
  96113. getAnimationRatio(): number;
  96114. /**
  96115. * Gets an unique Id for the current render phase
  96116. * @returns a number
  96117. */
  96118. getRenderId(): number;
  96119. /**
  96120. * Gets an unique Id for the current frame
  96121. * @returns a number
  96122. */
  96123. getFrameId(): number;
  96124. /** Call this function if you want to manually increment the render Id*/
  96125. incrementRenderId(): void;
  96126. private _createUbo;
  96127. /**
  96128. * Use this method to simulate a pointer move on a mesh
  96129. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96130. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96131. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96132. * @returns the current scene
  96133. */
  96134. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96135. /**
  96136. * Use this method to simulate a pointer down on a mesh
  96137. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96138. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96139. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96140. * @returns the current scene
  96141. */
  96142. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96143. /**
  96144. * Use this method to simulate a pointer up on a mesh
  96145. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96146. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96147. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96148. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96149. * @returns the current scene
  96150. */
  96151. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  96152. /**
  96153. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96154. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96155. * @returns true if the pointer was captured
  96156. */
  96157. isPointerCaptured(pointerId?: number): boolean;
  96158. /**
  96159. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96160. * @param attachUp defines if you want to attach events to pointerup
  96161. * @param attachDown defines if you want to attach events to pointerdown
  96162. * @param attachMove defines if you want to attach events to pointermove
  96163. */
  96164. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96165. /** Detaches all event handlers*/
  96166. detachControl(): void;
  96167. /**
  96168. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  96169. * Delay loaded resources are not taking in account
  96170. * @return true if all required resources are ready
  96171. */
  96172. isReady(): boolean;
  96173. /** Resets all cached information relative to material (including effect and visibility) */
  96174. resetCachedMaterial(): void;
  96175. /**
  96176. * Registers a function to be called before every frame render
  96177. * @param func defines the function to register
  96178. */
  96179. registerBeforeRender(func: () => void): void;
  96180. /**
  96181. * Unregisters a function called before every frame render
  96182. * @param func defines the function to unregister
  96183. */
  96184. unregisterBeforeRender(func: () => void): void;
  96185. /**
  96186. * Registers a function to be called after every frame render
  96187. * @param func defines the function to register
  96188. */
  96189. registerAfterRender(func: () => void): void;
  96190. /**
  96191. * Unregisters a function called after every frame render
  96192. * @param func defines the function to unregister
  96193. */
  96194. unregisterAfterRender(func: () => void): void;
  96195. private _executeOnceBeforeRender;
  96196. /**
  96197. * The provided function will run before render once and will be disposed afterwards.
  96198. * A timeout delay can be provided so that the function will be executed in N ms.
  96199. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  96200. * @param func The function to be executed.
  96201. * @param timeout optional delay in ms
  96202. */
  96203. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  96204. /** @hidden */
  96205. _addPendingData(data: any): void;
  96206. /** @hidden */
  96207. _removePendingData(data: any): void;
  96208. /**
  96209. * Returns the number of items waiting to be loaded
  96210. * @returns the number of items waiting to be loaded
  96211. */
  96212. getWaitingItemsCount(): number;
  96213. /**
  96214. * Returns a boolean indicating if the scene is still loading data
  96215. */
  96216. readonly isLoading: boolean;
  96217. /**
  96218. * Registers a function to be executed when the scene is ready
  96219. * @param {Function} func - the function to be executed
  96220. */
  96221. executeWhenReady(func: () => void): void;
  96222. /**
  96223. * Returns a promise that resolves when the scene is ready
  96224. * @returns A promise that resolves when the scene is ready
  96225. */
  96226. whenReadyAsync(): Promise<void>;
  96227. /** @hidden */
  96228. _checkIsReady(): void;
  96229. /**
  96230. * Gets all animatable attached to the scene
  96231. */
  96232. readonly animatables: Animatable[];
  96233. /**
  96234. * Resets the last animation time frame.
  96235. * Useful to override when animations start running when loading a scene for the first time.
  96236. */
  96237. resetLastAnimationTimeFrame(): void;
  96238. /**
  96239. * Gets the current view matrix
  96240. * @returns a Matrix
  96241. */
  96242. getViewMatrix(): Matrix;
  96243. /**
  96244. * Gets the current projection matrix
  96245. * @returns a Matrix
  96246. */
  96247. getProjectionMatrix(): Matrix;
  96248. /**
  96249. * Gets the current transform matrix
  96250. * @returns a Matrix made of View * Projection
  96251. */
  96252. getTransformMatrix(): Matrix;
  96253. /**
  96254. * Sets the current transform matrix
  96255. * @param viewL defines the View matrix to use
  96256. * @param projectionL defines the Projection matrix to use
  96257. * @param viewR defines the right View matrix to use (if provided)
  96258. * @param projectionR defines the right Projection matrix to use (if provided)
  96259. */
  96260. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  96261. /**
  96262. * Gets the uniform buffer used to store scene data
  96263. * @returns a UniformBuffer
  96264. */
  96265. getSceneUniformBuffer(): UniformBuffer;
  96266. /**
  96267. * Gets an unique (relatively to the current scene) Id
  96268. * @returns an unique number for the scene
  96269. */
  96270. getUniqueId(): number;
  96271. /**
  96272. * Add a mesh to the list of scene's meshes
  96273. * @param newMesh defines the mesh to add
  96274. * @param recursive if all child meshes should also be added to the scene
  96275. */
  96276. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  96277. /**
  96278. * Remove a mesh for the list of scene's meshes
  96279. * @param toRemove defines the mesh to remove
  96280. * @param recursive if all child meshes should also be removed from the scene
  96281. * @returns the index where the mesh was in the mesh list
  96282. */
  96283. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  96284. /**
  96285. * Add a transform node to the list of scene's transform nodes
  96286. * @param newTransformNode defines the transform node to add
  96287. */
  96288. addTransformNode(newTransformNode: TransformNode): void;
  96289. /**
  96290. * Remove a transform node for the list of scene's transform nodes
  96291. * @param toRemove defines the transform node to remove
  96292. * @returns the index where the transform node was in the transform node list
  96293. */
  96294. removeTransformNode(toRemove: TransformNode): number;
  96295. /**
  96296. * Remove a skeleton for the list of scene's skeletons
  96297. * @param toRemove defines the skeleton to remove
  96298. * @returns the index where the skeleton was in the skeleton list
  96299. */
  96300. removeSkeleton(toRemove: Skeleton): number;
  96301. /**
  96302. * Remove a morph target for the list of scene's morph targets
  96303. * @param toRemove defines the morph target to remove
  96304. * @returns the index where the morph target was in the morph target list
  96305. */
  96306. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  96307. /**
  96308. * Remove a light for the list of scene's lights
  96309. * @param toRemove defines the light to remove
  96310. * @returns the index where the light was in the light list
  96311. */
  96312. removeLight(toRemove: Light): number;
  96313. /**
  96314. * Remove a camera for the list of scene's cameras
  96315. * @param toRemove defines the camera to remove
  96316. * @returns the index where the camera was in the camera list
  96317. */
  96318. removeCamera(toRemove: Camera): number;
  96319. /**
  96320. * Remove a particle system for the list of scene's particle systems
  96321. * @param toRemove defines the particle system to remove
  96322. * @returns the index where the particle system was in the particle system list
  96323. */
  96324. removeParticleSystem(toRemove: IParticleSystem): number;
  96325. /**
  96326. * Remove a animation for the list of scene's animations
  96327. * @param toRemove defines the animation to remove
  96328. * @returns the index where the animation was in the animation list
  96329. */
  96330. removeAnimation(toRemove: Animation): number;
  96331. /**
  96332. * Will stop the animation of the given target
  96333. * @param target - the target
  96334. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96335. * @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)
  96336. */
  96337. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96338. /**
  96339. * Removes the given animation group from this scene.
  96340. * @param toRemove The animation group to remove
  96341. * @returns The index of the removed animation group
  96342. */
  96343. removeAnimationGroup(toRemove: AnimationGroup): number;
  96344. /**
  96345. * Removes the given multi-material from this scene.
  96346. * @param toRemove The multi-material to remove
  96347. * @returns The index of the removed multi-material
  96348. */
  96349. removeMultiMaterial(toRemove: MultiMaterial): number;
  96350. /**
  96351. * Removes the given material from this scene.
  96352. * @param toRemove The material to remove
  96353. * @returns The index of the removed material
  96354. */
  96355. removeMaterial(toRemove: Material): number;
  96356. /**
  96357. * Removes the given action manager from this scene.
  96358. * @param toRemove The action manager to remove
  96359. * @returns The index of the removed action manager
  96360. */
  96361. removeActionManager(toRemove: AbstractActionManager): number;
  96362. /**
  96363. * Removes the given texture from this scene.
  96364. * @param toRemove The texture to remove
  96365. * @returns The index of the removed texture
  96366. */
  96367. removeTexture(toRemove: BaseTexture): number;
  96368. /**
  96369. * Adds the given light to this scene
  96370. * @param newLight The light to add
  96371. */
  96372. addLight(newLight: Light): void;
  96373. /**
  96374. * Sorts the list list based on light priorities
  96375. */
  96376. sortLightsByPriority(): void;
  96377. /**
  96378. * Adds the given camera to this scene
  96379. * @param newCamera The camera to add
  96380. */
  96381. addCamera(newCamera: Camera): void;
  96382. /**
  96383. * Adds the given skeleton to this scene
  96384. * @param newSkeleton The skeleton to add
  96385. */
  96386. addSkeleton(newSkeleton: Skeleton): void;
  96387. /**
  96388. * Adds the given particle system to this scene
  96389. * @param newParticleSystem The particle system to add
  96390. */
  96391. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96392. /**
  96393. * Adds the given animation to this scene
  96394. * @param newAnimation The animation to add
  96395. */
  96396. addAnimation(newAnimation: Animation): void;
  96397. /**
  96398. * Adds the given animation group to this scene.
  96399. * @param newAnimationGroup The animation group to add
  96400. */
  96401. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96402. /**
  96403. * Adds the given multi-material to this scene
  96404. * @param newMultiMaterial The multi-material to add
  96405. */
  96406. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96407. /**
  96408. * Adds the given material to this scene
  96409. * @param newMaterial The material to add
  96410. */
  96411. addMaterial(newMaterial: Material): void;
  96412. /**
  96413. * Adds the given morph target to this scene
  96414. * @param newMorphTargetManager The morph target to add
  96415. */
  96416. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96417. /**
  96418. * Adds the given geometry to this scene
  96419. * @param newGeometry The geometry to add
  96420. */
  96421. addGeometry(newGeometry: Geometry): void;
  96422. /**
  96423. * Adds the given action manager to this scene
  96424. * @param newActionManager The action manager to add
  96425. */
  96426. addActionManager(newActionManager: AbstractActionManager): void;
  96427. /**
  96428. * Adds the given texture to this scene.
  96429. * @param newTexture The texture to add
  96430. */
  96431. addTexture(newTexture: BaseTexture): void;
  96432. /**
  96433. * Switch active camera
  96434. * @param newCamera defines the new active camera
  96435. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96436. */
  96437. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96438. /**
  96439. * sets the active camera of the scene using its ID
  96440. * @param id defines the camera's ID
  96441. * @return the new active camera or null if none found.
  96442. */
  96443. setActiveCameraByID(id: string): Nullable<Camera>;
  96444. /**
  96445. * sets the active camera of the scene using its name
  96446. * @param name defines the camera's name
  96447. * @returns the new active camera or null if none found.
  96448. */
  96449. setActiveCameraByName(name: string): Nullable<Camera>;
  96450. /**
  96451. * get an animation group using its name
  96452. * @param name defines the material's name
  96453. * @return the animation group or null if none found.
  96454. */
  96455. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96456. /**
  96457. * Get a material using its unique id
  96458. * @param uniqueId defines the material's unique id
  96459. * @return the material or null if none found.
  96460. */
  96461. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96462. /**
  96463. * get a material using its id
  96464. * @param id defines the material's ID
  96465. * @return the material or null if none found.
  96466. */
  96467. getMaterialByID(id: string): Nullable<Material>;
  96468. /**
  96469. * Gets a material using its name
  96470. * @param name defines the material's name
  96471. * @return the material or null if none found.
  96472. */
  96473. getMaterialByName(name: string): Nullable<Material>;
  96474. /**
  96475. * Gets a camera using its id
  96476. * @param id defines the id to look for
  96477. * @returns the camera or null if not found
  96478. */
  96479. getCameraByID(id: string): Nullable<Camera>;
  96480. /**
  96481. * Gets a camera using its unique id
  96482. * @param uniqueId defines the unique id to look for
  96483. * @returns the camera or null if not found
  96484. */
  96485. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96486. /**
  96487. * Gets a camera using its name
  96488. * @param name defines the camera's name
  96489. * @return the camera or null if none found.
  96490. */
  96491. getCameraByName(name: string): Nullable<Camera>;
  96492. /**
  96493. * Gets a bone using its id
  96494. * @param id defines the bone's id
  96495. * @return the bone or null if not found
  96496. */
  96497. getBoneByID(id: string): Nullable<Bone>;
  96498. /**
  96499. * Gets a bone using its id
  96500. * @param name defines the bone's name
  96501. * @return the bone or null if not found
  96502. */
  96503. getBoneByName(name: string): Nullable<Bone>;
  96504. /**
  96505. * Gets a light node using its name
  96506. * @param name defines the the light's name
  96507. * @return the light or null if none found.
  96508. */
  96509. getLightByName(name: string): Nullable<Light>;
  96510. /**
  96511. * Gets a light node using its id
  96512. * @param id defines the light's id
  96513. * @return the light or null if none found.
  96514. */
  96515. getLightByID(id: string): Nullable<Light>;
  96516. /**
  96517. * Gets a light node using its scene-generated unique ID
  96518. * @param uniqueId defines the light's unique id
  96519. * @return the light or null if none found.
  96520. */
  96521. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96522. /**
  96523. * Gets a particle system by id
  96524. * @param id defines the particle system id
  96525. * @return the corresponding system or null if none found
  96526. */
  96527. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96528. /**
  96529. * Gets a geometry using its ID
  96530. * @param id defines the geometry's id
  96531. * @return the geometry or null if none found.
  96532. */
  96533. getGeometryByID(id: string): Nullable<Geometry>;
  96534. private _getGeometryByUniqueID;
  96535. /**
  96536. * Add a new geometry to this scene
  96537. * @param geometry defines the geometry to be added to the scene.
  96538. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96539. * @return a boolean defining if the geometry was added or not
  96540. */
  96541. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96542. /**
  96543. * Removes an existing geometry
  96544. * @param geometry defines the geometry to be removed from the scene
  96545. * @return a boolean defining if the geometry was removed or not
  96546. */
  96547. removeGeometry(geometry: Geometry): boolean;
  96548. /**
  96549. * Gets the list of geometries attached to the scene
  96550. * @returns an array of Geometry
  96551. */
  96552. getGeometries(): Geometry[];
  96553. /**
  96554. * Gets the first added mesh found of a given ID
  96555. * @param id defines the id to search for
  96556. * @return the mesh found or null if not found at all
  96557. */
  96558. getMeshByID(id: string): Nullable<AbstractMesh>;
  96559. /**
  96560. * Gets a list of meshes using their id
  96561. * @param id defines the id to search for
  96562. * @returns a list of meshes
  96563. */
  96564. getMeshesByID(id: string): Array<AbstractMesh>;
  96565. /**
  96566. * Gets the first added transform node found of a given ID
  96567. * @param id defines the id to search for
  96568. * @return the found transform node or null if not found at all.
  96569. */
  96570. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96571. /**
  96572. * Gets a transform node with its auto-generated unique id
  96573. * @param uniqueId efines the unique id to search for
  96574. * @return the found transform node or null if not found at all.
  96575. */
  96576. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96577. /**
  96578. * Gets a list of transform nodes using their id
  96579. * @param id defines the id to search for
  96580. * @returns a list of transform nodes
  96581. */
  96582. getTransformNodesByID(id: string): Array<TransformNode>;
  96583. /**
  96584. * Gets a mesh with its auto-generated unique id
  96585. * @param uniqueId defines the unique id to search for
  96586. * @return the found mesh or null if not found at all.
  96587. */
  96588. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96589. /**
  96590. * Gets a the last added mesh using a given id
  96591. * @param id defines the id to search for
  96592. * @return the found mesh or null if not found at all.
  96593. */
  96594. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96595. /**
  96596. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96597. * @param id defines the id to search for
  96598. * @return the found node or null if not found at all
  96599. */
  96600. getLastEntryByID(id: string): Nullable<Node>;
  96601. /**
  96602. * Gets a node (Mesh, Camera, Light) using a given id
  96603. * @param id defines the id to search for
  96604. * @return the found node or null if not found at all
  96605. */
  96606. getNodeByID(id: string): Nullable<Node>;
  96607. /**
  96608. * Gets a node (Mesh, Camera, Light) using a given name
  96609. * @param name defines the name to search for
  96610. * @return the found node or null if not found at all.
  96611. */
  96612. getNodeByName(name: string): Nullable<Node>;
  96613. /**
  96614. * Gets a mesh using a given name
  96615. * @param name defines the name to search for
  96616. * @return the found mesh or null if not found at all.
  96617. */
  96618. getMeshByName(name: string): Nullable<AbstractMesh>;
  96619. /**
  96620. * Gets a transform node using a given name
  96621. * @param name defines the name to search for
  96622. * @return the found transform node or null if not found at all.
  96623. */
  96624. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96625. /**
  96626. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96627. * @param id defines the id to search for
  96628. * @return the found skeleton or null if not found at all.
  96629. */
  96630. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96631. /**
  96632. * Gets a skeleton using a given auto generated unique id
  96633. * @param uniqueId defines the unique id to search for
  96634. * @return the found skeleton or null if not found at all.
  96635. */
  96636. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96637. /**
  96638. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96639. * @param id defines the id to search for
  96640. * @return the found skeleton or null if not found at all.
  96641. */
  96642. getSkeletonById(id: string): Nullable<Skeleton>;
  96643. /**
  96644. * Gets a skeleton using a given name
  96645. * @param name defines the name to search for
  96646. * @return the found skeleton or null if not found at all.
  96647. */
  96648. getSkeletonByName(name: string): Nullable<Skeleton>;
  96649. /**
  96650. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96651. * @param id defines the id to search for
  96652. * @return the found morph target manager or null if not found at all.
  96653. */
  96654. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96655. /**
  96656. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96657. * @param id defines the id to search for
  96658. * @return the found morph target or null if not found at all.
  96659. */
  96660. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96661. /**
  96662. * Gets a boolean indicating if the given mesh is active
  96663. * @param mesh defines the mesh to look for
  96664. * @returns true if the mesh is in the active list
  96665. */
  96666. isActiveMesh(mesh: AbstractMesh): boolean;
  96667. /**
  96668. * Return a unique id as a string which can serve as an identifier for the scene
  96669. */
  96670. readonly uid: string;
  96671. /**
  96672. * Add an externaly attached data from its key.
  96673. * This method call will fail and return false, if such key already exists.
  96674. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96675. * @param key the unique key that identifies the data
  96676. * @param data the data object to associate to the key for this Engine instance
  96677. * @return true if no such key were already present and the data was added successfully, false otherwise
  96678. */
  96679. addExternalData<T>(key: string, data: T): boolean;
  96680. /**
  96681. * Get an externaly attached data from its key
  96682. * @param key the unique key that identifies the data
  96683. * @return the associated data, if present (can be null), or undefined if not present
  96684. */
  96685. getExternalData<T>(key: string): Nullable<T>;
  96686. /**
  96687. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96688. * @param key the unique key that identifies the data
  96689. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96690. * @return the associated data, can be null if the factory returned null.
  96691. */
  96692. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96693. /**
  96694. * Remove an externaly attached data from the Engine instance
  96695. * @param key the unique key that identifies the data
  96696. * @return true if the data was successfully removed, false if it doesn't exist
  96697. */
  96698. removeExternalData(key: string): boolean;
  96699. private _evaluateSubMesh;
  96700. /**
  96701. * Clear the processed materials smart array preventing retention point in material dispose.
  96702. */
  96703. freeProcessedMaterials(): void;
  96704. private _preventFreeActiveMeshesAndRenderingGroups;
  96705. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96706. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96707. * when disposing several meshes in a row or a hierarchy of meshes.
  96708. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96709. */
  96710. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96711. /**
  96712. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96713. */
  96714. freeActiveMeshes(): void;
  96715. /**
  96716. * Clear the info related to rendering groups preventing retention points during dispose.
  96717. */
  96718. freeRenderingGroups(): void;
  96719. /** @hidden */
  96720. _isInIntermediateRendering(): boolean;
  96721. /**
  96722. * Lambda returning the list of potentially active meshes.
  96723. */
  96724. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96725. /**
  96726. * Lambda returning the list of potentially active sub meshes.
  96727. */
  96728. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96729. /**
  96730. * Lambda returning the list of potentially intersecting sub meshes.
  96731. */
  96732. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96733. /**
  96734. * Lambda returning the list of potentially colliding sub meshes.
  96735. */
  96736. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96737. private _activeMeshesFrozen;
  96738. /**
  96739. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96740. * @returns the current scene
  96741. */
  96742. freezeActiveMeshes(): Scene;
  96743. /**
  96744. * Use this function to restart evaluating active meshes on every frame
  96745. * @returns the current scene
  96746. */
  96747. unfreezeActiveMeshes(): Scene;
  96748. private _evaluateActiveMeshes;
  96749. private _activeMesh;
  96750. /**
  96751. * Update the transform matrix to update from the current active camera
  96752. * @param force defines a boolean used to force the update even if cache is up to date
  96753. */
  96754. updateTransformMatrix(force?: boolean): void;
  96755. private _bindFrameBuffer;
  96756. /** @hidden */
  96757. _allowPostProcessClearColor: boolean;
  96758. /** @hidden */
  96759. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96760. private _processSubCameras;
  96761. private _checkIntersections;
  96762. /** @hidden */
  96763. _advancePhysicsEngineStep(step: number): void;
  96764. /**
  96765. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96766. */
  96767. getDeterministicFrameTime: () => number;
  96768. /** @hidden */
  96769. _animate(): void;
  96770. /** Execute all animations (for a frame) */
  96771. animate(): void;
  96772. /**
  96773. * Render the scene
  96774. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96775. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96776. */
  96777. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96778. /**
  96779. * Freeze all materials
  96780. * A frozen material will not be updatable but should be faster to render
  96781. */
  96782. freezeMaterials(): void;
  96783. /**
  96784. * Unfreeze all materials
  96785. * A frozen material will not be updatable but should be faster to render
  96786. */
  96787. unfreezeMaterials(): void;
  96788. /**
  96789. * Releases all held ressources
  96790. */
  96791. dispose(): void;
  96792. /**
  96793. * Gets if the scene is already disposed
  96794. */
  96795. readonly isDisposed: boolean;
  96796. /**
  96797. * Call this function to reduce memory footprint of the scene.
  96798. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96799. */
  96800. clearCachedVertexData(): void;
  96801. /**
  96802. * This function will remove the local cached buffer data from texture.
  96803. * It will save memory but will prevent the texture from being rebuilt
  96804. */
  96805. cleanCachedTextureBuffer(): void;
  96806. /**
  96807. * Get the world extend vectors with an optional filter
  96808. *
  96809. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96810. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96811. */
  96812. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96813. min: Vector3;
  96814. max: Vector3;
  96815. };
  96816. /**
  96817. * Creates a ray that can be used to pick in the scene
  96818. * @param x defines the x coordinate of the origin (on-screen)
  96819. * @param y defines the y coordinate of the origin (on-screen)
  96820. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96821. * @param camera defines the camera to use for the picking
  96822. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96823. * @returns a Ray
  96824. */
  96825. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96826. /**
  96827. * Creates a ray that can be used to pick in the scene
  96828. * @param x defines the x coordinate of the origin (on-screen)
  96829. * @param y defines the y coordinate of the origin (on-screen)
  96830. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96831. * @param result defines the ray where to store the picking ray
  96832. * @param camera defines the camera to use for the picking
  96833. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96834. * @returns the current scene
  96835. */
  96836. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96837. /**
  96838. * Creates a ray that can be used to pick in the scene
  96839. * @param x defines the x coordinate of the origin (on-screen)
  96840. * @param y defines the y coordinate of the origin (on-screen)
  96841. * @param camera defines the camera to use for the picking
  96842. * @returns a Ray
  96843. */
  96844. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96845. /**
  96846. * Creates a ray that can be used to pick in the scene
  96847. * @param x defines the x coordinate of the origin (on-screen)
  96848. * @param y defines the y coordinate of the origin (on-screen)
  96849. * @param result defines the ray where to store the picking ray
  96850. * @param camera defines the camera to use for the picking
  96851. * @returns the current scene
  96852. */
  96853. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96854. /** Launch a ray to try to pick a mesh in the scene
  96855. * @param x position on screen
  96856. * @param y position on screen
  96857. * @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
  96858. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96859. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96860. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96861. * @returns a PickingInfo
  96862. */
  96863. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96864. /** Use the given ray to pick a mesh in the scene
  96865. * @param ray The ray to use to pick meshes
  96866. * @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
  96867. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96868. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96869. * @returns a PickingInfo
  96870. */
  96871. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96872. /**
  96873. * Launch a ray to try to pick a mesh in the scene
  96874. * @param x X position on screen
  96875. * @param y Y position on screen
  96876. * @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
  96877. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96878. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96879. * @returns an array of PickingInfo
  96880. */
  96881. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96882. /**
  96883. * Launch a ray to try to pick a mesh in the scene
  96884. * @param ray Ray to use
  96885. * @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
  96886. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96887. * @returns an array of PickingInfo
  96888. */
  96889. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96890. /**
  96891. * Force the value of meshUnderPointer
  96892. * @param mesh defines the mesh to use
  96893. */
  96894. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96895. /**
  96896. * Gets the mesh under the pointer
  96897. * @returns a Mesh or null if no mesh is under the pointer
  96898. */
  96899. getPointerOverMesh(): Nullable<AbstractMesh>;
  96900. /** @hidden */
  96901. _rebuildGeometries(): void;
  96902. /** @hidden */
  96903. _rebuildTextures(): void;
  96904. private _getByTags;
  96905. /**
  96906. * Get a list of meshes by tags
  96907. * @param tagsQuery defines the tags query to use
  96908. * @param forEach defines a predicate used to filter results
  96909. * @returns an array of Mesh
  96910. */
  96911. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96912. /**
  96913. * Get a list of cameras by tags
  96914. * @param tagsQuery defines the tags query to use
  96915. * @param forEach defines a predicate used to filter results
  96916. * @returns an array of Camera
  96917. */
  96918. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96919. /**
  96920. * Get a list of lights by tags
  96921. * @param tagsQuery defines the tags query to use
  96922. * @param forEach defines a predicate used to filter results
  96923. * @returns an array of Light
  96924. */
  96925. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96926. /**
  96927. * Get a list of materials by tags
  96928. * @param tagsQuery defines the tags query to use
  96929. * @param forEach defines a predicate used to filter results
  96930. * @returns an array of Material
  96931. */
  96932. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96933. /**
  96934. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96935. * This allowed control for front to back rendering or reversly depending of the special needs.
  96936. *
  96937. * @param renderingGroupId The rendering group id corresponding to its index
  96938. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96939. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96940. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96941. */
  96942. 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;
  96943. /**
  96944. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96945. *
  96946. * @param renderingGroupId The rendering group id corresponding to its index
  96947. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96948. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96949. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96950. */
  96951. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96952. /**
  96953. * Gets the current auto clear configuration for one rendering group of the rendering
  96954. * manager.
  96955. * @param index the rendering group index to get the information for
  96956. * @returns The auto clear setup for the requested rendering group
  96957. */
  96958. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96959. private _blockMaterialDirtyMechanism;
  96960. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96961. blockMaterialDirtyMechanism: boolean;
  96962. /**
  96963. * Will flag all materials as dirty to trigger new shader compilation
  96964. * @param flag defines the flag used to specify which material part must be marked as dirty
  96965. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96966. */
  96967. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96968. /** @hidden */
  96969. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  96970. /** @hidden */
  96971. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96972. }
  96973. }
  96974. declare module BABYLON {
  96975. /**
  96976. * Set of assets to keep when moving a scene into an asset container.
  96977. */
  96978. export class KeepAssets extends AbstractScene {
  96979. }
  96980. /**
  96981. * Container with a set of assets that can be added or removed from a scene.
  96982. */
  96983. export class AssetContainer extends AbstractScene {
  96984. /**
  96985. * The scene the AssetContainer belongs to.
  96986. */
  96987. scene: Scene;
  96988. /**
  96989. * Instantiates an AssetContainer.
  96990. * @param scene The scene the AssetContainer belongs to.
  96991. */
  96992. constructor(scene: Scene);
  96993. /**
  96994. * Adds all the assets from the container to the scene.
  96995. */
  96996. addAllToScene(): void;
  96997. /**
  96998. * Removes all the assets in the container from the scene
  96999. */
  97000. removeAllFromScene(): void;
  97001. /**
  97002. * Disposes all the assets in the container
  97003. */
  97004. dispose(): void;
  97005. private _moveAssets;
  97006. /**
  97007. * Removes all the assets contained in the scene and adds them to the container.
  97008. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  97009. */
  97010. moveAllFromScene(keepAssets?: KeepAssets): void;
  97011. /**
  97012. * 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.
  97013. * @returns the root mesh
  97014. */
  97015. createRootMesh(): Mesh;
  97016. }
  97017. }
  97018. declare module BABYLON {
  97019. /**
  97020. * Defines how the parser contract is defined.
  97021. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  97022. */
  97023. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  97024. /**
  97025. * Defines how the individual parser contract is defined.
  97026. * These parser can parse an individual asset
  97027. */
  97028. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  97029. /**
  97030. * Base class of the scene acting as a container for the different elements composing a scene.
  97031. * This class is dynamically extended by the different components of the scene increasing
  97032. * flexibility and reducing coupling
  97033. */
  97034. export abstract class AbstractScene {
  97035. /**
  97036. * Stores the list of available parsers in the application.
  97037. */
  97038. private static _BabylonFileParsers;
  97039. /**
  97040. * Stores the list of available individual parsers in the application.
  97041. */
  97042. private static _IndividualBabylonFileParsers;
  97043. /**
  97044. * Adds a parser in the list of available ones
  97045. * @param name Defines the name of the parser
  97046. * @param parser Defines the parser to add
  97047. */
  97048. static AddParser(name: string, parser: BabylonFileParser): void;
  97049. /**
  97050. * Gets a general parser from the list of avaialble ones
  97051. * @param name Defines the name of the parser
  97052. * @returns the requested parser or null
  97053. */
  97054. static GetParser(name: string): Nullable<BabylonFileParser>;
  97055. /**
  97056. * Adds n individual parser in the list of available ones
  97057. * @param name Defines the name of the parser
  97058. * @param parser Defines the parser to add
  97059. */
  97060. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  97061. /**
  97062. * Gets an individual parser from the list of avaialble ones
  97063. * @param name Defines the name of the parser
  97064. * @returns the requested parser or null
  97065. */
  97066. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  97067. /**
  97068. * Parser json data and populate both a scene and its associated container object
  97069. * @param jsonData Defines the data to parse
  97070. * @param scene Defines the scene to parse the data for
  97071. * @param container Defines the container attached to the parsing sequence
  97072. * @param rootUrl Defines the root url of the data
  97073. */
  97074. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  97075. /**
  97076. * Gets the list of root nodes (ie. nodes with no parent)
  97077. */
  97078. rootNodes: Node[];
  97079. /** All of the cameras added to this scene
  97080. * @see http://doc.babylonjs.com/babylon101/cameras
  97081. */
  97082. cameras: Camera[];
  97083. /**
  97084. * All of the lights added to this scene
  97085. * @see http://doc.babylonjs.com/babylon101/lights
  97086. */
  97087. lights: Light[];
  97088. /**
  97089. * All of the (abstract) meshes added to this scene
  97090. */
  97091. meshes: AbstractMesh[];
  97092. /**
  97093. * The list of skeletons added to the scene
  97094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97095. */
  97096. skeletons: Skeleton[];
  97097. /**
  97098. * All of the particle systems added to this scene
  97099. * @see http://doc.babylonjs.com/babylon101/particles
  97100. */
  97101. particleSystems: IParticleSystem[];
  97102. /**
  97103. * Gets a list of Animations associated with the scene
  97104. */
  97105. animations: Animation[];
  97106. /**
  97107. * All of the animation groups added to this scene
  97108. * @see http://doc.babylonjs.com/how_to/group
  97109. */
  97110. animationGroups: AnimationGroup[];
  97111. /**
  97112. * All of the multi-materials added to this scene
  97113. * @see http://doc.babylonjs.com/how_to/multi_materials
  97114. */
  97115. multiMaterials: MultiMaterial[];
  97116. /**
  97117. * All of the materials added to this scene
  97118. * In the context of a Scene, it is not supposed to be modified manually.
  97119. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  97120. * Note also that the order of the Material wihin the array is not significant and might change.
  97121. * @see http://doc.babylonjs.com/babylon101/materials
  97122. */
  97123. materials: Material[];
  97124. /**
  97125. * The list of morph target managers added to the scene
  97126. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  97127. */
  97128. morphTargetManagers: MorphTargetManager[];
  97129. /**
  97130. * The list of geometries used in the scene.
  97131. */
  97132. geometries: Geometry[];
  97133. /**
  97134. * All of the tranform nodes added to this scene
  97135. * In the context of a Scene, it is not supposed to be modified manually.
  97136. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  97137. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  97138. * @see http://doc.babylonjs.com/how_to/transformnode
  97139. */
  97140. transformNodes: TransformNode[];
  97141. /**
  97142. * ActionManagers available on the scene.
  97143. */
  97144. actionManagers: AbstractActionManager[];
  97145. /**
  97146. * Textures to keep.
  97147. */
  97148. textures: BaseTexture[];
  97149. /**
  97150. * Environment texture for the scene
  97151. */
  97152. environmentTexture: Nullable<BaseTexture>;
  97153. }
  97154. }
  97155. declare module BABYLON {
  97156. /**
  97157. * Interface used to define options for Sound class
  97158. */
  97159. export interface ISoundOptions {
  97160. /**
  97161. * Does the sound autoplay once loaded.
  97162. */
  97163. autoplay?: boolean;
  97164. /**
  97165. * Does the sound loop after it finishes playing once.
  97166. */
  97167. loop?: boolean;
  97168. /**
  97169. * Sound's volume
  97170. */
  97171. volume?: number;
  97172. /**
  97173. * Is it a spatial sound?
  97174. */
  97175. spatialSound?: boolean;
  97176. /**
  97177. * Maximum distance to hear that sound
  97178. */
  97179. maxDistance?: number;
  97180. /**
  97181. * Uses user defined attenuation function
  97182. */
  97183. useCustomAttenuation?: boolean;
  97184. /**
  97185. * Define the roll off factor of spatial sounds.
  97186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97187. */
  97188. rolloffFactor?: number;
  97189. /**
  97190. * Define the reference distance the sound should be heard perfectly.
  97191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97192. */
  97193. refDistance?: number;
  97194. /**
  97195. * Define the distance attenuation model the sound will follow.
  97196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97197. */
  97198. distanceModel?: string;
  97199. /**
  97200. * Defines the playback speed (1 by default)
  97201. */
  97202. playbackRate?: number;
  97203. /**
  97204. * Defines if the sound is from a streaming source
  97205. */
  97206. streaming?: boolean;
  97207. /**
  97208. * Defines an optional length (in ms) inside the sound file
  97209. */
  97210. length?: number;
  97211. /**
  97212. * Defines an optional offset (in ms) inside the sound file
  97213. */
  97214. offset?: number;
  97215. }
  97216. /**
  97217. * Defines a sound that can be played in the application.
  97218. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  97219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97220. */
  97221. export class Sound {
  97222. /**
  97223. * The name of the sound in the scene.
  97224. */
  97225. name: string;
  97226. /**
  97227. * Does the sound autoplay once loaded.
  97228. */
  97229. autoplay: boolean;
  97230. /**
  97231. * Does the sound loop after it finishes playing once.
  97232. */
  97233. loop: boolean;
  97234. /**
  97235. * Does the sound use a custom attenuation curve to simulate the falloff
  97236. * happening when the source gets further away from the camera.
  97237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97238. */
  97239. useCustomAttenuation: boolean;
  97240. /**
  97241. * The sound track id this sound belongs to.
  97242. */
  97243. soundTrackId: number;
  97244. /**
  97245. * Is this sound currently played.
  97246. */
  97247. isPlaying: boolean;
  97248. /**
  97249. * Is this sound currently paused.
  97250. */
  97251. isPaused: boolean;
  97252. /**
  97253. * Does this sound enables spatial sound.
  97254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97255. */
  97256. spatialSound: boolean;
  97257. /**
  97258. * Define the reference distance the sound should be heard perfectly.
  97259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97260. */
  97261. refDistance: number;
  97262. /**
  97263. * Define the roll off factor of spatial sounds.
  97264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97265. */
  97266. rolloffFactor: number;
  97267. /**
  97268. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  97269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97270. */
  97271. maxDistance: number;
  97272. /**
  97273. * Define the distance attenuation model the sound will follow.
  97274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97275. */
  97276. distanceModel: string;
  97277. /**
  97278. * @hidden
  97279. * Back Compat
  97280. **/
  97281. onended: () => any;
  97282. /**
  97283. * Observable event when the current playing sound finishes.
  97284. */
  97285. onEndedObservable: Observable<Sound>;
  97286. private _panningModel;
  97287. private _playbackRate;
  97288. private _streaming;
  97289. private _startTime;
  97290. private _startOffset;
  97291. private _position;
  97292. /** @hidden */
  97293. _positionInEmitterSpace: boolean;
  97294. private _localDirection;
  97295. private _volume;
  97296. private _isReadyToPlay;
  97297. private _isDirectional;
  97298. private _readyToPlayCallback;
  97299. private _audioBuffer;
  97300. private _soundSource;
  97301. private _streamingSource;
  97302. private _soundPanner;
  97303. private _soundGain;
  97304. private _inputAudioNode;
  97305. private _outputAudioNode;
  97306. private _coneInnerAngle;
  97307. private _coneOuterAngle;
  97308. private _coneOuterGain;
  97309. private _scene;
  97310. private _connectedTransformNode;
  97311. private _customAttenuationFunction;
  97312. private _registerFunc;
  97313. private _isOutputConnected;
  97314. private _htmlAudioElement;
  97315. private _urlType;
  97316. private _length?;
  97317. private _offset?;
  97318. /** @hidden */
  97319. static _SceneComponentInitialization: (scene: Scene) => void;
  97320. /**
  97321. * Create a sound and attach it to a scene
  97322. * @param name Name of your sound
  97323. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97324. * @param scene defines the scene the sound belongs to
  97325. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97326. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97327. */
  97328. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97329. /**
  97330. * Release the sound and its associated resources
  97331. */
  97332. dispose(): void;
  97333. /**
  97334. * Gets if the sounds is ready to be played or not.
  97335. * @returns true if ready, otherwise false
  97336. */
  97337. isReady(): boolean;
  97338. private _soundLoaded;
  97339. /**
  97340. * Sets the data of the sound from an audiobuffer
  97341. * @param audioBuffer The audioBuffer containing the data
  97342. */
  97343. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97344. /**
  97345. * Updates the current sounds options such as maxdistance, loop...
  97346. * @param options A JSON object containing values named as the object properties
  97347. */
  97348. updateOptions(options: ISoundOptions): void;
  97349. private _createSpatialParameters;
  97350. private _updateSpatialParameters;
  97351. /**
  97352. * Switch the panning model to HRTF:
  97353. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97355. */
  97356. switchPanningModelToHRTF(): void;
  97357. /**
  97358. * Switch the panning model to Equal Power:
  97359. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97361. */
  97362. switchPanningModelToEqualPower(): void;
  97363. private _switchPanningModel;
  97364. /**
  97365. * Connect this sound to a sound track audio node like gain...
  97366. * @param soundTrackAudioNode the sound track audio node to connect to
  97367. */
  97368. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97369. /**
  97370. * Transform this sound into a directional source
  97371. * @param coneInnerAngle Size of the inner cone in degree
  97372. * @param coneOuterAngle Size of the outer cone in degree
  97373. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97374. */
  97375. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97376. /**
  97377. * Gets or sets the inner angle for the directional cone.
  97378. */
  97379. /**
  97380. * Gets or sets the inner angle for the directional cone.
  97381. */
  97382. directionalConeInnerAngle: number;
  97383. /**
  97384. * Gets or sets the outer angle for the directional cone.
  97385. */
  97386. /**
  97387. * Gets or sets the outer angle for the directional cone.
  97388. */
  97389. directionalConeOuterAngle: number;
  97390. /**
  97391. * Sets the position of the emitter if spatial sound is enabled
  97392. * @param newPosition Defines the new posisiton
  97393. */
  97394. setPosition(newPosition: Vector3): void;
  97395. /**
  97396. * Sets the local direction of the emitter if spatial sound is enabled
  97397. * @param newLocalDirection Defines the new local direction
  97398. */
  97399. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97400. private _updateDirection;
  97401. /** @hidden */
  97402. updateDistanceFromListener(): void;
  97403. /**
  97404. * Sets a new custom attenuation function for the sound.
  97405. * @param callback Defines the function used for the attenuation
  97406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97407. */
  97408. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97409. /**
  97410. * Play the sound
  97411. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97412. * @param offset (optional) Start the sound at a specific time in seconds
  97413. * @param length (optional) Sound duration (in seconds)
  97414. */
  97415. play(time?: number, offset?: number, length?: number): void;
  97416. private _onended;
  97417. /**
  97418. * Stop the sound
  97419. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97420. */
  97421. stop(time?: number): void;
  97422. /**
  97423. * Put the sound in pause
  97424. */
  97425. pause(): void;
  97426. /**
  97427. * Sets a dedicated volume for this sounds
  97428. * @param newVolume Define the new volume of the sound
  97429. * @param time Define time for gradual change to new volume
  97430. */
  97431. setVolume(newVolume: number, time?: number): void;
  97432. /**
  97433. * Set the sound play back rate
  97434. * @param newPlaybackRate Define the playback rate the sound should be played at
  97435. */
  97436. setPlaybackRate(newPlaybackRate: number): void;
  97437. /**
  97438. * Gets the volume of the sound.
  97439. * @returns the volume of the sound
  97440. */
  97441. getVolume(): number;
  97442. /**
  97443. * Attach the sound to a dedicated mesh
  97444. * @param transformNode The transform node to connect the sound with
  97445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97446. */
  97447. attachToMesh(transformNode: TransformNode): void;
  97448. /**
  97449. * Detach the sound from the previously attached mesh
  97450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97451. */
  97452. detachFromMesh(): void;
  97453. private _onRegisterAfterWorldMatrixUpdate;
  97454. /**
  97455. * Clone the current sound in the scene.
  97456. * @returns the new sound clone
  97457. */
  97458. clone(): Nullable<Sound>;
  97459. /**
  97460. * Gets the current underlying audio buffer containing the data
  97461. * @returns the audio buffer
  97462. */
  97463. getAudioBuffer(): Nullable<AudioBuffer>;
  97464. /**
  97465. * Serializes the Sound in a JSON representation
  97466. * @returns the JSON representation of the sound
  97467. */
  97468. serialize(): any;
  97469. /**
  97470. * Parse a JSON representation of a sound to innstantiate in a given scene
  97471. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97472. * @param scene Define the scene the new parsed sound should be created in
  97473. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97474. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97475. * @returns the newly parsed sound
  97476. */
  97477. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97478. }
  97479. }
  97480. declare module BABYLON {
  97481. /**
  97482. * This defines an action helpful to play a defined sound on a triggered action.
  97483. */
  97484. export class PlaySoundAction extends Action {
  97485. private _sound;
  97486. /**
  97487. * Instantiate the action
  97488. * @param triggerOptions defines the trigger options
  97489. * @param sound defines the sound to play
  97490. * @param condition defines the trigger related conditions
  97491. */
  97492. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97493. /** @hidden */
  97494. _prepare(): void;
  97495. /**
  97496. * Execute the action and play the sound.
  97497. */
  97498. execute(): void;
  97499. /**
  97500. * Serializes the actions and its related information.
  97501. * @param parent defines the object to serialize in
  97502. * @returns the serialized object
  97503. */
  97504. serialize(parent: any): any;
  97505. }
  97506. /**
  97507. * This defines an action helpful to stop a defined sound on a triggered action.
  97508. */
  97509. export class StopSoundAction extends Action {
  97510. private _sound;
  97511. /**
  97512. * Instantiate the action
  97513. * @param triggerOptions defines the trigger options
  97514. * @param sound defines the sound to stop
  97515. * @param condition defines the trigger related conditions
  97516. */
  97517. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97518. /** @hidden */
  97519. _prepare(): void;
  97520. /**
  97521. * Execute the action and stop the sound.
  97522. */
  97523. execute(): void;
  97524. /**
  97525. * Serializes the actions and its related information.
  97526. * @param parent defines the object to serialize in
  97527. * @returns the serialized object
  97528. */
  97529. serialize(parent: any): any;
  97530. }
  97531. }
  97532. declare module BABYLON {
  97533. /**
  97534. * This defines an action responsible to change the value of a property
  97535. * by interpolating between its current value and the newly set one once triggered.
  97536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97537. */
  97538. export class InterpolateValueAction extends Action {
  97539. /**
  97540. * Defines the path of the property where the value should be interpolated
  97541. */
  97542. propertyPath: string;
  97543. /**
  97544. * Defines the target value at the end of the interpolation.
  97545. */
  97546. value: any;
  97547. /**
  97548. * Defines the time it will take for the property to interpolate to the value.
  97549. */
  97550. duration: number;
  97551. /**
  97552. * Defines if the other scene animations should be stopped when the action has been triggered
  97553. */
  97554. stopOtherAnimations?: boolean;
  97555. /**
  97556. * Defines a callback raised once the interpolation animation has been done.
  97557. */
  97558. onInterpolationDone?: () => void;
  97559. /**
  97560. * Observable triggered once the interpolation animation has been done.
  97561. */
  97562. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97563. private _target;
  97564. private _effectiveTarget;
  97565. private _property;
  97566. /**
  97567. * Instantiate the action
  97568. * @param triggerOptions defines the trigger options
  97569. * @param target defines the object containing the value to interpolate
  97570. * @param propertyPath defines the path to the property in the target object
  97571. * @param value defines the target value at the end of the interpolation
  97572. * @param duration deines the time it will take for the property to interpolate to the value.
  97573. * @param condition defines the trigger related conditions
  97574. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97575. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97576. */
  97577. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97578. /** @hidden */
  97579. _prepare(): void;
  97580. /**
  97581. * Execute the action starts the value interpolation.
  97582. */
  97583. execute(): void;
  97584. /**
  97585. * Serializes the actions and its related information.
  97586. * @param parent defines the object to serialize in
  97587. * @returns the serialized object
  97588. */
  97589. serialize(parent: any): any;
  97590. }
  97591. }
  97592. declare module BABYLON {
  97593. /**
  97594. * Options allowed during the creation of a sound track.
  97595. */
  97596. export interface ISoundTrackOptions {
  97597. /**
  97598. * The volume the sound track should take during creation
  97599. */
  97600. volume?: number;
  97601. /**
  97602. * Define if the sound track is the main sound track of the scene
  97603. */
  97604. mainTrack?: boolean;
  97605. }
  97606. /**
  97607. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97608. * It will be also used in a future release to apply effects on a specific track.
  97609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97610. */
  97611. export class SoundTrack {
  97612. /**
  97613. * The unique identifier of the sound track in the scene.
  97614. */
  97615. id: number;
  97616. /**
  97617. * The list of sounds included in the sound track.
  97618. */
  97619. soundCollection: Array<Sound>;
  97620. private _outputAudioNode;
  97621. private _scene;
  97622. private _isMainTrack;
  97623. private _connectedAnalyser;
  97624. private _options;
  97625. private _isInitialized;
  97626. /**
  97627. * Creates a new sound track.
  97628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97629. * @param scene Define the scene the sound track belongs to
  97630. * @param options
  97631. */
  97632. constructor(scene: Scene, options?: ISoundTrackOptions);
  97633. private _initializeSoundTrackAudioGraph;
  97634. /**
  97635. * Release the sound track and its associated resources
  97636. */
  97637. dispose(): void;
  97638. /**
  97639. * Adds a sound to this sound track
  97640. * @param sound define the cound to add
  97641. * @ignoreNaming
  97642. */
  97643. AddSound(sound: Sound): void;
  97644. /**
  97645. * Removes a sound to this sound track
  97646. * @param sound define the cound to remove
  97647. * @ignoreNaming
  97648. */
  97649. RemoveSound(sound: Sound): void;
  97650. /**
  97651. * Set a global volume for the full sound track.
  97652. * @param newVolume Define the new volume of the sound track
  97653. */
  97654. setVolume(newVolume: number): void;
  97655. /**
  97656. * Switch the panning model to HRTF:
  97657. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97659. */
  97660. switchPanningModelToHRTF(): void;
  97661. /**
  97662. * Switch the panning model to Equal Power:
  97663. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97665. */
  97666. switchPanningModelToEqualPower(): void;
  97667. /**
  97668. * Connect the sound track to an audio analyser allowing some amazing
  97669. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97671. * @param analyser The analyser to connect to the engine
  97672. */
  97673. connectToAnalyser(analyser: Analyser): void;
  97674. }
  97675. }
  97676. declare module BABYLON {
  97677. interface AbstractScene {
  97678. /**
  97679. * The list of sounds used in the scene.
  97680. */
  97681. sounds: Nullable<Array<Sound>>;
  97682. }
  97683. interface Scene {
  97684. /**
  97685. * @hidden
  97686. * Backing field
  97687. */
  97688. _mainSoundTrack: SoundTrack;
  97689. /**
  97690. * The main sound track played by the scene.
  97691. * It cotains your primary collection of sounds.
  97692. */
  97693. mainSoundTrack: SoundTrack;
  97694. /**
  97695. * The list of sound tracks added to the scene
  97696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97697. */
  97698. soundTracks: Nullable<Array<SoundTrack>>;
  97699. /**
  97700. * Gets a sound using a given name
  97701. * @param name defines the name to search for
  97702. * @return the found sound or null if not found at all.
  97703. */
  97704. getSoundByName(name: string): Nullable<Sound>;
  97705. /**
  97706. * Gets or sets if audio support is enabled
  97707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97708. */
  97709. audioEnabled: boolean;
  97710. /**
  97711. * Gets or sets if audio will be output to headphones
  97712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97713. */
  97714. headphone: boolean;
  97715. }
  97716. /**
  97717. * Defines the sound scene component responsible to manage any sounds
  97718. * in a given scene.
  97719. */
  97720. export class AudioSceneComponent implements ISceneSerializableComponent {
  97721. /**
  97722. * The component name helpfull to identify the component in the list of scene components.
  97723. */
  97724. readonly name: string;
  97725. /**
  97726. * The scene the component belongs to.
  97727. */
  97728. scene: Scene;
  97729. private _audioEnabled;
  97730. /**
  97731. * Gets whether audio is enabled or not.
  97732. * Please use related enable/disable method to switch state.
  97733. */
  97734. readonly audioEnabled: boolean;
  97735. private _headphone;
  97736. /**
  97737. * Gets whether audio is outputing to headphone or not.
  97738. * Please use the according Switch methods to change output.
  97739. */
  97740. readonly headphone: boolean;
  97741. /**
  97742. * Creates a new instance of the component for the given scene
  97743. * @param scene Defines the scene to register the component in
  97744. */
  97745. constructor(scene: Scene);
  97746. /**
  97747. * Registers the component in a given scene
  97748. */
  97749. register(): void;
  97750. /**
  97751. * Rebuilds the elements related to this component in case of
  97752. * context lost for instance.
  97753. */
  97754. rebuild(): void;
  97755. /**
  97756. * Serializes the component data to the specified json object
  97757. * @param serializationObject The object to serialize to
  97758. */
  97759. serialize(serializationObject: any): void;
  97760. /**
  97761. * Adds all the elements from the container to the scene
  97762. * @param container the container holding the elements
  97763. */
  97764. addFromContainer(container: AbstractScene): void;
  97765. /**
  97766. * Removes all the elements in the container from the scene
  97767. * @param container contains the elements to remove
  97768. * @param dispose if the removed element should be disposed (default: false)
  97769. */
  97770. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97771. /**
  97772. * Disposes the component and the associated ressources.
  97773. */
  97774. dispose(): void;
  97775. /**
  97776. * Disables audio in the associated scene.
  97777. */
  97778. disableAudio(): void;
  97779. /**
  97780. * Enables audio in the associated scene.
  97781. */
  97782. enableAudio(): void;
  97783. /**
  97784. * Switch audio to headphone output.
  97785. */
  97786. switchAudioModeForHeadphones(): void;
  97787. /**
  97788. * Switch audio to normal speakers.
  97789. */
  97790. switchAudioModeForNormalSpeakers(): void;
  97791. private _afterRender;
  97792. }
  97793. }
  97794. declare module BABYLON {
  97795. /**
  97796. * Wraps one or more Sound objects and selects one with random weight for playback.
  97797. */
  97798. export class WeightedSound {
  97799. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97800. loop: boolean;
  97801. private _coneInnerAngle;
  97802. private _coneOuterAngle;
  97803. private _volume;
  97804. /** A Sound is currently playing. */
  97805. isPlaying: boolean;
  97806. /** A Sound is currently paused. */
  97807. isPaused: boolean;
  97808. private _sounds;
  97809. private _weights;
  97810. private _currentIndex?;
  97811. /**
  97812. * Creates a new WeightedSound from the list of sounds given.
  97813. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97814. * @param sounds Array of Sounds that will be selected from.
  97815. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97816. */
  97817. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97818. /**
  97819. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97820. */
  97821. /**
  97822. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97823. */
  97824. directionalConeInnerAngle: number;
  97825. /**
  97826. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97827. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97828. */
  97829. /**
  97830. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97831. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97832. */
  97833. directionalConeOuterAngle: number;
  97834. /**
  97835. * Playback volume.
  97836. */
  97837. /**
  97838. * Playback volume.
  97839. */
  97840. volume: number;
  97841. private _onended;
  97842. /**
  97843. * Suspend playback
  97844. */
  97845. pause(): void;
  97846. /**
  97847. * Stop playback
  97848. */
  97849. stop(): void;
  97850. /**
  97851. * Start playback.
  97852. * @param startOffset Position the clip head at a specific time in seconds.
  97853. */
  97854. play(startOffset?: number): void;
  97855. }
  97856. }
  97857. declare module BABYLON {
  97858. /**
  97859. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97860. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97861. */
  97862. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97863. /**
  97864. * Gets the name of the behavior.
  97865. */
  97866. readonly name: string;
  97867. /**
  97868. * The easing function used by animations
  97869. */
  97870. static EasingFunction: BackEase;
  97871. /**
  97872. * The easing mode used by animations
  97873. */
  97874. static EasingMode: number;
  97875. /**
  97876. * The duration of the animation, in milliseconds
  97877. */
  97878. transitionDuration: number;
  97879. /**
  97880. * Length of the distance animated by the transition when lower radius is reached
  97881. */
  97882. lowerRadiusTransitionRange: number;
  97883. /**
  97884. * Length of the distance animated by the transition when upper radius is reached
  97885. */
  97886. upperRadiusTransitionRange: number;
  97887. private _autoTransitionRange;
  97888. /**
  97889. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97890. */
  97891. /**
  97892. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97893. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97894. */
  97895. autoTransitionRange: boolean;
  97896. private _attachedCamera;
  97897. private _onAfterCheckInputsObserver;
  97898. private _onMeshTargetChangedObserver;
  97899. /**
  97900. * Initializes the behavior.
  97901. */
  97902. init(): void;
  97903. /**
  97904. * Attaches the behavior to its arc rotate camera.
  97905. * @param camera Defines the camera to attach the behavior to
  97906. */
  97907. attach(camera: ArcRotateCamera): void;
  97908. /**
  97909. * Detaches the behavior from its current arc rotate camera.
  97910. */
  97911. detach(): void;
  97912. private _radiusIsAnimating;
  97913. private _radiusBounceTransition;
  97914. private _animatables;
  97915. private _cachedWheelPrecision;
  97916. /**
  97917. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97918. * @param radiusLimit The limit to check against.
  97919. * @return Bool to indicate if at limit.
  97920. */
  97921. private _isRadiusAtLimit;
  97922. /**
  97923. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97924. * @param radiusDelta The delta by which to animate to. Can be negative.
  97925. */
  97926. private _applyBoundRadiusAnimation;
  97927. /**
  97928. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97929. */
  97930. protected _clearAnimationLocks(): void;
  97931. /**
  97932. * Stops and removes all animations that have been applied to the camera
  97933. */
  97934. stopAllAnimations(): void;
  97935. }
  97936. }
  97937. declare module BABYLON {
  97938. /**
  97939. * 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.
  97940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97941. */
  97942. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97943. /**
  97944. * Gets the name of the behavior.
  97945. */
  97946. readonly name: string;
  97947. private _mode;
  97948. private _radiusScale;
  97949. private _positionScale;
  97950. private _defaultElevation;
  97951. private _elevationReturnTime;
  97952. private _elevationReturnWaitTime;
  97953. private _zoomStopsAnimation;
  97954. private _framingTime;
  97955. /**
  97956. * The easing function used by animations
  97957. */
  97958. static EasingFunction: ExponentialEase;
  97959. /**
  97960. * The easing mode used by animations
  97961. */
  97962. static EasingMode: number;
  97963. /**
  97964. * Sets the current mode used by the behavior
  97965. */
  97966. /**
  97967. * Gets current mode used by the behavior.
  97968. */
  97969. mode: number;
  97970. /**
  97971. * Sets the scale applied to the radius (1 by default)
  97972. */
  97973. /**
  97974. * Gets the scale applied to the radius
  97975. */
  97976. radiusScale: number;
  97977. /**
  97978. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97979. */
  97980. /**
  97981. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97982. */
  97983. positionScale: number;
  97984. /**
  97985. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97986. * behaviour is triggered, in radians.
  97987. */
  97988. /**
  97989. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97990. * behaviour is triggered, in radians.
  97991. */
  97992. defaultElevation: number;
  97993. /**
  97994. * Sets the time (in milliseconds) taken to return to the default beta position.
  97995. * Negative value indicates camera should not return to default.
  97996. */
  97997. /**
  97998. * Gets the time (in milliseconds) taken to return to the default beta position.
  97999. * Negative value indicates camera should not return to default.
  98000. */
  98001. elevationReturnTime: number;
  98002. /**
  98003. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98004. */
  98005. /**
  98006. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98007. */
  98008. elevationReturnWaitTime: number;
  98009. /**
  98010. * Sets the flag that indicates if user zooming should stop animation.
  98011. */
  98012. /**
  98013. * Gets the flag that indicates if user zooming should stop animation.
  98014. */
  98015. zoomStopsAnimation: boolean;
  98016. /**
  98017. * Sets the transition time when framing the mesh, in milliseconds
  98018. */
  98019. /**
  98020. * Gets the transition time when framing the mesh, in milliseconds
  98021. */
  98022. framingTime: number;
  98023. /**
  98024. * Define if the behavior should automatically change the configured
  98025. * camera limits and sensibilities.
  98026. */
  98027. autoCorrectCameraLimitsAndSensibility: boolean;
  98028. private _onPrePointerObservableObserver;
  98029. private _onAfterCheckInputsObserver;
  98030. private _onMeshTargetChangedObserver;
  98031. private _attachedCamera;
  98032. private _isPointerDown;
  98033. private _lastInteractionTime;
  98034. /**
  98035. * Initializes the behavior.
  98036. */
  98037. init(): void;
  98038. /**
  98039. * Attaches the behavior to its arc rotate camera.
  98040. * @param camera Defines the camera to attach the behavior to
  98041. */
  98042. attach(camera: ArcRotateCamera): void;
  98043. /**
  98044. * Detaches the behavior from its current arc rotate camera.
  98045. */
  98046. detach(): void;
  98047. private _animatables;
  98048. private _betaIsAnimating;
  98049. private _betaTransition;
  98050. private _radiusTransition;
  98051. private _vectorTransition;
  98052. /**
  98053. * Targets the given mesh and updates zoom level accordingly.
  98054. * @param mesh The mesh to target.
  98055. * @param radius Optional. If a cached radius position already exists, overrides default.
  98056. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98057. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98058. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98059. */
  98060. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98061. /**
  98062. * Targets the given mesh with its children and updates zoom level accordingly.
  98063. * @param mesh The mesh to target.
  98064. * @param radius Optional. If a cached radius position already exists, overrides default.
  98065. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98066. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98067. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98068. */
  98069. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98070. /**
  98071. * Targets the given meshes with their children and updates zoom level accordingly.
  98072. * @param meshes The mesh to target.
  98073. * @param radius Optional. If a cached radius position already exists, overrides default.
  98074. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98075. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98076. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98077. */
  98078. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98079. /**
  98080. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  98081. * @param minimumWorld Determines the smaller position of the bounding box extend
  98082. * @param maximumWorld Determines the bigger position of the bounding box extend
  98083. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98084. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98085. */
  98086. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98087. /**
  98088. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  98089. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  98090. * frustum width.
  98091. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  98092. * to fully enclose the mesh in the viewing frustum.
  98093. */
  98094. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  98095. /**
  98096. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  98097. * is automatically returned to its default position (expected to be above ground plane).
  98098. */
  98099. private _maintainCameraAboveGround;
  98100. /**
  98101. * Returns the frustum slope based on the canvas ratio and camera FOV
  98102. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  98103. */
  98104. private _getFrustumSlope;
  98105. /**
  98106. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  98107. */
  98108. private _clearAnimationLocks;
  98109. /**
  98110. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98111. */
  98112. private _applyUserInteraction;
  98113. /**
  98114. * Stops and removes all animations that have been applied to the camera
  98115. */
  98116. stopAllAnimations(): void;
  98117. /**
  98118. * Gets a value indicating if the user is moving the camera
  98119. */
  98120. readonly isUserIsMoving: boolean;
  98121. /**
  98122. * The camera can move all the way towards the mesh.
  98123. */
  98124. static IgnoreBoundsSizeMode: number;
  98125. /**
  98126. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  98127. */
  98128. static FitFrustumSidesMode: number;
  98129. }
  98130. }
  98131. declare module BABYLON {
  98132. /**
  98133. * Base class for Camera Pointer Inputs.
  98134. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  98135. * for example usage.
  98136. */
  98137. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  98138. /**
  98139. * Defines the camera the input is attached to.
  98140. */
  98141. abstract camera: Camera;
  98142. /**
  98143. * Whether keyboard modifier keys are pressed at time of last mouse event.
  98144. */
  98145. protected _altKey: boolean;
  98146. protected _ctrlKey: boolean;
  98147. protected _metaKey: boolean;
  98148. protected _shiftKey: boolean;
  98149. /**
  98150. * Which mouse buttons were pressed at time of last mouse event.
  98151. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  98152. */
  98153. protected _buttonsPressed: number;
  98154. /**
  98155. * Defines the buttons associated with the input to handle camera move.
  98156. */
  98157. buttons: number[];
  98158. /**
  98159. * Attach the input controls to a specific dom element to get the input from.
  98160. * @param element Defines the element the controls should be listened from
  98161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98162. */
  98163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98164. /**
  98165. * Detach the current controls from the specified dom element.
  98166. * @param element Defines the element to stop listening the inputs from
  98167. */
  98168. detachControl(element: Nullable<HTMLElement>): void;
  98169. /**
  98170. * Gets the class name of the current input.
  98171. * @returns the class name
  98172. */
  98173. getClassName(): string;
  98174. /**
  98175. * Get the friendly name associated with the input class.
  98176. * @returns the input friendly name
  98177. */
  98178. getSimpleName(): string;
  98179. /**
  98180. * Called on pointer POINTERDOUBLETAP event.
  98181. * Override this method to provide functionality on POINTERDOUBLETAP event.
  98182. */
  98183. protected onDoubleTap(type: string): void;
  98184. /**
  98185. * Called on pointer POINTERMOVE event if only a single touch is active.
  98186. * Override this method to provide functionality.
  98187. */
  98188. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98189. /**
  98190. * Called on pointer POINTERMOVE event if multiple touches are active.
  98191. * Override this method to provide functionality.
  98192. */
  98193. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98194. /**
  98195. * Called on JS contextmenu event.
  98196. * Override this method to provide functionality.
  98197. */
  98198. protected onContextMenu(evt: PointerEvent): void;
  98199. /**
  98200. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98201. * press.
  98202. * Override this method to provide functionality.
  98203. */
  98204. protected onButtonDown(evt: PointerEvent): void;
  98205. /**
  98206. * Called each time a new POINTERUP event occurs. Ie, for each button
  98207. * release.
  98208. * Override this method to provide functionality.
  98209. */
  98210. protected onButtonUp(evt: PointerEvent): void;
  98211. /**
  98212. * Called when window becomes inactive.
  98213. * Override this method to provide functionality.
  98214. */
  98215. protected onLostFocus(): void;
  98216. private _pointerInput;
  98217. private _observer;
  98218. private _onLostFocus;
  98219. private pointA;
  98220. private pointB;
  98221. }
  98222. }
  98223. declare module BABYLON {
  98224. /**
  98225. * Manage the pointers inputs to control an arc rotate camera.
  98226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98227. */
  98228. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  98229. /**
  98230. * Defines the camera the input is attached to.
  98231. */
  98232. camera: ArcRotateCamera;
  98233. /**
  98234. * Gets the class name of the current input.
  98235. * @returns the class name
  98236. */
  98237. getClassName(): string;
  98238. /**
  98239. * Defines the buttons associated with the input to handle camera move.
  98240. */
  98241. buttons: number[];
  98242. /**
  98243. * Defines the pointer angular sensibility along the X axis or how fast is
  98244. * the camera rotating.
  98245. */
  98246. angularSensibilityX: number;
  98247. /**
  98248. * Defines the pointer angular sensibility along the Y axis or how fast is
  98249. * the camera rotating.
  98250. */
  98251. angularSensibilityY: number;
  98252. /**
  98253. * Defines the pointer pinch precision or how fast is the camera zooming.
  98254. */
  98255. pinchPrecision: number;
  98256. /**
  98257. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98258. * from 0.
  98259. * It defines the percentage of current camera.radius to use as delta when
  98260. * pinch zoom is used.
  98261. */
  98262. pinchDeltaPercentage: number;
  98263. /**
  98264. * Defines the pointer panning sensibility or how fast is the camera moving.
  98265. */
  98266. panningSensibility: number;
  98267. /**
  98268. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  98269. */
  98270. multiTouchPanning: boolean;
  98271. /**
  98272. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  98273. * zoom (pinch) through multitouch.
  98274. */
  98275. multiTouchPanAndZoom: boolean;
  98276. /**
  98277. * Revers pinch action direction.
  98278. */
  98279. pinchInwards: boolean;
  98280. private _isPanClick;
  98281. private _twoFingerActivityCount;
  98282. private _isPinching;
  98283. /**
  98284. * Called on pointer POINTERMOVE event if only a single touch is active.
  98285. */
  98286. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98287. /**
  98288. * Called on pointer POINTERDOUBLETAP event.
  98289. */
  98290. protected onDoubleTap(type: string): void;
  98291. /**
  98292. * Called on pointer POINTERMOVE event if multiple touches are active.
  98293. */
  98294. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98295. /**
  98296. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98297. * press.
  98298. */
  98299. protected onButtonDown(evt: PointerEvent): void;
  98300. /**
  98301. * Called each time a new POINTERUP event occurs. Ie, for each button
  98302. * release.
  98303. */
  98304. protected onButtonUp(evt: PointerEvent): void;
  98305. /**
  98306. * Called when window becomes inactive.
  98307. */
  98308. protected onLostFocus(): void;
  98309. }
  98310. }
  98311. declare module BABYLON {
  98312. /**
  98313. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98315. */
  98316. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98317. /**
  98318. * Defines the camera the input is attached to.
  98319. */
  98320. camera: ArcRotateCamera;
  98321. /**
  98322. * Defines the list of key codes associated with the up action (increase alpha)
  98323. */
  98324. keysUp: number[];
  98325. /**
  98326. * Defines the list of key codes associated with the down action (decrease alpha)
  98327. */
  98328. keysDown: number[];
  98329. /**
  98330. * Defines the list of key codes associated with the left action (increase beta)
  98331. */
  98332. keysLeft: number[];
  98333. /**
  98334. * Defines the list of key codes associated with the right action (decrease beta)
  98335. */
  98336. keysRight: number[];
  98337. /**
  98338. * Defines the list of key codes associated with the reset action.
  98339. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98340. */
  98341. keysReset: number[];
  98342. /**
  98343. * Defines the panning sensibility of the inputs.
  98344. * (How fast is the camera paning)
  98345. */
  98346. panningSensibility: number;
  98347. /**
  98348. * Defines the zooming sensibility of the inputs.
  98349. * (How fast is the camera zooming)
  98350. */
  98351. zoomingSensibility: number;
  98352. /**
  98353. * Defines wether maintaining the alt key down switch the movement mode from
  98354. * orientation to zoom.
  98355. */
  98356. useAltToZoom: boolean;
  98357. /**
  98358. * Rotation speed of the camera
  98359. */
  98360. angularSpeed: number;
  98361. private _keys;
  98362. private _ctrlPressed;
  98363. private _altPressed;
  98364. private _onCanvasBlurObserver;
  98365. private _onKeyboardObserver;
  98366. private _engine;
  98367. private _scene;
  98368. /**
  98369. * Attach the input controls to a specific dom element to get the input from.
  98370. * @param element Defines the element the controls should be listened from
  98371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98372. */
  98373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98374. /**
  98375. * Detach the current controls from the specified dom element.
  98376. * @param element Defines the element to stop listening the inputs from
  98377. */
  98378. detachControl(element: Nullable<HTMLElement>): void;
  98379. /**
  98380. * Update the current camera state depending on the inputs that have been used this frame.
  98381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98382. */
  98383. checkInputs(): void;
  98384. /**
  98385. * Gets the class name of the current intput.
  98386. * @returns the class name
  98387. */
  98388. getClassName(): string;
  98389. /**
  98390. * Get the friendly name associated with the input class.
  98391. * @returns the input friendly name
  98392. */
  98393. getSimpleName(): string;
  98394. }
  98395. }
  98396. declare module BABYLON {
  98397. /**
  98398. * Manage the mouse wheel inputs to control an arc rotate camera.
  98399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98400. */
  98401. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98402. /**
  98403. * Defines the camera the input is attached to.
  98404. */
  98405. camera: ArcRotateCamera;
  98406. /**
  98407. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98408. */
  98409. wheelPrecision: number;
  98410. /**
  98411. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98412. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98413. */
  98414. wheelDeltaPercentage: number;
  98415. private _wheel;
  98416. private _observer;
  98417. private computeDeltaFromMouseWheelLegacyEvent;
  98418. /**
  98419. * Attach the input controls to a specific dom element to get the input from.
  98420. * @param element Defines the element the controls should be listened from
  98421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98422. */
  98423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98424. /**
  98425. * Detach the current controls from the specified dom element.
  98426. * @param element Defines the element to stop listening the inputs from
  98427. */
  98428. detachControl(element: Nullable<HTMLElement>): void;
  98429. /**
  98430. * Gets the class name of the current intput.
  98431. * @returns the class name
  98432. */
  98433. getClassName(): string;
  98434. /**
  98435. * Get the friendly name associated with the input class.
  98436. * @returns the input friendly name
  98437. */
  98438. getSimpleName(): string;
  98439. }
  98440. }
  98441. declare module BABYLON {
  98442. /**
  98443. * Default Inputs manager for the ArcRotateCamera.
  98444. * It groups all the default supported inputs for ease of use.
  98445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98446. */
  98447. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98448. /**
  98449. * Instantiates a new ArcRotateCameraInputsManager.
  98450. * @param camera Defines the camera the inputs belong to
  98451. */
  98452. constructor(camera: ArcRotateCamera);
  98453. /**
  98454. * Add mouse wheel input support to the input manager.
  98455. * @returns the current input manager
  98456. */
  98457. addMouseWheel(): ArcRotateCameraInputsManager;
  98458. /**
  98459. * Add pointers input support to the input manager.
  98460. * @returns the current input manager
  98461. */
  98462. addPointers(): ArcRotateCameraInputsManager;
  98463. /**
  98464. * Add keyboard input support to the input manager.
  98465. * @returns the current input manager
  98466. */
  98467. addKeyboard(): ArcRotateCameraInputsManager;
  98468. }
  98469. }
  98470. declare module BABYLON {
  98471. /**
  98472. * This represents an orbital type of camera.
  98473. *
  98474. * 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.
  98475. * 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.
  98476. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98477. */
  98478. export class ArcRotateCamera extends TargetCamera {
  98479. /**
  98480. * Defines the rotation angle of the camera along the longitudinal axis.
  98481. */
  98482. alpha: number;
  98483. /**
  98484. * Defines the rotation angle of the camera along the latitudinal axis.
  98485. */
  98486. beta: number;
  98487. /**
  98488. * Defines the radius of the camera from it s target point.
  98489. */
  98490. radius: number;
  98491. protected _target: Vector3;
  98492. protected _targetHost: Nullable<AbstractMesh>;
  98493. /**
  98494. * Defines the target point of the camera.
  98495. * The camera looks towards it form the radius distance.
  98496. */
  98497. target: Vector3;
  98498. /**
  98499. * Define the current local position of the camera in the scene
  98500. */
  98501. position: Vector3;
  98502. protected _upVector: Vector3;
  98503. protected _upToYMatrix: Matrix;
  98504. protected _YToUpMatrix: Matrix;
  98505. /**
  98506. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98507. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98508. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98509. */
  98510. upVector: Vector3;
  98511. /**
  98512. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98513. */
  98514. setMatUp(): void;
  98515. /**
  98516. * Current inertia value on the longitudinal axis.
  98517. * The bigger this number the longer it will take for the camera to stop.
  98518. */
  98519. inertialAlphaOffset: number;
  98520. /**
  98521. * Current inertia value on the latitudinal axis.
  98522. * The bigger this number the longer it will take for the camera to stop.
  98523. */
  98524. inertialBetaOffset: number;
  98525. /**
  98526. * Current inertia value on the radius axis.
  98527. * The bigger this number the longer it will take for the camera to stop.
  98528. */
  98529. inertialRadiusOffset: number;
  98530. /**
  98531. * Minimum allowed angle on the longitudinal axis.
  98532. * This can help limiting how the Camera is able to move in the scene.
  98533. */
  98534. lowerAlphaLimit: Nullable<number>;
  98535. /**
  98536. * Maximum allowed angle on the longitudinal axis.
  98537. * This can help limiting how the Camera is able to move in the scene.
  98538. */
  98539. upperAlphaLimit: Nullable<number>;
  98540. /**
  98541. * Minimum allowed angle on the latitudinal axis.
  98542. * This can help limiting how the Camera is able to move in the scene.
  98543. */
  98544. lowerBetaLimit: number;
  98545. /**
  98546. * Maximum allowed angle on the latitudinal axis.
  98547. * This can help limiting how the Camera is able to move in the scene.
  98548. */
  98549. upperBetaLimit: number;
  98550. /**
  98551. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98552. * This can help limiting how the Camera is able to move in the scene.
  98553. */
  98554. lowerRadiusLimit: Nullable<number>;
  98555. /**
  98556. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98557. * This can help limiting how the Camera is able to move in the scene.
  98558. */
  98559. upperRadiusLimit: Nullable<number>;
  98560. /**
  98561. * Defines the current inertia value used during panning of the camera along the X axis.
  98562. */
  98563. inertialPanningX: number;
  98564. /**
  98565. * Defines the current inertia value used during panning of the camera along the Y axis.
  98566. */
  98567. inertialPanningY: number;
  98568. /**
  98569. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98570. * Basically if your fingers moves away from more than this distance you will be considered
  98571. * in pinch mode.
  98572. */
  98573. pinchToPanMaxDistance: number;
  98574. /**
  98575. * Defines the maximum distance the camera can pan.
  98576. * This could help keeping the cammera always in your scene.
  98577. */
  98578. panningDistanceLimit: Nullable<number>;
  98579. /**
  98580. * Defines the target of the camera before paning.
  98581. */
  98582. panningOriginTarget: Vector3;
  98583. /**
  98584. * Defines the value of the inertia used during panning.
  98585. * 0 would mean stop inertia and one would mean no decelleration at all.
  98586. */
  98587. panningInertia: number;
  98588. /**
  98589. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98590. */
  98591. angularSensibilityX: number;
  98592. /**
  98593. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98594. */
  98595. angularSensibilityY: number;
  98596. /**
  98597. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98598. */
  98599. pinchPrecision: number;
  98600. /**
  98601. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98602. * It will be used instead of pinchDeltaPrecision if different from 0.
  98603. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98604. */
  98605. pinchDeltaPercentage: number;
  98606. /**
  98607. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98608. */
  98609. panningSensibility: number;
  98610. /**
  98611. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98612. */
  98613. keysUp: number[];
  98614. /**
  98615. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98616. */
  98617. keysDown: number[];
  98618. /**
  98619. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98620. */
  98621. keysLeft: number[];
  98622. /**
  98623. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98624. */
  98625. keysRight: number[];
  98626. /**
  98627. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98628. */
  98629. wheelPrecision: number;
  98630. /**
  98631. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98632. * It will be used instead of pinchDeltaPrecision if different from 0.
  98633. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98634. */
  98635. wheelDeltaPercentage: number;
  98636. /**
  98637. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98638. */
  98639. zoomOnFactor: number;
  98640. /**
  98641. * Defines a screen offset for the camera position.
  98642. */
  98643. targetScreenOffset: Vector2;
  98644. /**
  98645. * Allows the camera to be completely reversed.
  98646. * If false the camera can not arrive upside down.
  98647. */
  98648. allowUpsideDown: boolean;
  98649. /**
  98650. * Define if double tap/click is used to restore the previously saved state of the camera.
  98651. */
  98652. useInputToRestoreState: boolean;
  98653. /** @hidden */
  98654. _viewMatrix: Matrix;
  98655. /** @hidden */
  98656. _useCtrlForPanning: boolean;
  98657. /** @hidden */
  98658. _panningMouseButton: number;
  98659. /**
  98660. * Defines the input associated to the camera.
  98661. */
  98662. inputs: ArcRotateCameraInputsManager;
  98663. /** @hidden */
  98664. _reset: () => void;
  98665. /**
  98666. * Defines the allowed panning axis.
  98667. */
  98668. panningAxis: Vector3;
  98669. protected _localDirection: Vector3;
  98670. protected _transformedDirection: Vector3;
  98671. private _bouncingBehavior;
  98672. /**
  98673. * Gets the bouncing behavior of the camera if it has been enabled.
  98674. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98675. */
  98676. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98677. /**
  98678. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98680. */
  98681. useBouncingBehavior: boolean;
  98682. private _framingBehavior;
  98683. /**
  98684. * Gets the framing behavior of the camera if it has been enabled.
  98685. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98686. */
  98687. readonly framingBehavior: Nullable<FramingBehavior>;
  98688. /**
  98689. * Defines if the framing behavior of the camera is enabled on the camera.
  98690. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98691. */
  98692. useFramingBehavior: boolean;
  98693. private _autoRotationBehavior;
  98694. /**
  98695. * Gets the auto rotation behavior of the camera if it has been enabled.
  98696. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98697. */
  98698. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98699. /**
  98700. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98701. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98702. */
  98703. useAutoRotationBehavior: boolean;
  98704. /**
  98705. * Observable triggered when the mesh target has been changed on the camera.
  98706. */
  98707. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98708. /**
  98709. * Event raised when the camera is colliding with a mesh.
  98710. */
  98711. onCollide: (collidedMesh: AbstractMesh) => void;
  98712. /**
  98713. * Defines whether the camera should check collision with the objects oh the scene.
  98714. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98715. */
  98716. checkCollisions: boolean;
  98717. /**
  98718. * Defines the collision radius of the camera.
  98719. * This simulates a sphere around the camera.
  98720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98721. */
  98722. collisionRadius: Vector3;
  98723. protected _collider: Collider;
  98724. protected _previousPosition: Vector3;
  98725. protected _collisionVelocity: Vector3;
  98726. protected _newPosition: Vector3;
  98727. protected _previousAlpha: number;
  98728. protected _previousBeta: number;
  98729. protected _previousRadius: number;
  98730. protected _collisionTriggered: boolean;
  98731. protected _targetBoundingCenter: Nullable<Vector3>;
  98732. private _computationVector;
  98733. /**
  98734. * Instantiates a new ArcRotateCamera in a given scene
  98735. * @param name Defines the name of the camera
  98736. * @param alpha Defines the camera rotation along the logitudinal axis
  98737. * @param beta Defines the camera rotation along the latitudinal axis
  98738. * @param radius Defines the camera distance from its target
  98739. * @param target Defines the camera target
  98740. * @param scene Defines the scene the camera belongs to
  98741. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98742. */
  98743. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98744. /** @hidden */
  98745. _initCache(): void;
  98746. /** @hidden */
  98747. _updateCache(ignoreParentClass?: boolean): void;
  98748. protected _getTargetPosition(): Vector3;
  98749. private _storedAlpha;
  98750. private _storedBeta;
  98751. private _storedRadius;
  98752. private _storedTarget;
  98753. /**
  98754. * Stores the current state of the camera (alpha, beta, radius and target)
  98755. * @returns the camera itself
  98756. */
  98757. storeState(): Camera;
  98758. /**
  98759. * @hidden
  98760. * Restored camera state. You must call storeState() first
  98761. */
  98762. _restoreStateValues(): boolean;
  98763. /** @hidden */
  98764. _isSynchronizedViewMatrix(): boolean;
  98765. /**
  98766. * Attached controls to the current camera.
  98767. * @param element Defines the element the controls should be listened from
  98768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98769. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98770. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98771. */
  98772. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98773. /**
  98774. * Detach the current controls from the camera.
  98775. * The camera will stop reacting to inputs.
  98776. * @param element Defines the element to stop listening the inputs from
  98777. */
  98778. detachControl(element: HTMLElement): void;
  98779. /** @hidden */
  98780. _checkInputs(): void;
  98781. protected _checkLimits(): void;
  98782. /**
  98783. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98784. */
  98785. rebuildAnglesAndRadius(): void;
  98786. /**
  98787. * Use a position to define the current camera related information like aplha, beta and radius
  98788. * @param position Defines the position to set the camera at
  98789. */
  98790. setPosition(position: Vector3): void;
  98791. /**
  98792. * Defines the target the camera should look at.
  98793. * This will automatically adapt alpha beta and radius to fit within the new target.
  98794. * @param target Defines the new target as a Vector or a mesh
  98795. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98796. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98797. */
  98798. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98799. /** @hidden */
  98800. _getViewMatrix(): Matrix;
  98801. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98802. /**
  98803. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98804. * @param meshes Defines the mesh to zoom on
  98805. * @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)
  98806. */
  98807. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98808. /**
  98809. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98810. * The target will be changed but the radius
  98811. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98812. * @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)
  98813. */
  98814. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98815. min: Vector3;
  98816. max: Vector3;
  98817. distance: number;
  98818. }, doNotUpdateMaxZ?: boolean): void;
  98819. /**
  98820. * @override
  98821. * Override Camera.createRigCamera
  98822. */
  98823. createRigCamera(name: string, cameraIndex: number): Camera;
  98824. /**
  98825. * @hidden
  98826. * @override
  98827. * Override Camera._updateRigCameras
  98828. */
  98829. _updateRigCameras(): void;
  98830. /**
  98831. * Destroy the camera and release the current resources hold by it.
  98832. */
  98833. dispose(): void;
  98834. /**
  98835. * Gets the current object class name.
  98836. * @return the class name
  98837. */
  98838. getClassName(): string;
  98839. }
  98840. }
  98841. declare module BABYLON {
  98842. /**
  98843. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98844. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98845. */
  98846. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98847. /**
  98848. * Gets the name of the behavior.
  98849. */
  98850. readonly name: string;
  98851. private _zoomStopsAnimation;
  98852. private _idleRotationSpeed;
  98853. private _idleRotationWaitTime;
  98854. private _idleRotationSpinupTime;
  98855. /**
  98856. * Sets the flag that indicates if user zooming should stop animation.
  98857. */
  98858. /**
  98859. * Gets the flag that indicates if user zooming should stop animation.
  98860. */
  98861. zoomStopsAnimation: boolean;
  98862. /**
  98863. * Sets the default speed at which the camera rotates around the model.
  98864. */
  98865. /**
  98866. * Gets the default speed at which the camera rotates around the model.
  98867. */
  98868. idleRotationSpeed: number;
  98869. /**
  98870. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98871. */
  98872. /**
  98873. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98874. */
  98875. idleRotationWaitTime: number;
  98876. /**
  98877. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98878. */
  98879. /**
  98880. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98881. */
  98882. idleRotationSpinupTime: number;
  98883. /**
  98884. * Gets a value indicating if the camera is currently rotating because of this behavior
  98885. */
  98886. readonly rotationInProgress: boolean;
  98887. private _onPrePointerObservableObserver;
  98888. private _onAfterCheckInputsObserver;
  98889. private _attachedCamera;
  98890. private _isPointerDown;
  98891. private _lastFrameTime;
  98892. private _lastInteractionTime;
  98893. private _cameraRotationSpeed;
  98894. /**
  98895. * Initializes the behavior.
  98896. */
  98897. init(): void;
  98898. /**
  98899. * Attaches the behavior to its arc rotate camera.
  98900. * @param camera Defines the camera to attach the behavior to
  98901. */
  98902. attach(camera: ArcRotateCamera): void;
  98903. /**
  98904. * Detaches the behavior from its current arc rotate camera.
  98905. */
  98906. detach(): void;
  98907. /**
  98908. * Returns true if user is scrolling.
  98909. * @return true if user is scrolling.
  98910. */
  98911. private _userIsZooming;
  98912. private _lastFrameRadius;
  98913. private _shouldAnimationStopForInteraction;
  98914. /**
  98915. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98916. */
  98917. private _applyUserInteraction;
  98918. private _userIsMoving;
  98919. }
  98920. }
  98921. declare module BABYLON {
  98922. /**
  98923. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98924. */
  98925. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98926. private ui;
  98927. /**
  98928. * The name of the behavior
  98929. */
  98930. name: string;
  98931. /**
  98932. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98933. */
  98934. distanceAwayFromFace: number;
  98935. /**
  98936. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98937. */
  98938. distanceAwayFromBottomOfFace: number;
  98939. private _faceVectors;
  98940. private _target;
  98941. private _scene;
  98942. private _onRenderObserver;
  98943. private _tmpMatrix;
  98944. private _tmpVector;
  98945. /**
  98946. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98947. * @param ui The transform node that should be attched to the mesh
  98948. */
  98949. constructor(ui: TransformNode);
  98950. /**
  98951. * Initializes the behavior
  98952. */
  98953. init(): void;
  98954. private _closestFace;
  98955. private _zeroVector;
  98956. private _lookAtTmpMatrix;
  98957. private _lookAtToRef;
  98958. /**
  98959. * Attaches the AttachToBoxBehavior to the passed in mesh
  98960. * @param target The mesh that the specified node will be attached to
  98961. */
  98962. attach(target: Mesh): void;
  98963. /**
  98964. * Detaches the behavior from the mesh
  98965. */
  98966. detach(): void;
  98967. }
  98968. }
  98969. declare module BABYLON {
  98970. /**
  98971. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98972. */
  98973. export class FadeInOutBehavior implements Behavior<Mesh> {
  98974. /**
  98975. * Time in milliseconds to delay before fading in (Default: 0)
  98976. */
  98977. delay: number;
  98978. /**
  98979. * Time in milliseconds for the mesh to fade in (Default: 300)
  98980. */
  98981. fadeInTime: number;
  98982. private _millisecondsPerFrame;
  98983. private _hovered;
  98984. private _hoverValue;
  98985. private _ownerNode;
  98986. /**
  98987. * Instatiates the FadeInOutBehavior
  98988. */
  98989. constructor();
  98990. /**
  98991. * The name of the behavior
  98992. */
  98993. readonly name: string;
  98994. /**
  98995. * Initializes the behavior
  98996. */
  98997. init(): void;
  98998. /**
  98999. * Attaches the fade behavior on the passed in mesh
  99000. * @param ownerNode The mesh that will be faded in/out once attached
  99001. */
  99002. attach(ownerNode: Mesh): void;
  99003. /**
  99004. * Detaches the behavior from the mesh
  99005. */
  99006. detach(): void;
  99007. /**
  99008. * Triggers the mesh to begin fading in or out
  99009. * @param value if the object should fade in or out (true to fade in)
  99010. */
  99011. fadeIn(value: boolean): void;
  99012. private _update;
  99013. private _setAllVisibility;
  99014. }
  99015. }
  99016. declare module BABYLON {
  99017. /**
  99018. * Class containing a set of static utilities functions for managing Pivots
  99019. * @hidden
  99020. */
  99021. export class PivotTools {
  99022. private static _PivotCached;
  99023. private static _OldPivotPoint;
  99024. private static _PivotTranslation;
  99025. private static _PivotTmpVector;
  99026. /** @hidden */
  99027. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  99028. /** @hidden */
  99029. static _RestorePivotPoint(mesh: AbstractMesh): void;
  99030. }
  99031. }
  99032. declare module BABYLON {
  99033. /**
  99034. * Class containing static functions to help procedurally build meshes
  99035. */
  99036. export class PlaneBuilder {
  99037. /**
  99038. * Creates a plane mesh
  99039. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  99040. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  99041. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  99042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99045. * @param name defines the name of the mesh
  99046. * @param options defines the options used to create the mesh
  99047. * @param scene defines the hosting scene
  99048. * @returns the plane mesh
  99049. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  99050. */
  99051. static CreatePlane(name: string, options: {
  99052. size?: number;
  99053. width?: number;
  99054. height?: number;
  99055. sideOrientation?: number;
  99056. frontUVs?: Vector4;
  99057. backUVs?: Vector4;
  99058. updatable?: boolean;
  99059. sourcePlane?: Plane;
  99060. }, scene?: Nullable<Scene>): Mesh;
  99061. }
  99062. }
  99063. declare module BABYLON {
  99064. /**
  99065. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  99066. */
  99067. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  99068. private static _AnyMouseID;
  99069. /**
  99070. * Abstract mesh the behavior is set on
  99071. */
  99072. attachedNode: AbstractMesh;
  99073. private _dragPlane;
  99074. private _scene;
  99075. private _pointerObserver;
  99076. private _beforeRenderObserver;
  99077. private static _planeScene;
  99078. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  99079. /**
  99080. * 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)
  99081. */
  99082. maxDragAngle: number;
  99083. /**
  99084. * @hidden
  99085. */
  99086. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  99087. /**
  99088. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99089. */
  99090. currentDraggingPointerID: number;
  99091. /**
  99092. * The last position where the pointer hit the drag plane in world space
  99093. */
  99094. lastDragPosition: Vector3;
  99095. /**
  99096. * If the behavior is currently in a dragging state
  99097. */
  99098. dragging: boolean;
  99099. /**
  99100. * 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)
  99101. */
  99102. dragDeltaRatio: number;
  99103. /**
  99104. * If the drag plane orientation should be updated during the dragging (Default: true)
  99105. */
  99106. updateDragPlane: boolean;
  99107. private _debugMode;
  99108. private _moving;
  99109. /**
  99110. * Fires each time the attached mesh is dragged with the pointer
  99111. * * delta between last drag position and current drag position in world space
  99112. * * dragDistance along the drag axis
  99113. * * dragPlaneNormal normal of the current drag plane used during the drag
  99114. * * dragPlanePoint in world space where the drag intersects the drag plane
  99115. */
  99116. onDragObservable: Observable<{
  99117. delta: Vector3;
  99118. dragPlanePoint: Vector3;
  99119. dragPlaneNormal: Vector3;
  99120. dragDistance: number;
  99121. pointerId: number;
  99122. }>;
  99123. /**
  99124. * Fires each time a drag begins (eg. mouse down on mesh)
  99125. */
  99126. onDragStartObservable: Observable<{
  99127. dragPlanePoint: Vector3;
  99128. pointerId: number;
  99129. }>;
  99130. /**
  99131. * Fires each time a drag ends (eg. mouse release after drag)
  99132. */
  99133. onDragEndObservable: Observable<{
  99134. dragPlanePoint: Vector3;
  99135. pointerId: number;
  99136. }>;
  99137. /**
  99138. * If the attached mesh should be moved when dragged
  99139. */
  99140. moveAttached: boolean;
  99141. /**
  99142. * If the drag behavior will react to drag events (Default: true)
  99143. */
  99144. enabled: boolean;
  99145. /**
  99146. * If camera controls should be detached during the drag
  99147. */
  99148. detachCameraControls: boolean;
  99149. /**
  99150. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  99151. */
  99152. useObjectOrienationForDragging: boolean;
  99153. private _options;
  99154. /**
  99155. * Creates a pointer drag behavior that can be attached to a mesh
  99156. * @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)
  99157. */
  99158. constructor(options?: {
  99159. dragAxis?: Vector3;
  99160. dragPlaneNormal?: Vector3;
  99161. });
  99162. /**
  99163. * Predicate to determine if it is valid to move the object to a new position when it is moved
  99164. */
  99165. validateDrag: (targetPosition: Vector3) => boolean;
  99166. /**
  99167. * The name of the behavior
  99168. */
  99169. readonly name: string;
  99170. /**
  99171. * Initializes the behavior
  99172. */
  99173. init(): void;
  99174. private _tmpVector;
  99175. private _alternatePickedPoint;
  99176. private _worldDragAxis;
  99177. private _targetPosition;
  99178. private _attachedElement;
  99179. /**
  99180. * Attaches the drag behavior the passed in mesh
  99181. * @param ownerNode The mesh that will be dragged around once attached
  99182. */
  99183. attach(ownerNode: AbstractMesh): void;
  99184. /**
  99185. * Force relase the drag action by code.
  99186. */
  99187. releaseDrag(): void;
  99188. private _startDragRay;
  99189. private _lastPointerRay;
  99190. /**
  99191. * Simulates the start of a pointer drag event on the behavior
  99192. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  99193. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  99194. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  99195. */
  99196. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  99197. private _startDrag;
  99198. private _dragDelta;
  99199. private _moveDrag;
  99200. private _pickWithRayOnDragPlane;
  99201. private _pointA;
  99202. private _pointB;
  99203. private _pointC;
  99204. private _lineA;
  99205. private _lineB;
  99206. private _localAxis;
  99207. private _lookAt;
  99208. private _updateDragPlanePosition;
  99209. /**
  99210. * Detaches the behavior from the mesh
  99211. */
  99212. detach(): void;
  99213. }
  99214. }
  99215. declare module BABYLON {
  99216. /**
  99217. * A behavior that when attached to a mesh will allow the mesh to be scaled
  99218. */
  99219. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  99220. private _dragBehaviorA;
  99221. private _dragBehaviorB;
  99222. private _startDistance;
  99223. private _initialScale;
  99224. private _targetScale;
  99225. private _ownerNode;
  99226. private _sceneRenderObserver;
  99227. /**
  99228. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  99229. */
  99230. constructor();
  99231. /**
  99232. * The name of the behavior
  99233. */
  99234. readonly name: string;
  99235. /**
  99236. * Initializes the behavior
  99237. */
  99238. init(): void;
  99239. private _getCurrentDistance;
  99240. /**
  99241. * Attaches the scale behavior the passed in mesh
  99242. * @param ownerNode The mesh that will be scaled around once attached
  99243. */
  99244. attach(ownerNode: Mesh): void;
  99245. /**
  99246. * Detaches the behavior from the mesh
  99247. */
  99248. detach(): void;
  99249. }
  99250. }
  99251. declare module BABYLON {
  99252. /**
  99253. * 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
  99254. */
  99255. export class SixDofDragBehavior implements Behavior<Mesh> {
  99256. private static _virtualScene;
  99257. private _ownerNode;
  99258. private _sceneRenderObserver;
  99259. private _scene;
  99260. private _targetPosition;
  99261. private _virtualOriginMesh;
  99262. private _virtualDragMesh;
  99263. private _pointerObserver;
  99264. private _moving;
  99265. private _startingOrientation;
  99266. /**
  99267. * 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)
  99268. */
  99269. private zDragFactor;
  99270. /**
  99271. * If the object should rotate to face the drag origin
  99272. */
  99273. rotateDraggedObject: boolean;
  99274. /**
  99275. * If the behavior is currently in a dragging state
  99276. */
  99277. dragging: boolean;
  99278. /**
  99279. * 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)
  99280. */
  99281. dragDeltaRatio: number;
  99282. /**
  99283. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99284. */
  99285. currentDraggingPointerID: number;
  99286. /**
  99287. * If camera controls should be detached during the drag
  99288. */
  99289. detachCameraControls: boolean;
  99290. /**
  99291. * Fires each time a drag starts
  99292. */
  99293. onDragStartObservable: Observable<{}>;
  99294. /**
  99295. * Fires each time a drag ends (eg. mouse release after drag)
  99296. */
  99297. onDragEndObservable: Observable<{}>;
  99298. /**
  99299. * 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
  99300. */
  99301. constructor();
  99302. /**
  99303. * The name of the behavior
  99304. */
  99305. readonly name: string;
  99306. /**
  99307. * Initializes the behavior
  99308. */
  99309. init(): void;
  99310. /**
  99311. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99312. */
  99313. private readonly _pointerCamera;
  99314. /**
  99315. * Attaches the scale behavior the passed in mesh
  99316. * @param ownerNode The mesh that will be scaled around once attached
  99317. */
  99318. attach(ownerNode: Mesh): void;
  99319. /**
  99320. * Detaches the behavior from the mesh
  99321. */
  99322. detach(): void;
  99323. }
  99324. }
  99325. declare module BABYLON {
  99326. /**
  99327. * Class used to apply inverse kinematics to bones
  99328. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99329. */
  99330. export class BoneIKController {
  99331. private static _tmpVecs;
  99332. private static _tmpQuat;
  99333. private static _tmpMats;
  99334. /**
  99335. * Gets or sets the target mesh
  99336. */
  99337. targetMesh: AbstractMesh;
  99338. /** Gets or sets the mesh used as pole */
  99339. poleTargetMesh: AbstractMesh;
  99340. /**
  99341. * Gets or sets the bone used as pole
  99342. */
  99343. poleTargetBone: Nullable<Bone>;
  99344. /**
  99345. * Gets or sets the target position
  99346. */
  99347. targetPosition: Vector3;
  99348. /**
  99349. * Gets or sets the pole target position
  99350. */
  99351. poleTargetPosition: Vector3;
  99352. /**
  99353. * Gets or sets the pole target local offset
  99354. */
  99355. poleTargetLocalOffset: Vector3;
  99356. /**
  99357. * Gets or sets the pole angle
  99358. */
  99359. poleAngle: number;
  99360. /**
  99361. * Gets or sets the mesh associated with the controller
  99362. */
  99363. mesh: AbstractMesh;
  99364. /**
  99365. * 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)
  99366. */
  99367. slerpAmount: number;
  99368. private _bone1Quat;
  99369. private _bone1Mat;
  99370. private _bone2Ang;
  99371. private _bone1;
  99372. private _bone2;
  99373. private _bone1Length;
  99374. private _bone2Length;
  99375. private _maxAngle;
  99376. private _maxReach;
  99377. private _rightHandedSystem;
  99378. private _bendAxis;
  99379. private _slerping;
  99380. private _adjustRoll;
  99381. /**
  99382. * Gets or sets maximum allowed angle
  99383. */
  99384. maxAngle: number;
  99385. /**
  99386. * Creates a new BoneIKController
  99387. * @param mesh defines the mesh to control
  99388. * @param bone defines the bone to control
  99389. * @param options defines options to set up the controller
  99390. */
  99391. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99392. targetMesh?: AbstractMesh;
  99393. poleTargetMesh?: AbstractMesh;
  99394. poleTargetBone?: Bone;
  99395. poleTargetLocalOffset?: Vector3;
  99396. poleAngle?: number;
  99397. bendAxis?: Vector3;
  99398. maxAngle?: number;
  99399. slerpAmount?: number;
  99400. });
  99401. private _setMaxAngle;
  99402. /**
  99403. * Force the controller to update the bones
  99404. */
  99405. update(): void;
  99406. }
  99407. }
  99408. declare module BABYLON {
  99409. /**
  99410. * Class used to make a bone look toward a point in space
  99411. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99412. */
  99413. export class BoneLookController {
  99414. private static _tmpVecs;
  99415. private static _tmpQuat;
  99416. private static _tmpMats;
  99417. /**
  99418. * The target Vector3 that the bone will look at
  99419. */
  99420. target: Vector3;
  99421. /**
  99422. * The mesh that the bone is attached to
  99423. */
  99424. mesh: AbstractMesh;
  99425. /**
  99426. * The bone that will be looking to the target
  99427. */
  99428. bone: Bone;
  99429. /**
  99430. * The up axis of the coordinate system that is used when the bone is rotated
  99431. */
  99432. upAxis: Vector3;
  99433. /**
  99434. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99435. */
  99436. upAxisSpace: Space;
  99437. /**
  99438. * Used to make an adjustment to the yaw of the bone
  99439. */
  99440. adjustYaw: number;
  99441. /**
  99442. * Used to make an adjustment to the pitch of the bone
  99443. */
  99444. adjustPitch: number;
  99445. /**
  99446. * Used to make an adjustment to the roll of the bone
  99447. */
  99448. adjustRoll: number;
  99449. /**
  99450. * 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)
  99451. */
  99452. slerpAmount: number;
  99453. private _minYaw;
  99454. private _maxYaw;
  99455. private _minPitch;
  99456. private _maxPitch;
  99457. private _minYawSin;
  99458. private _minYawCos;
  99459. private _maxYawSin;
  99460. private _maxYawCos;
  99461. private _midYawConstraint;
  99462. private _minPitchTan;
  99463. private _maxPitchTan;
  99464. private _boneQuat;
  99465. private _slerping;
  99466. private _transformYawPitch;
  99467. private _transformYawPitchInv;
  99468. private _firstFrameSkipped;
  99469. private _yawRange;
  99470. private _fowardAxis;
  99471. /**
  99472. * Gets or sets the minimum yaw angle that the bone can look to
  99473. */
  99474. minYaw: number;
  99475. /**
  99476. * Gets or sets the maximum yaw angle that the bone can look to
  99477. */
  99478. maxYaw: number;
  99479. /**
  99480. * Gets or sets the minimum pitch angle that the bone can look to
  99481. */
  99482. minPitch: number;
  99483. /**
  99484. * Gets or sets the maximum pitch angle that the bone can look to
  99485. */
  99486. maxPitch: number;
  99487. /**
  99488. * Create a BoneLookController
  99489. * @param mesh the mesh that the bone belongs to
  99490. * @param bone the bone that will be looking to the target
  99491. * @param target the target Vector3 to look at
  99492. * @param options optional settings:
  99493. * * maxYaw: the maximum angle the bone will yaw to
  99494. * * minYaw: the minimum angle the bone will yaw to
  99495. * * maxPitch: the maximum angle the bone will pitch to
  99496. * * minPitch: the minimum angle the bone will yaw to
  99497. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99498. * * upAxis: the up axis of the coordinate system
  99499. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99500. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99501. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99502. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99503. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99504. * * adjustRoll: used to make an adjustment to the roll of the bone
  99505. **/
  99506. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99507. maxYaw?: number;
  99508. minYaw?: number;
  99509. maxPitch?: number;
  99510. minPitch?: number;
  99511. slerpAmount?: number;
  99512. upAxis?: Vector3;
  99513. upAxisSpace?: Space;
  99514. yawAxis?: Vector3;
  99515. pitchAxis?: Vector3;
  99516. adjustYaw?: number;
  99517. adjustPitch?: number;
  99518. adjustRoll?: number;
  99519. });
  99520. /**
  99521. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99522. */
  99523. update(): void;
  99524. private _getAngleDiff;
  99525. private _getAngleBetween;
  99526. private _isAngleBetween;
  99527. }
  99528. }
  99529. declare module BABYLON {
  99530. /**
  99531. * Manage the gamepad inputs to control an arc rotate camera.
  99532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99533. */
  99534. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99535. /**
  99536. * Defines the camera the input is attached to.
  99537. */
  99538. camera: ArcRotateCamera;
  99539. /**
  99540. * Defines the gamepad the input is gathering event from.
  99541. */
  99542. gamepad: Nullable<Gamepad>;
  99543. /**
  99544. * Defines the gamepad rotation sensiblity.
  99545. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99546. */
  99547. gamepadRotationSensibility: number;
  99548. /**
  99549. * Defines the gamepad move sensiblity.
  99550. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99551. */
  99552. gamepadMoveSensibility: number;
  99553. private _onGamepadConnectedObserver;
  99554. private _onGamepadDisconnectedObserver;
  99555. /**
  99556. * Attach the input controls to a specific dom element to get the input from.
  99557. * @param element Defines the element the controls should be listened from
  99558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99559. */
  99560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99561. /**
  99562. * Detach the current controls from the specified dom element.
  99563. * @param element Defines the element to stop listening the inputs from
  99564. */
  99565. detachControl(element: Nullable<HTMLElement>): void;
  99566. /**
  99567. * Update the current camera state depending on the inputs that have been used this frame.
  99568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99569. */
  99570. checkInputs(): void;
  99571. /**
  99572. * Gets the class name of the current intput.
  99573. * @returns the class name
  99574. */
  99575. getClassName(): string;
  99576. /**
  99577. * Get the friendly name associated with the input class.
  99578. * @returns the input friendly name
  99579. */
  99580. getSimpleName(): string;
  99581. }
  99582. }
  99583. declare module BABYLON {
  99584. interface ArcRotateCameraInputsManager {
  99585. /**
  99586. * Add orientation input support to the input manager.
  99587. * @returns the current input manager
  99588. */
  99589. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99590. }
  99591. /**
  99592. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99594. */
  99595. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99596. /**
  99597. * Defines the camera the input is attached to.
  99598. */
  99599. camera: ArcRotateCamera;
  99600. /**
  99601. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99602. */
  99603. alphaCorrection: number;
  99604. /**
  99605. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99606. */
  99607. gammaCorrection: number;
  99608. private _alpha;
  99609. private _gamma;
  99610. private _dirty;
  99611. private _deviceOrientationHandler;
  99612. /**
  99613. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99614. */
  99615. constructor();
  99616. /**
  99617. * Attach the input controls to a specific dom element to get the input from.
  99618. * @param element Defines the element the controls should be listened from
  99619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99620. */
  99621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99622. /** @hidden */
  99623. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99624. /**
  99625. * Update the current camera state depending on the inputs that have been used this frame.
  99626. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99627. */
  99628. checkInputs(): void;
  99629. /**
  99630. * Detach the current controls from the specified dom element.
  99631. * @param element Defines the element to stop listening the inputs from
  99632. */
  99633. detachControl(element: Nullable<HTMLElement>): void;
  99634. /**
  99635. * Gets the class name of the current intput.
  99636. * @returns the class name
  99637. */
  99638. getClassName(): string;
  99639. /**
  99640. * Get the friendly name associated with the input class.
  99641. * @returns the input friendly name
  99642. */
  99643. getSimpleName(): string;
  99644. }
  99645. }
  99646. declare module BABYLON {
  99647. /**
  99648. * Listen to mouse events to control the camera.
  99649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99650. */
  99651. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99652. /**
  99653. * Defines the camera the input is attached to.
  99654. */
  99655. camera: FlyCamera;
  99656. /**
  99657. * Defines if touch is enabled. (Default is true.)
  99658. */
  99659. touchEnabled: boolean;
  99660. /**
  99661. * Defines the buttons associated with the input to handle camera rotation.
  99662. */
  99663. buttons: number[];
  99664. /**
  99665. * Assign buttons for Yaw control.
  99666. */
  99667. buttonsYaw: number[];
  99668. /**
  99669. * Assign buttons for Pitch control.
  99670. */
  99671. buttonsPitch: number[];
  99672. /**
  99673. * Assign buttons for Roll control.
  99674. */
  99675. buttonsRoll: number[];
  99676. /**
  99677. * Detect if any button is being pressed while mouse is moved.
  99678. * -1 = Mouse locked.
  99679. * 0 = Left button.
  99680. * 1 = Middle Button.
  99681. * 2 = Right Button.
  99682. */
  99683. activeButton: number;
  99684. /**
  99685. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99686. * Higher values reduce its sensitivity.
  99687. */
  99688. angularSensibility: number;
  99689. private _mousemoveCallback;
  99690. private _observer;
  99691. private _rollObserver;
  99692. private previousPosition;
  99693. private noPreventDefault;
  99694. private element;
  99695. /**
  99696. * Listen to mouse events to control the camera.
  99697. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99699. */
  99700. constructor(touchEnabled?: boolean);
  99701. /**
  99702. * Attach the mouse control to the HTML DOM element.
  99703. * @param element Defines the element that listens to the input events.
  99704. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99705. */
  99706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99707. /**
  99708. * Detach the current controls from the specified dom element.
  99709. * @param element Defines the element to stop listening the inputs from
  99710. */
  99711. detachControl(element: Nullable<HTMLElement>): void;
  99712. /**
  99713. * Gets the class name of the current input.
  99714. * @returns the class name.
  99715. */
  99716. getClassName(): string;
  99717. /**
  99718. * Get the friendly name associated with the input class.
  99719. * @returns the input's friendly name.
  99720. */
  99721. getSimpleName(): string;
  99722. private _pointerInput;
  99723. private _onMouseMove;
  99724. /**
  99725. * Rotate camera by mouse offset.
  99726. */
  99727. private rotateCamera;
  99728. }
  99729. }
  99730. declare module BABYLON {
  99731. /**
  99732. * Default Inputs manager for the FlyCamera.
  99733. * It groups all the default supported inputs for ease of use.
  99734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99735. */
  99736. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99737. /**
  99738. * Instantiates a new FlyCameraInputsManager.
  99739. * @param camera Defines the camera the inputs belong to.
  99740. */
  99741. constructor(camera: FlyCamera);
  99742. /**
  99743. * Add keyboard input support to the input manager.
  99744. * @returns the new FlyCameraKeyboardMoveInput().
  99745. */
  99746. addKeyboard(): FlyCameraInputsManager;
  99747. /**
  99748. * Add mouse input support to the input manager.
  99749. * @param touchEnabled Enable touch screen support.
  99750. * @returns the new FlyCameraMouseInput().
  99751. */
  99752. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99753. }
  99754. }
  99755. declare module BABYLON {
  99756. /**
  99757. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99758. * such as in a 3D Space Shooter or a Flight Simulator.
  99759. */
  99760. export class FlyCamera extends TargetCamera {
  99761. /**
  99762. * Define the collision ellipsoid of the camera.
  99763. * This is helpful for simulating a camera body, like a player's body.
  99764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99765. */
  99766. ellipsoid: Vector3;
  99767. /**
  99768. * Define an offset for the position of the ellipsoid around the camera.
  99769. * This can be helpful if the camera is attached away from the player's body center,
  99770. * such as at its head.
  99771. */
  99772. ellipsoidOffset: Vector3;
  99773. /**
  99774. * Enable or disable collisions of the camera with the rest of the scene objects.
  99775. */
  99776. checkCollisions: boolean;
  99777. /**
  99778. * Enable or disable gravity on the camera.
  99779. */
  99780. applyGravity: boolean;
  99781. /**
  99782. * Define the current direction the camera is moving to.
  99783. */
  99784. cameraDirection: Vector3;
  99785. /**
  99786. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99787. * This overrides and empties cameraRotation.
  99788. */
  99789. rotationQuaternion: Quaternion;
  99790. /**
  99791. * Track Roll to maintain the wanted Rolling when looking around.
  99792. */
  99793. _trackRoll: number;
  99794. /**
  99795. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99796. */
  99797. rollCorrect: number;
  99798. /**
  99799. * Mimic a banked turn, Rolling the camera when Yawing.
  99800. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99801. */
  99802. bankedTurn: boolean;
  99803. /**
  99804. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99805. */
  99806. bankedTurnLimit: number;
  99807. /**
  99808. * Value of 0 disables the banked Roll.
  99809. * Value of 1 is equal to the Yaw angle in radians.
  99810. */
  99811. bankedTurnMultiplier: number;
  99812. /**
  99813. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99814. */
  99815. inputs: FlyCameraInputsManager;
  99816. /**
  99817. * Gets the input sensibility for mouse input.
  99818. * Higher values reduce sensitivity.
  99819. */
  99820. /**
  99821. * Sets the input sensibility for a mouse input.
  99822. * Higher values reduce sensitivity.
  99823. */
  99824. angularSensibility: number;
  99825. /**
  99826. * Get the keys for camera movement forward.
  99827. */
  99828. /**
  99829. * Set the keys for camera movement forward.
  99830. */
  99831. keysForward: number[];
  99832. /**
  99833. * Get the keys for camera movement backward.
  99834. */
  99835. keysBackward: number[];
  99836. /**
  99837. * Get the keys for camera movement up.
  99838. */
  99839. /**
  99840. * Set the keys for camera movement up.
  99841. */
  99842. keysUp: number[];
  99843. /**
  99844. * Get the keys for camera movement down.
  99845. */
  99846. /**
  99847. * Set the keys for camera movement down.
  99848. */
  99849. keysDown: number[];
  99850. /**
  99851. * Get the keys for camera movement left.
  99852. */
  99853. /**
  99854. * Set the keys for camera movement left.
  99855. */
  99856. keysLeft: number[];
  99857. /**
  99858. * Set the keys for camera movement right.
  99859. */
  99860. /**
  99861. * Set the keys for camera movement right.
  99862. */
  99863. keysRight: number[];
  99864. /**
  99865. * Event raised when the camera collides with a mesh in the scene.
  99866. */
  99867. onCollide: (collidedMesh: AbstractMesh) => void;
  99868. private _collider;
  99869. private _needMoveForGravity;
  99870. private _oldPosition;
  99871. private _diffPosition;
  99872. private _newPosition;
  99873. /** @hidden */
  99874. _localDirection: Vector3;
  99875. /** @hidden */
  99876. _transformedDirection: Vector3;
  99877. /**
  99878. * Instantiates a FlyCamera.
  99879. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99880. * such as in a 3D Space Shooter or a Flight Simulator.
  99881. * @param name Define the name of the camera in the scene.
  99882. * @param position Define the starting position of the camera in the scene.
  99883. * @param scene Define the scene the camera belongs to.
  99884. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99885. */
  99886. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99887. /**
  99888. * Attach a control to the HTML DOM element.
  99889. * @param element Defines the element that listens to the input events.
  99890. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99891. */
  99892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99893. /**
  99894. * Detach a control from the HTML DOM element.
  99895. * The camera will stop reacting to that input.
  99896. * @param element Defines the element that listens to the input events.
  99897. */
  99898. detachControl(element: HTMLElement): void;
  99899. private _collisionMask;
  99900. /**
  99901. * Get the mask that the camera ignores in collision events.
  99902. */
  99903. /**
  99904. * Set the mask that the camera ignores in collision events.
  99905. */
  99906. collisionMask: number;
  99907. /** @hidden */
  99908. _collideWithWorld(displacement: Vector3): void;
  99909. /** @hidden */
  99910. private _onCollisionPositionChange;
  99911. /** @hidden */
  99912. _checkInputs(): void;
  99913. /** @hidden */
  99914. _decideIfNeedsToMove(): boolean;
  99915. /** @hidden */
  99916. _updatePosition(): void;
  99917. /**
  99918. * Restore the Roll to its target value at the rate specified.
  99919. * @param rate - Higher means slower restoring.
  99920. * @hidden
  99921. */
  99922. restoreRoll(rate: number): void;
  99923. /**
  99924. * Destroy the camera and release the current resources held by it.
  99925. */
  99926. dispose(): void;
  99927. /**
  99928. * Get the current object class name.
  99929. * @returns the class name.
  99930. */
  99931. getClassName(): string;
  99932. }
  99933. }
  99934. declare module BABYLON {
  99935. /**
  99936. * Listen to keyboard events to control the camera.
  99937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99938. */
  99939. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99940. /**
  99941. * Defines the camera the input is attached to.
  99942. */
  99943. camera: FlyCamera;
  99944. /**
  99945. * The list of keyboard keys used to control the forward move of the camera.
  99946. */
  99947. keysForward: number[];
  99948. /**
  99949. * The list of keyboard keys used to control the backward move of the camera.
  99950. */
  99951. keysBackward: number[];
  99952. /**
  99953. * The list of keyboard keys used to control the forward move of the camera.
  99954. */
  99955. keysUp: number[];
  99956. /**
  99957. * The list of keyboard keys used to control the backward move of the camera.
  99958. */
  99959. keysDown: number[];
  99960. /**
  99961. * The list of keyboard keys used to control the right strafe move of the camera.
  99962. */
  99963. keysRight: number[];
  99964. /**
  99965. * The list of keyboard keys used to control the left strafe move of the camera.
  99966. */
  99967. keysLeft: number[];
  99968. private _keys;
  99969. private _onCanvasBlurObserver;
  99970. private _onKeyboardObserver;
  99971. private _engine;
  99972. private _scene;
  99973. /**
  99974. * Attach the input controls to a specific dom element to get the input from.
  99975. * @param element Defines the element the controls should be listened from
  99976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99977. */
  99978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99979. /**
  99980. * Detach the current controls from the specified dom element.
  99981. * @param element Defines the element to stop listening the inputs from
  99982. */
  99983. detachControl(element: Nullable<HTMLElement>): void;
  99984. /**
  99985. * Gets the class name of the current intput.
  99986. * @returns the class name
  99987. */
  99988. getClassName(): string;
  99989. /** @hidden */
  99990. _onLostFocus(e: FocusEvent): void;
  99991. /**
  99992. * Get the friendly name associated with the input class.
  99993. * @returns the input friendly name
  99994. */
  99995. getSimpleName(): string;
  99996. /**
  99997. * Update the current camera state depending on the inputs that have been used this frame.
  99998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99999. */
  100000. checkInputs(): void;
  100001. }
  100002. }
  100003. declare module BABYLON {
  100004. /**
  100005. * Manage the mouse wheel inputs to control a follow camera.
  100006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100007. */
  100008. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  100009. /**
  100010. * Defines the camera the input is attached to.
  100011. */
  100012. camera: FollowCamera;
  100013. /**
  100014. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  100015. */
  100016. axisControlRadius: boolean;
  100017. /**
  100018. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  100019. */
  100020. axisControlHeight: boolean;
  100021. /**
  100022. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  100023. */
  100024. axisControlRotation: boolean;
  100025. /**
  100026. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  100027. * relation to mouseWheel events.
  100028. */
  100029. wheelPrecision: number;
  100030. /**
  100031. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100032. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100033. */
  100034. wheelDeltaPercentage: number;
  100035. private _wheel;
  100036. private _observer;
  100037. /**
  100038. * Attach the input controls to a specific dom element to get the input from.
  100039. * @param element Defines the element the controls should be listened from
  100040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100041. */
  100042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100043. /**
  100044. * Detach the current controls from the specified dom element.
  100045. * @param element Defines the element to stop listening the inputs from
  100046. */
  100047. detachControl(element: Nullable<HTMLElement>): void;
  100048. /**
  100049. * Gets the class name of the current intput.
  100050. * @returns the class name
  100051. */
  100052. getClassName(): string;
  100053. /**
  100054. * Get the friendly name associated with the input class.
  100055. * @returns the input friendly name
  100056. */
  100057. getSimpleName(): string;
  100058. }
  100059. }
  100060. declare module BABYLON {
  100061. /**
  100062. * Manage the pointers inputs to control an follow camera.
  100063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100064. */
  100065. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  100066. /**
  100067. * Defines the camera the input is attached to.
  100068. */
  100069. camera: FollowCamera;
  100070. /**
  100071. * Gets the class name of the current input.
  100072. * @returns the class name
  100073. */
  100074. getClassName(): string;
  100075. /**
  100076. * Defines the pointer angular sensibility along the X axis or how fast is
  100077. * the camera rotating.
  100078. * A negative number will reverse the axis direction.
  100079. */
  100080. angularSensibilityX: number;
  100081. /**
  100082. * Defines the pointer angular sensibility along the Y axis or how fast is
  100083. * the camera rotating.
  100084. * A negative number will reverse the axis direction.
  100085. */
  100086. angularSensibilityY: number;
  100087. /**
  100088. * Defines the pointer pinch precision or how fast is the camera zooming.
  100089. * A negative number will reverse the axis direction.
  100090. */
  100091. pinchPrecision: number;
  100092. /**
  100093. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100094. * from 0.
  100095. * It defines the percentage of current camera.radius to use as delta when
  100096. * pinch zoom is used.
  100097. */
  100098. pinchDeltaPercentage: number;
  100099. /**
  100100. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  100101. */
  100102. axisXControlRadius: boolean;
  100103. /**
  100104. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  100105. */
  100106. axisXControlHeight: boolean;
  100107. /**
  100108. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  100109. */
  100110. axisXControlRotation: boolean;
  100111. /**
  100112. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  100113. */
  100114. axisYControlRadius: boolean;
  100115. /**
  100116. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  100117. */
  100118. axisYControlHeight: boolean;
  100119. /**
  100120. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  100121. */
  100122. axisYControlRotation: boolean;
  100123. /**
  100124. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  100125. */
  100126. axisPinchControlRadius: boolean;
  100127. /**
  100128. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  100129. */
  100130. axisPinchControlHeight: boolean;
  100131. /**
  100132. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  100133. */
  100134. axisPinchControlRotation: boolean;
  100135. /**
  100136. * Log error messages if basic misconfiguration has occurred.
  100137. */
  100138. warningEnable: boolean;
  100139. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100140. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100141. private _warningCounter;
  100142. private _warning;
  100143. }
  100144. }
  100145. declare module BABYLON {
  100146. /**
  100147. * Default Inputs manager for the FollowCamera.
  100148. * It groups all the default supported inputs for ease of use.
  100149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100150. */
  100151. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  100152. /**
  100153. * Instantiates a new FollowCameraInputsManager.
  100154. * @param camera Defines the camera the inputs belong to
  100155. */
  100156. constructor(camera: FollowCamera);
  100157. /**
  100158. * Add keyboard input support to the input manager.
  100159. * @returns the current input manager
  100160. */
  100161. addKeyboard(): FollowCameraInputsManager;
  100162. /**
  100163. * Add mouse wheel input support to the input manager.
  100164. * @returns the current input manager
  100165. */
  100166. addMouseWheel(): FollowCameraInputsManager;
  100167. /**
  100168. * Add pointers input support to the input manager.
  100169. * @returns the current input manager
  100170. */
  100171. addPointers(): FollowCameraInputsManager;
  100172. /**
  100173. * Add orientation input support to the input manager.
  100174. * @returns the current input manager
  100175. */
  100176. addVRDeviceOrientation(): FollowCameraInputsManager;
  100177. }
  100178. }
  100179. declare module BABYLON {
  100180. /**
  100181. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  100182. * an arc rotate version arcFollowCamera are available.
  100183. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100184. */
  100185. export class FollowCamera extends TargetCamera {
  100186. /**
  100187. * Distance the follow camera should follow an object at
  100188. */
  100189. radius: number;
  100190. /**
  100191. * Minimum allowed distance of the camera to the axis of rotation
  100192. * (The camera can not get closer).
  100193. * This can help limiting how the Camera is able to move in the scene.
  100194. */
  100195. lowerRadiusLimit: Nullable<number>;
  100196. /**
  100197. * Maximum allowed distance of the camera to the axis of rotation
  100198. * (The camera can not get further).
  100199. * This can help limiting how the Camera is able to move in the scene.
  100200. */
  100201. upperRadiusLimit: Nullable<number>;
  100202. /**
  100203. * Define a rotation offset between the camera and the object it follows
  100204. */
  100205. rotationOffset: number;
  100206. /**
  100207. * Minimum allowed angle to camera position relative to target object.
  100208. * This can help limiting how the Camera is able to move in the scene.
  100209. */
  100210. lowerRotationOffsetLimit: Nullable<number>;
  100211. /**
  100212. * Maximum allowed angle to camera position relative to target object.
  100213. * This can help limiting how the Camera is able to move in the scene.
  100214. */
  100215. upperRotationOffsetLimit: Nullable<number>;
  100216. /**
  100217. * Define a height offset between the camera and the object it follows.
  100218. * It can help following an object from the top (like a car chaing a plane)
  100219. */
  100220. heightOffset: number;
  100221. /**
  100222. * Minimum allowed height of camera position relative to target object.
  100223. * This can help limiting how the Camera is able to move in the scene.
  100224. */
  100225. lowerHeightOffsetLimit: Nullable<number>;
  100226. /**
  100227. * Maximum allowed height of camera position relative to target object.
  100228. * This can help limiting how the Camera is able to move in the scene.
  100229. */
  100230. upperHeightOffsetLimit: Nullable<number>;
  100231. /**
  100232. * Define how fast the camera can accelerate to follow it s target.
  100233. */
  100234. cameraAcceleration: number;
  100235. /**
  100236. * Define the speed limit of the camera following an object.
  100237. */
  100238. maxCameraSpeed: number;
  100239. /**
  100240. * Define the target of the camera.
  100241. */
  100242. lockedTarget: Nullable<AbstractMesh>;
  100243. /**
  100244. * Defines the input associated with the camera.
  100245. */
  100246. inputs: FollowCameraInputsManager;
  100247. /**
  100248. * Instantiates the follow camera.
  100249. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100250. * @param name Define the name of the camera in the scene
  100251. * @param position Define the position of the camera
  100252. * @param scene Define the scene the camera belong to
  100253. * @param lockedTarget Define the target of the camera
  100254. */
  100255. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  100256. private _follow;
  100257. /**
  100258. * Attached controls to the current camera.
  100259. * @param element Defines the element the controls should be listened from
  100260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100261. */
  100262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100263. /**
  100264. * Detach the current controls from the camera.
  100265. * The camera will stop reacting to inputs.
  100266. * @param element Defines the element to stop listening the inputs from
  100267. */
  100268. detachControl(element: HTMLElement): void;
  100269. /** @hidden */
  100270. _checkInputs(): void;
  100271. private _checkLimits;
  100272. /**
  100273. * Gets the camera class name.
  100274. * @returns the class name
  100275. */
  100276. getClassName(): string;
  100277. }
  100278. /**
  100279. * Arc Rotate version of the follow camera.
  100280. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  100281. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100282. */
  100283. export class ArcFollowCamera extends TargetCamera {
  100284. /** The longitudinal angle of the camera */
  100285. alpha: number;
  100286. /** The latitudinal angle of the camera */
  100287. beta: number;
  100288. /** The radius of the camera from its target */
  100289. radius: number;
  100290. /** Define the camera target (the messh it should follow) */
  100291. target: Nullable<AbstractMesh>;
  100292. private _cartesianCoordinates;
  100293. /**
  100294. * Instantiates a new ArcFollowCamera
  100295. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100296. * @param name Define the name of the camera
  100297. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100298. * @param beta Define the rotation angle of the camera around the elevation axis
  100299. * @param radius Define the radius of the camera from its target point
  100300. * @param target Define the target of the camera
  100301. * @param scene Define the scene the camera belongs to
  100302. */
  100303. constructor(name: string,
  100304. /** The longitudinal angle of the camera */
  100305. alpha: number,
  100306. /** The latitudinal angle of the camera */
  100307. beta: number,
  100308. /** The radius of the camera from its target */
  100309. radius: number,
  100310. /** Define the camera target (the messh it should follow) */
  100311. target: Nullable<AbstractMesh>, scene: Scene);
  100312. private _follow;
  100313. /** @hidden */
  100314. _checkInputs(): void;
  100315. /**
  100316. * Returns the class name of the object.
  100317. * It is mostly used internally for serialization purposes.
  100318. */
  100319. getClassName(): string;
  100320. }
  100321. }
  100322. declare module BABYLON {
  100323. /**
  100324. * Manage the keyboard inputs to control the movement of a follow camera.
  100325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100326. */
  100327. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100328. /**
  100329. * Defines the camera the input is attached to.
  100330. */
  100331. camera: FollowCamera;
  100332. /**
  100333. * Defines the list of key codes associated with the up action (increase heightOffset)
  100334. */
  100335. keysHeightOffsetIncr: number[];
  100336. /**
  100337. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100338. */
  100339. keysHeightOffsetDecr: number[];
  100340. /**
  100341. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100342. */
  100343. keysHeightOffsetModifierAlt: boolean;
  100344. /**
  100345. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100346. */
  100347. keysHeightOffsetModifierCtrl: boolean;
  100348. /**
  100349. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100350. */
  100351. keysHeightOffsetModifierShift: boolean;
  100352. /**
  100353. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100354. */
  100355. keysRotationOffsetIncr: number[];
  100356. /**
  100357. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100358. */
  100359. keysRotationOffsetDecr: number[];
  100360. /**
  100361. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100362. */
  100363. keysRotationOffsetModifierAlt: boolean;
  100364. /**
  100365. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100366. */
  100367. keysRotationOffsetModifierCtrl: boolean;
  100368. /**
  100369. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100370. */
  100371. keysRotationOffsetModifierShift: boolean;
  100372. /**
  100373. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100374. */
  100375. keysRadiusIncr: number[];
  100376. /**
  100377. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100378. */
  100379. keysRadiusDecr: number[];
  100380. /**
  100381. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100382. */
  100383. keysRadiusModifierAlt: boolean;
  100384. /**
  100385. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100386. */
  100387. keysRadiusModifierCtrl: boolean;
  100388. /**
  100389. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100390. */
  100391. keysRadiusModifierShift: boolean;
  100392. /**
  100393. * Defines the rate of change of heightOffset.
  100394. */
  100395. heightSensibility: number;
  100396. /**
  100397. * Defines the rate of change of rotationOffset.
  100398. */
  100399. rotationSensibility: number;
  100400. /**
  100401. * Defines the rate of change of radius.
  100402. */
  100403. radiusSensibility: number;
  100404. private _keys;
  100405. private _ctrlPressed;
  100406. private _altPressed;
  100407. private _shiftPressed;
  100408. private _onCanvasBlurObserver;
  100409. private _onKeyboardObserver;
  100410. private _engine;
  100411. private _scene;
  100412. /**
  100413. * Attach the input controls to a specific dom element to get the input from.
  100414. * @param element Defines the element the controls should be listened from
  100415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100416. */
  100417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100418. /**
  100419. * Detach the current controls from the specified dom element.
  100420. * @param element Defines the element to stop listening the inputs from
  100421. */
  100422. detachControl(element: Nullable<HTMLElement>): void;
  100423. /**
  100424. * Update the current camera state depending on the inputs that have been used this frame.
  100425. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100426. */
  100427. checkInputs(): void;
  100428. /**
  100429. * Gets the class name of the current input.
  100430. * @returns the class name
  100431. */
  100432. getClassName(): string;
  100433. /**
  100434. * Get the friendly name associated with the input class.
  100435. * @returns the input friendly name
  100436. */
  100437. getSimpleName(): string;
  100438. /**
  100439. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100440. * allow modification of the heightOffset value.
  100441. */
  100442. private _modifierHeightOffset;
  100443. /**
  100444. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100445. * allow modification of the rotationOffset value.
  100446. */
  100447. private _modifierRotationOffset;
  100448. /**
  100449. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100450. * allow modification of the radius value.
  100451. */
  100452. private _modifierRadius;
  100453. }
  100454. }
  100455. declare module BABYLON {
  100456. interface FreeCameraInputsManager {
  100457. /**
  100458. * @hidden
  100459. */
  100460. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100461. /**
  100462. * Add orientation input support to the input manager.
  100463. * @returns the current input manager
  100464. */
  100465. addDeviceOrientation(): FreeCameraInputsManager;
  100466. }
  100467. /**
  100468. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100469. * Screen rotation is taken into account.
  100470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100471. */
  100472. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100473. private _camera;
  100474. private _screenOrientationAngle;
  100475. private _constantTranform;
  100476. private _screenQuaternion;
  100477. private _alpha;
  100478. private _beta;
  100479. private _gamma;
  100480. /**
  100481. * Can be used to detect if a device orientation sensor is availible on a device
  100482. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100483. * @returns a promise that will resolve on orientation change
  100484. */
  100485. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100486. /**
  100487. * @hidden
  100488. */
  100489. _onDeviceOrientationChangedObservable: Observable<void>;
  100490. /**
  100491. * Instantiates a new input
  100492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100493. */
  100494. constructor();
  100495. /**
  100496. * Define the camera controlled by the input.
  100497. */
  100498. camera: FreeCamera;
  100499. /**
  100500. * Attach the input controls to a specific dom element to get the input from.
  100501. * @param element Defines the element the controls should be listened from
  100502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100503. */
  100504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100505. private _orientationChanged;
  100506. private _deviceOrientation;
  100507. /**
  100508. * Detach the current controls from the specified dom element.
  100509. * @param element Defines the element to stop listening the inputs from
  100510. */
  100511. detachControl(element: Nullable<HTMLElement>): void;
  100512. /**
  100513. * Update the current camera state depending on the inputs that have been used this frame.
  100514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100515. */
  100516. checkInputs(): void;
  100517. /**
  100518. * Gets the class name of the current intput.
  100519. * @returns the class name
  100520. */
  100521. getClassName(): string;
  100522. /**
  100523. * Get the friendly name associated with the input class.
  100524. * @returns the input friendly name
  100525. */
  100526. getSimpleName(): string;
  100527. }
  100528. }
  100529. declare module BABYLON {
  100530. /**
  100531. * Manage the gamepad inputs to control a free camera.
  100532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100533. */
  100534. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100535. /**
  100536. * Define the camera the input is attached to.
  100537. */
  100538. camera: FreeCamera;
  100539. /**
  100540. * Define the Gamepad controlling the input
  100541. */
  100542. gamepad: Nullable<Gamepad>;
  100543. /**
  100544. * Defines the gamepad rotation sensiblity.
  100545. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100546. */
  100547. gamepadAngularSensibility: number;
  100548. /**
  100549. * Defines the gamepad move sensiblity.
  100550. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100551. */
  100552. gamepadMoveSensibility: number;
  100553. private _onGamepadConnectedObserver;
  100554. private _onGamepadDisconnectedObserver;
  100555. private _cameraTransform;
  100556. private _deltaTransform;
  100557. private _vector3;
  100558. private _vector2;
  100559. /**
  100560. * Attach the input controls to a specific dom element to get the input from.
  100561. * @param element Defines the element the controls should be listened from
  100562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100563. */
  100564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100565. /**
  100566. * Detach the current controls from the specified dom element.
  100567. * @param element Defines the element to stop listening the inputs from
  100568. */
  100569. detachControl(element: Nullable<HTMLElement>): void;
  100570. /**
  100571. * Update the current camera state depending on the inputs that have been used this frame.
  100572. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100573. */
  100574. checkInputs(): void;
  100575. /**
  100576. * Gets the class name of the current intput.
  100577. * @returns the class name
  100578. */
  100579. getClassName(): string;
  100580. /**
  100581. * Get the friendly name associated with the input class.
  100582. * @returns the input friendly name
  100583. */
  100584. getSimpleName(): string;
  100585. }
  100586. }
  100587. declare module BABYLON {
  100588. /**
  100589. * Defines the potential axis of a Joystick
  100590. */
  100591. export enum JoystickAxis {
  100592. /** X axis */
  100593. X = 0,
  100594. /** Y axis */
  100595. Y = 1,
  100596. /** Z axis */
  100597. Z = 2
  100598. }
  100599. /**
  100600. * Class used to define virtual joystick (used in touch mode)
  100601. */
  100602. export class VirtualJoystick {
  100603. /**
  100604. * Gets or sets a boolean indicating that left and right values must be inverted
  100605. */
  100606. reverseLeftRight: boolean;
  100607. /**
  100608. * Gets or sets a boolean indicating that up and down values must be inverted
  100609. */
  100610. reverseUpDown: boolean;
  100611. /**
  100612. * Gets the offset value for the position (ie. the change of the position value)
  100613. */
  100614. deltaPosition: Vector3;
  100615. /**
  100616. * Gets a boolean indicating if the virtual joystick was pressed
  100617. */
  100618. pressed: boolean;
  100619. /**
  100620. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100621. */
  100622. static Canvas: Nullable<HTMLCanvasElement>;
  100623. private static _globalJoystickIndex;
  100624. private static vjCanvasContext;
  100625. private static vjCanvasWidth;
  100626. private static vjCanvasHeight;
  100627. private static halfWidth;
  100628. private _action;
  100629. private _axisTargetedByLeftAndRight;
  100630. private _axisTargetedByUpAndDown;
  100631. private _joystickSensibility;
  100632. private _inversedSensibility;
  100633. private _joystickPointerID;
  100634. private _joystickColor;
  100635. private _joystickPointerPos;
  100636. private _joystickPreviousPointerPos;
  100637. private _joystickPointerStartPos;
  100638. private _deltaJoystickVector;
  100639. private _leftJoystick;
  100640. private _touches;
  100641. private _onPointerDownHandlerRef;
  100642. private _onPointerMoveHandlerRef;
  100643. private _onPointerUpHandlerRef;
  100644. private _onResize;
  100645. /**
  100646. * Creates a new virtual joystick
  100647. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100648. */
  100649. constructor(leftJoystick?: boolean);
  100650. /**
  100651. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100652. * @param newJoystickSensibility defines the new sensibility
  100653. */
  100654. setJoystickSensibility(newJoystickSensibility: number): void;
  100655. private _onPointerDown;
  100656. private _onPointerMove;
  100657. private _onPointerUp;
  100658. /**
  100659. * Change the color of the virtual joystick
  100660. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100661. */
  100662. setJoystickColor(newColor: string): void;
  100663. /**
  100664. * Defines a callback to call when the joystick is touched
  100665. * @param action defines the callback
  100666. */
  100667. setActionOnTouch(action: () => any): void;
  100668. /**
  100669. * Defines which axis you'd like to control for left & right
  100670. * @param axis defines the axis to use
  100671. */
  100672. setAxisForLeftRight(axis: JoystickAxis): void;
  100673. /**
  100674. * Defines which axis you'd like to control for up & down
  100675. * @param axis defines the axis to use
  100676. */
  100677. setAxisForUpDown(axis: JoystickAxis): void;
  100678. private _drawVirtualJoystick;
  100679. /**
  100680. * Release internal HTML canvas
  100681. */
  100682. releaseCanvas(): void;
  100683. }
  100684. }
  100685. declare module BABYLON {
  100686. interface FreeCameraInputsManager {
  100687. /**
  100688. * Add virtual joystick input support to the input manager.
  100689. * @returns the current input manager
  100690. */
  100691. addVirtualJoystick(): FreeCameraInputsManager;
  100692. }
  100693. /**
  100694. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100696. */
  100697. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100698. /**
  100699. * Defines the camera the input is attached to.
  100700. */
  100701. camera: FreeCamera;
  100702. private _leftjoystick;
  100703. private _rightjoystick;
  100704. /**
  100705. * Gets the left stick of the virtual joystick.
  100706. * @returns The virtual Joystick
  100707. */
  100708. getLeftJoystick(): VirtualJoystick;
  100709. /**
  100710. * Gets the right stick of the virtual joystick.
  100711. * @returns The virtual Joystick
  100712. */
  100713. getRightJoystick(): VirtualJoystick;
  100714. /**
  100715. * Update the current camera state depending on the inputs that have been used this frame.
  100716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100717. */
  100718. checkInputs(): void;
  100719. /**
  100720. * Attach the input controls to a specific dom element to get the input from.
  100721. * @param element Defines the element the controls should be listened from
  100722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100723. */
  100724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100725. /**
  100726. * Detach the current controls from the specified dom element.
  100727. * @param element Defines the element to stop listening the inputs from
  100728. */
  100729. detachControl(element: Nullable<HTMLElement>): void;
  100730. /**
  100731. * Gets the class name of the current intput.
  100732. * @returns the class name
  100733. */
  100734. getClassName(): string;
  100735. /**
  100736. * Get the friendly name associated with the input class.
  100737. * @returns the input friendly name
  100738. */
  100739. getSimpleName(): string;
  100740. }
  100741. }
  100742. declare module BABYLON {
  100743. /**
  100744. * This represents a FPS type of camera controlled by touch.
  100745. * This is like a universal camera minus the Gamepad controls.
  100746. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100747. */
  100748. export class TouchCamera extends FreeCamera {
  100749. /**
  100750. * Defines the touch sensibility for rotation.
  100751. * The higher the faster.
  100752. */
  100753. touchAngularSensibility: number;
  100754. /**
  100755. * Defines the touch sensibility for move.
  100756. * The higher the faster.
  100757. */
  100758. touchMoveSensibility: number;
  100759. /**
  100760. * Instantiates a new touch camera.
  100761. * This represents a FPS type of camera controlled by touch.
  100762. * This is like a universal camera minus the Gamepad controls.
  100763. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100764. * @param name Define the name of the camera in the scene
  100765. * @param position Define the start position of the camera in the scene
  100766. * @param scene Define the scene the camera belongs to
  100767. */
  100768. constructor(name: string, position: Vector3, scene: Scene);
  100769. /**
  100770. * Gets the current object class name.
  100771. * @return the class name
  100772. */
  100773. getClassName(): string;
  100774. /** @hidden */
  100775. _setupInputs(): void;
  100776. }
  100777. }
  100778. declare module BABYLON {
  100779. /**
  100780. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100781. * being tilted forward or back and left or right.
  100782. */
  100783. export class DeviceOrientationCamera extends FreeCamera {
  100784. private _initialQuaternion;
  100785. private _quaternionCache;
  100786. private _tmpDragQuaternion;
  100787. /**
  100788. * Creates a new device orientation camera
  100789. * @param name The name of the camera
  100790. * @param position The start position camera
  100791. * @param scene The scene the camera belongs to
  100792. */
  100793. constructor(name: string, position: Vector3, scene: Scene);
  100794. /**
  100795. * @hidden
  100796. * Disabled pointer input on first orientation sensor update (Default: true)
  100797. */
  100798. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100799. private _dragFactor;
  100800. /**
  100801. * Enabled turning on the y axis when the orientation sensor is active
  100802. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100803. */
  100804. enableHorizontalDragging(dragFactor?: number): void;
  100805. /**
  100806. * Gets the current instance class name ("DeviceOrientationCamera").
  100807. * This helps avoiding instanceof at run time.
  100808. * @returns the class name
  100809. */
  100810. getClassName(): string;
  100811. /**
  100812. * @hidden
  100813. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100814. */
  100815. _checkInputs(): void;
  100816. /**
  100817. * Reset the camera to its default orientation on the specified axis only.
  100818. * @param axis The axis to reset
  100819. */
  100820. resetToCurrentRotation(axis?: Axis): void;
  100821. }
  100822. }
  100823. declare module BABYLON {
  100824. /**
  100825. * Defines supported buttons for XBox360 compatible gamepads
  100826. */
  100827. export enum Xbox360Button {
  100828. /** A */
  100829. A = 0,
  100830. /** B */
  100831. B = 1,
  100832. /** X */
  100833. X = 2,
  100834. /** Y */
  100835. Y = 3,
  100836. /** Start */
  100837. Start = 4,
  100838. /** Back */
  100839. Back = 5,
  100840. /** Left button */
  100841. LB = 6,
  100842. /** Right button */
  100843. RB = 7,
  100844. /** Left stick */
  100845. LeftStick = 8,
  100846. /** Right stick */
  100847. RightStick = 9
  100848. }
  100849. /** Defines values for XBox360 DPad */
  100850. export enum Xbox360Dpad {
  100851. /** Up */
  100852. Up = 0,
  100853. /** Down */
  100854. Down = 1,
  100855. /** Left */
  100856. Left = 2,
  100857. /** Right */
  100858. Right = 3
  100859. }
  100860. /**
  100861. * Defines a XBox360 gamepad
  100862. */
  100863. export class Xbox360Pad extends Gamepad {
  100864. private _leftTrigger;
  100865. private _rightTrigger;
  100866. private _onlefttriggerchanged;
  100867. private _onrighttriggerchanged;
  100868. private _onbuttondown;
  100869. private _onbuttonup;
  100870. private _ondpaddown;
  100871. private _ondpadup;
  100872. /** Observable raised when a button is pressed */
  100873. onButtonDownObservable: Observable<Xbox360Button>;
  100874. /** Observable raised when a button is released */
  100875. onButtonUpObservable: Observable<Xbox360Button>;
  100876. /** Observable raised when a pad is pressed */
  100877. onPadDownObservable: Observable<Xbox360Dpad>;
  100878. /** Observable raised when a pad is released */
  100879. onPadUpObservable: Observable<Xbox360Dpad>;
  100880. private _buttonA;
  100881. private _buttonB;
  100882. private _buttonX;
  100883. private _buttonY;
  100884. private _buttonBack;
  100885. private _buttonStart;
  100886. private _buttonLB;
  100887. private _buttonRB;
  100888. private _buttonLeftStick;
  100889. private _buttonRightStick;
  100890. private _dPadUp;
  100891. private _dPadDown;
  100892. private _dPadLeft;
  100893. private _dPadRight;
  100894. private _isXboxOnePad;
  100895. /**
  100896. * Creates a new XBox360 gamepad object
  100897. * @param id defines the id of this gamepad
  100898. * @param index defines its index
  100899. * @param gamepad defines the internal HTML gamepad object
  100900. * @param xboxOne defines if it is a XBox One gamepad
  100901. */
  100902. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100903. /**
  100904. * Defines the callback to call when left trigger is pressed
  100905. * @param callback defines the callback to use
  100906. */
  100907. onlefttriggerchanged(callback: (value: number) => void): void;
  100908. /**
  100909. * Defines the callback to call when right trigger is pressed
  100910. * @param callback defines the callback to use
  100911. */
  100912. onrighttriggerchanged(callback: (value: number) => void): void;
  100913. /**
  100914. * Gets the left trigger value
  100915. */
  100916. /**
  100917. * Sets the left trigger value
  100918. */
  100919. leftTrigger: number;
  100920. /**
  100921. * Gets the right trigger value
  100922. */
  100923. /**
  100924. * Sets the right trigger value
  100925. */
  100926. rightTrigger: number;
  100927. /**
  100928. * Defines the callback to call when a button is pressed
  100929. * @param callback defines the callback to use
  100930. */
  100931. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100932. /**
  100933. * Defines the callback to call when a button is released
  100934. * @param callback defines the callback to use
  100935. */
  100936. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100937. /**
  100938. * Defines the callback to call when a pad is pressed
  100939. * @param callback defines the callback to use
  100940. */
  100941. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100942. /**
  100943. * Defines the callback to call when a pad is released
  100944. * @param callback defines the callback to use
  100945. */
  100946. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100947. private _setButtonValue;
  100948. private _setDPadValue;
  100949. /**
  100950. * Gets the value of the `A` button
  100951. */
  100952. /**
  100953. * Sets the value of the `A` button
  100954. */
  100955. buttonA: number;
  100956. /**
  100957. * Gets the value of the `B` button
  100958. */
  100959. /**
  100960. * Sets the value of the `B` button
  100961. */
  100962. buttonB: number;
  100963. /**
  100964. * Gets the value of the `X` button
  100965. */
  100966. /**
  100967. * Sets the value of the `X` button
  100968. */
  100969. buttonX: number;
  100970. /**
  100971. * Gets the value of the `Y` button
  100972. */
  100973. /**
  100974. * Sets the value of the `Y` button
  100975. */
  100976. buttonY: number;
  100977. /**
  100978. * Gets the value of the `Start` button
  100979. */
  100980. /**
  100981. * Sets the value of the `Start` button
  100982. */
  100983. buttonStart: number;
  100984. /**
  100985. * Gets the value of the `Back` button
  100986. */
  100987. /**
  100988. * Sets the value of the `Back` button
  100989. */
  100990. buttonBack: number;
  100991. /**
  100992. * Gets the value of the `Left` button
  100993. */
  100994. /**
  100995. * Sets the value of the `Left` button
  100996. */
  100997. buttonLB: number;
  100998. /**
  100999. * Gets the value of the `Right` button
  101000. */
  101001. /**
  101002. * Sets the value of the `Right` button
  101003. */
  101004. buttonRB: number;
  101005. /**
  101006. * Gets the value of the Left joystick
  101007. */
  101008. /**
  101009. * Sets the value of the Left joystick
  101010. */
  101011. buttonLeftStick: number;
  101012. /**
  101013. * Gets the value of the Right joystick
  101014. */
  101015. /**
  101016. * Sets the value of the Right joystick
  101017. */
  101018. buttonRightStick: number;
  101019. /**
  101020. * Gets the value of D-pad up
  101021. */
  101022. /**
  101023. * Sets the value of D-pad up
  101024. */
  101025. dPadUp: number;
  101026. /**
  101027. * Gets the value of D-pad down
  101028. */
  101029. /**
  101030. * Sets the value of D-pad down
  101031. */
  101032. dPadDown: number;
  101033. /**
  101034. * Gets the value of D-pad left
  101035. */
  101036. /**
  101037. * Sets the value of D-pad left
  101038. */
  101039. dPadLeft: number;
  101040. /**
  101041. * Gets the value of D-pad right
  101042. */
  101043. /**
  101044. * Sets the value of D-pad right
  101045. */
  101046. dPadRight: number;
  101047. /**
  101048. * Force the gamepad to synchronize with device values
  101049. */
  101050. update(): void;
  101051. /**
  101052. * Disposes the gamepad
  101053. */
  101054. dispose(): void;
  101055. }
  101056. }
  101057. declare module BABYLON {
  101058. /**
  101059. * Manager for handling gamepads
  101060. */
  101061. export class GamepadManager {
  101062. private _scene?;
  101063. private _babylonGamepads;
  101064. private _oneGamepadConnected;
  101065. /** @hidden */
  101066. _isMonitoring: boolean;
  101067. private _gamepadEventSupported;
  101068. private _gamepadSupport;
  101069. /**
  101070. * observable to be triggered when the gamepad controller has been connected
  101071. */
  101072. onGamepadConnectedObservable: Observable<Gamepad>;
  101073. /**
  101074. * observable to be triggered when the gamepad controller has been disconnected
  101075. */
  101076. onGamepadDisconnectedObservable: Observable<Gamepad>;
  101077. private _onGamepadConnectedEvent;
  101078. private _onGamepadDisconnectedEvent;
  101079. /**
  101080. * Initializes the gamepad manager
  101081. * @param _scene BabylonJS scene
  101082. */
  101083. constructor(_scene?: Scene | undefined);
  101084. /**
  101085. * The gamepads in the game pad manager
  101086. */
  101087. readonly gamepads: Gamepad[];
  101088. /**
  101089. * Get the gamepad controllers based on type
  101090. * @param type The type of gamepad controller
  101091. * @returns Nullable gamepad
  101092. */
  101093. getGamepadByType(type?: number): Nullable<Gamepad>;
  101094. /**
  101095. * Disposes the gamepad manager
  101096. */
  101097. dispose(): void;
  101098. private _addNewGamepad;
  101099. private _startMonitoringGamepads;
  101100. private _stopMonitoringGamepads;
  101101. /** @hidden */
  101102. _checkGamepadsStatus(): void;
  101103. private _updateGamepadObjects;
  101104. }
  101105. }
  101106. declare module BABYLON {
  101107. interface Scene {
  101108. /** @hidden */
  101109. _gamepadManager: Nullable<GamepadManager>;
  101110. /**
  101111. * Gets the gamepad manager associated with the scene
  101112. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  101113. */
  101114. gamepadManager: GamepadManager;
  101115. }
  101116. /**
  101117. * Interface representing a free camera inputs manager
  101118. */
  101119. interface FreeCameraInputsManager {
  101120. /**
  101121. * Adds gamepad input support to the FreeCameraInputsManager.
  101122. * @returns the FreeCameraInputsManager
  101123. */
  101124. addGamepad(): FreeCameraInputsManager;
  101125. }
  101126. /**
  101127. * Interface representing an arc rotate camera inputs manager
  101128. */
  101129. interface ArcRotateCameraInputsManager {
  101130. /**
  101131. * Adds gamepad input support to the ArcRotateCamera InputManager.
  101132. * @returns the camera inputs manager
  101133. */
  101134. addGamepad(): ArcRotateCameraInputsManager;
  101135. }
  101136. /**
  101137. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  101138. */
  101139. export class GamepadSystemSceneComponent implements ISceneComponent {
  101140. /**
  101141. * The component name helpfull to identify the component in the list of scene components.
  101142. */
  101143. readonly name: string;
  101144. /**
  101145. * The scene the component belongs to.
  101146. */
  101147. scene: Scene;
  101148. /**
  101149. * Creates a new instance of the component for the given scene
  101150. * @param scene Defines the scene to register the component in
  101151. */
  101152. constructor(scene: Scene);
  101153. /**
  101154. * Registers the component in a given scene
  101155. */
  101156. register(): void;
  101157. /**
  101158. * Rebuilds the elements related to this component in case of
  101159. * context lost for instance.
  101160. */
  101161. rebuild(): void;
  101162. /**
  101163. * Disposes the component and the associated ressources
  101164. */
  101165. dispose(): void;
  101166. private _beforeCameraUpdate;
  101167. }
  101168. }
  101169. declare module BABYLON {
  101170. /**
  101171. * 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,
  101172. * which still works and will still be found in many Playgrounds.
  101173. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101174. */
  101175. export class UniversalCamera extends TouchCamera {
  101176. /**
  101177. * Defines the gamepad rotation sensiblity.
  101178. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101179. */
  101180. gamepadAngularSensibility: number;
  101181. /**
  101182. * Defines the gamepad move sensiblity.
  101183. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101184. */
  101185. gamepadMoveSensibility: number;
  101186. /**
  101187. * 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,
  101188. * which still works and will still be found in many Playgrounds.
  101189. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101190. * @param name Define the name of the camera in the scene
  101191. * @param position Define the start position of the camera in the scene
  101192. * @param scene Define the scene the camera belongs to
  101193. */
  101194. constructor(name: string, position: Vector3, scene: Scene);
  101195. /**
  101196. * Gets the current object class name.
  101197. * @return the class name
  101198. */
  101199. getClassName(): string;
  101200. }
  101201. }
  101202. declare module BABYLON {
  101203. /**
  101204. * This represents a FPS type of camera. This is only here for back compat purpose.
  101205. * Please use the UniversalCamera instead as both are identical.
  101206. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101207. */
  101208. export class GamepadCamera extends UniversalCamera {
  101209. /**
  101210. * Instantiates a new Gamepad Camera
  101211. * This represents a FPS type of camera. This is only here for back compat purpose.
  101212. * Please use the UniversalCamera instead as both are identical.
  101213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101214. * @param name Define the name of the camera in the scene
  101215. * @param position Define the start position of the camera in the scene
  101216. * @param scene Define the scene the camera belongs to
  101217. */
  101218. constructor(name: string, position: Vector3, scene: Scene);
  101219. /**
  101220. * Gets the current object class name.
  101221. * @return the class name
  101222. */
  101223. getClassName(): string;
  101224. }
  101225. }
  101226. declare module BABYLON {
  101227. /** @hidden */
  101228. export var passPixelShader: {
  101229. name: string;
  101230. shader: string;
  101231. };
  101232. }
  101233. declare module BABYLON {
  101234. /** @hidden */
  101235. export var passCubePixelShader: {
  101236. name: string;
  101237. shader: string;
  101238. };
  101239. }
  101240. declare module BABYLON {
  101241. /**
  101242. * PassPostProcess which produces an output the same as it's input
  101243. */
  101244. export class PassPostProcess extends PostProcess {
  101245. /**
  101246. * Creates the PassPostProcess
  101247. * @param name The name of the effect.
  101248. * @param options The required width/height ratio to downsize to before computing the render pass.
  101249. * @param camera The camera to apply the render pass to.
  101250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101251. * @param engine The engine which the post process will be applied. (default: current engine)
  101252. * @param reusable If the post process can be reused on the same frame. (default: false)
  101253. * @param textureType The type of texture to be used when performing the post processing.
  101254. * @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)
  101255. */
  101256. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101257. }
  101258. /**
  101259. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  101260. */
  101261. export class PassCubePostProcess extends PostProcess {
  101262. private _face;
  101263. /**
  101264. * Gets or sets the cube face to display.
  101265. * * 0 is +X
  101266. * * 1 is -X
  101267. * * 2 is +Y
  101268. * * 3 is -Y
  101269. * * 4 is +Z
  101270. * * 5 is -Z
  101271. */
  101272. face: number;
  101273. /**
  101274. * Creates the PassCubePostProcess
  101275. * @param name The name of the effect.
  101276. * @param options The required width/height ratio to downsize to before computing the render pass.
  101277. * @param camera The camera to apply the render pass to.
  101278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101279. * @param engine The engine which the post process will be applied. (default: current engine)
  101280. * @param reusable If the post process can be reused on the same frame. (default: false)
  101281. * @param textureType The type of texture to be used when performing the post processing.
  101282. * @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)
  101283. */
  101284. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101285. }
  101286. }
  101287. declare module BABYLON {
  101288. /** @hidden */
  101289. export var anaglyphPixelShader: {
  101290. name: string;
  101291. shader: string;
  101292. };
  101293. }
  101294. declare module BABYLON {
  101295. /**
  101296. * Postprocess used to generate anaglyphic rendering
  101297. */
  101298. export class AnaglyphPostProcess extends PostProcess {
  101299. private _passedProcess;
  101300. /**
  101301. * Creates a new AnaglyphPostProcess
  101302. * @param name defines postprocess name
  101303. * @param options defines creation options or target ratio scale
  101304. * @param rigCameras defines cameras using this postprocess
  101305. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101306. * @param engine defines hosting engine
  101307. * @param reusable defines if the postprocess will be reused multiple times per frame
  101308. */
  101309. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101310. }
  101311. }
  101312. declare module BABYLON {
  101313. /**
  101314. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101315. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101316. */
  101317. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101318. /**
  101319. * Creates a new AnaglyphArcRotateCamera
  101320. * @param name defines camera name
  101321. * @param alpha defines alpha angle (in radians)
  101322. * @param beta defines beta angle (in radians)
  101323. * @param radius defines radius
  101324. * @param target defines camera target
  101325. * @param interaxialDistance defines distance between each color axis
  101326. * @param scene defines the hosting scene
  101327. */
  101328. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101329. /**
  101330. * Gets camera class name
  101331. * @returns AnaglyphArcRotateCamera
  101332. */
  101333. getClassName(): string;
  101334. }
  101335. }
  101336. declare module BABYLON {
  101337. /**
  101338. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101339. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101340. */
  101341. export class AnaglyphFreeCamera extends FreeCamera {
  101342. /**
  101343. * Creates a new AnaglyphFreeCamera
  101344. * @param name defines camera name
  101345. * @param position defines initial position
  101346. * @param interaxialDistance defines distance between each color axis
  101347. * @param scene defines the hosting scene
  101348. */
  101349. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101350. /**
  101351. * Gets camera class name
  101352. * @returns AnaglyphFreeCamera
  101353. */
  101354. getClassName(): string;
  101355. }
  101356. }
  101357. declare module BABYLON {
  101358. /**
  101359. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101360. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101361. */
  101362. export class AnaglyphGamepadCamera extends GamepadCamera {
  101363. /**
  101364. * Creates a new AnaglyphGamepadCamera
  101365. * @param name defines camera name
  101366. * @param position defines initial position
  101367. * @param interaxialDistance defines distance between each color axis
  101368. * @param scene defines the hosting scene
  101369. */
  101370. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101371. /**
  101372. * Gets camera class name
  101373. * @returns AnaglyphGamepadCamera
  101374. */
  101375. getClassName(): string;
  101376. }
  101377. }
  101378. declare module BABYLON {
  101379. /**
  101380. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101381. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101382. */
  101383. export class AnaglyphUniversalCamera extends UniversalCamera {
  101384. /**
  101385. * Creates a new AnaglyphUniversalCamera
  101386. * @param name defines camera name
  101387. * @param position defines initial position
  101388. * @param interaxialDistance defines distance between each color axis
  101389. * @param scene defines the hosting scene
  101390. */
  101391. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101392. /**
  101393. * Gets camera class name
  101394. * @returns AnaglyphUniversalCamera
  101395. */
  101396. getClassName(): string;
  101397. }
  101398. }
  101399. declare module BABYLON {
  101400. /** @hidden */
  101401. export var stereoscopicInterlacePixelShader: {
  101402. name: string;
  101403. shader: string;
  101404. };
  101405. }
  101406. declare module BABYLON {
  101407. /**
  101408. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101409. */
  101410. export class StereoscopicInterlacePostProcess extends PostProcess {
  101411. private _stepSize;
  101412. private _passedProcess;
  101413. /**
  101414. * Initializes a StereoscopicInterlacePostProcess
  101415. * @param name The name of the effect.
  101416. * @param rigCameras The rig cameras to be appled to the post process
  101417. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101419. * @param engine The engine which the post process will be applied. (default: current engine)
  101420. * @param reusable If the post process can be reused on the same frame. (default: false)
  101421. */
  101422. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101423. }
  101424. }
  101425. declare module BABYLON {
  101426. /**
  101427. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101428. * @see http://doc.babylonjs.com/features/cameras
  101429. */
  101430. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101431. /**
  101432. * Creates a new StereoscopicArcRotateCamera
  101433. * @param name defines camera name
  101434. * @param alpha defines alpha angle (in radians)
  101435. * @param beta defines beta angle (in radians)
  101436. * @param radius defines radius
  101437. * @param target defines camera target
  101438. * @param interaxialDistance defines distance between each color axis
  101439. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101440. * @param scene defines the hosting scene
  101441. */
  101442. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101443. /**
  101444. * Gets camera class name
  101445. * @returns StereoscopicArcRotateCamera
  101446. */
  101447. getClassName(): string;
  101448. }
  101449. }
  101450. declare module BABYLON {
  101451. /**
  101452. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101453. * @see http://doc.babylonjs.com/features/cameras
  101454. */
  101455. export class StereoscopicFreeCamera extends FreeCamera {
  101456. /**
  101457. * Creates a new StereoscopicFreeCamera
  101458. * @param name defines camera name
  101459. * @param position defines initial position
  101460. * @param interaxialDistance defines distance between each color axis
  101461. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101462. * @param scene defines the hosting scene
  101463. */
  101464. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101465. /**
  101466. * Gets camera class name
  101467. * @returns StereoscopicFreeCamera
  101468. */
  101469. getClassName(): string;
  101470. }
  101471. }
  101472. declare module BABYLON {
  101473. /**
  101474. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101475. * @see http://doc.babylonjs.com/features/cameras
  101476. */
  101477. export class StereoscopicGamepadCamera extends GamepadCamera {
  101478. /**
  101479. * Creates a new StereoscopicGamepadCamera
  101480. * @param name defines camera name
  101481. * @param position defines initial position
  101482. * @param interaxialDistance defines distance between each color axis
  101483. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101484. * @param scene defines the hosting scene
  101485. */
  101486. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101487. /**
  101488. * Gets camera class name
  101489. * @returns StereoscopicGamepadCamera
  101490. */
  101491. getClassName(): string;
  101492. }
  101493. }
  101494. declare module BABYLON {
  101495. /**
  101496. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101497. * @see http://doc.babylonjs.com/features/cameras
  101498. */
  101499. export class StereoscopicUniversalCamera extends UniversalCamera {
  101500. /**
  101501. * Creates a new StereoscopicUniversalCamera
  101502. * @param name defines camera name
  101503. * @param position defines initial position
  101504. * @param interaxialDistance defines distance between each color axis
  101505. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101506. * @param scene defines the hosting scene
  101507. */
  101508. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101509. /**
  101510. * Gets camera class name
  101511. * @returns StereoscopicUniversalCamera
  101512. */
  101513. getClassName(): string;
  101514. }
  101515. }
  101516. declare module BABYLON {
  101517. /**
  101518. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101519. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101520. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101521. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101522. */
  101523. export class VirtualJoysticksCamera extends FreeCamera {
  101524. /**
  101525. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101526. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101527. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101528. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101529. * @param name Define the name of the camera in the scene
  101530. * @param position Define the start position of the camera in the scene
  101531. * @param scene Define the scene the camera belongs to
  101532. */
  101533. constructor(name: string, position: Vector3, scene: Scene);
  101534. /**
  101535. * Gets the current object class name.
  101536. * @return the class name
  101537. */
  101538. getClassName(): string;
  101539. }
  101540. }
  101541. declare module BABYLON {
  101542. /**
  101543. * This represents all the required metrics to create a VR camera.
  101544. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101545. */
  101546. export class VRCameraMetrics {
  101547. /**
  101548. * Define the horizontal resolution off the screen.
  101549. */
  101550. hResolution: number;
  101551. /**
  101552. * Define the vertical resolution off the screen.
  101553. */
  101554. vResolution: number;
  101555. /**
  101556. * Define the horizontal screen size.
  101557. */
  101558. hScreenSize: number;
  101559. /**
  101560. * Define the vertical screen size.
  101561. */
  101562. vScreenSize: number;
  101563. /**
  101564. * Define the vertical screen center position.
  101565. */
  101566. vScreenCenter: number;
  101567. /**
  101568. * Define the distance of the eyes to the screen.
  101569. */
  101570. eyeToScreenDistance: number;
  101571. /**
  101572. * Define the distance between both lenses
  101573. */
  101574. lensSeparationDistance: number;
  101575. /**
  101576. * Define the distance between both viewer's eyes.
  101577. */
  101578. interpupillaryDistance: number;
  101579. /**
  101580. * Define the distortion factor of the VR postprocess.
  101581. * Please, touch with care.
  101582. */
  101583. distortionK: number[];
  101584. /**
  101585. * Define the chromatic aberration correction factors for the VR post process.
  101586. */
  101587. chromaAbCorrection: number[];
  101588. /**
  101589. * Define the scale factor of the post process.
  101590. * The smaller the better but the slower.
  101591. */
  101592. postProcessScaleFactor: number;
  101593. /**
  101594. * Define an offset for the lens center.
  101595. */
  101596. lensCenterOffset: number;
  101597. /**
  101598. * Define if the current vr camera should compensate the distortion of the lense or not.
  101599. */
  101600. compensateDistortion: boolean;
  101601. /**
  101602. * Defines if multiview should be enabled when rendering (Default: false)
  101603. */
  101604. multiviewEnabled: boolean;
  101605. /**
  101606. * Gets the rendering aspect ratio based on the provided resolutions.
  101607. */
  101608. readonly aspectRatio: number;
  101609. /**
  101610. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101611. */
  101612. readonly aspectRatioFov: number;
  101613. /**
  101614. * @hidden
  101615. */
  101616. readonly leftHMatrix: Matrix;
  101617. /**
  101618. * @hidden
  101619. */
  101620. readonly rightHMatrix: Matrix;
  101621. /**
  101622. * @hidden
  101623. */
  101624. readonly leftPreViewMatrix: Matrix;
  101625. /**
  101626. * @hidden
  101627. */
  101628. readonly rightPreViewMatrix: Matrix;
  101629. /**
  101630. * Get the default VRMetrics based on the most generic setup.
  101631. * @returns the default vr metrics
  101632. */
  101633. static GetDefault(): VRCameraMetrics;
  101634. }
  101635. }
  101636. declare module BABYLON {
  101637. /** @hidden */
  101638. export var vrDistortionCorrectionPixelShader: {
  101639. name: string;
  101640. shader: string;
  101641. };
  101642. }
  101643. declare module BABYLON {
  101644. /**
  101645. * VRDistortionCorrectionPostProcess used for mobile VR
  101646. */
  101647. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101648. private _isRightEye;
  101649. private _distortionFactors;
  101650. private _postProcessScaleFactor;
  101651. private _lensCenterOffset;
  101652. private _scaleIn;
  101653. private _scaleFactor;
  101654. private _lensCenter;
  101655. /**
  101656. * Initializes the VRDistortionCorrectionPostProcess
  101657. * @param name The name of the effect.
  101658. * @param camera The camera to apply the render pass to.
  101659. * @param isRightEye If this is for the right eye distortion
  101660. * @param vrMetrics All the required metrics for the VR camera
  101661. */
  101662. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101663. }
  101664. }
  101665. declare module BABYLON {
  101666. /**
  101667. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101668. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101669. */
  101670. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101671. /**
  101672. * Creates a new VRDeviceOrientationArcRotateCamera
  101673. * @param name defines camera name
  101674. * @param alpha defines the camera rotation along the logitudinal axis
  101675. * @param beta defines the camera rotation along the latitudinal axis
  101676. * @param radius defines the camera distance from its target
  101677. * @param target defines the camera target
  101678. * @param scene defines the scene the camera belongs to
  101679. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101680. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101681. */
  101682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101683. /**
  101684. * Gets camera class name
  101685. * @returns VRDeviceOrientationArcRotateCamera
  101686. */
  101687. getClassName(): string;
  101688. }
  101689. }
  101690. declare module BABYLON {
  101691. /**
  101692. * Camera used to simulate VR rendering (based on FreeCamera)
  101693. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101694. */
  101695. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101696. /**
  101697. * Creates a new VRDeviceOrientationFreeCamera
  101698. * @param name defines camera name
  101699. * @param position defines the start position of the camera
  101700. * @param scene defines the scene the camera belongs to
  101701. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101702. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101703. */
  101704. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101705. /**
  101706. * Gets camera class name
  101707. * @returns VRDeviceOrientationFreeCamera
  101708. */
  101709. getClassName(): string;
  101710. }
  101711. }
  101712. declare module BABYLON {
  101713. /**
  101714. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101715. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101716. */
  101717. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101718. /**
  101719. * Creates a new VRDeviceOrientationGamepadCamera
  101720. * @param name defines camera name
  101721. * @param position defines the start position of the camera
  101722. * @param scene defines the scene the camera belongs to
  101723. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101724. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101725. */
  101726. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101727. /**
  101728. * Gets camera class name
  101729. * @returns VRDeviceOrientationGamepadCamera
  101730. */
  101731. getClassName(): string;
  101732. }
  101733. }
  101734. declare module BABYLON {
  101735. /**
  101736. * Base class of materials working in push mode in babylon JS
  101737. * @hidden
  101738. */
  101739. export class PushMaterial extends Material {
  101740. protected _activeEffect: Effect;
  101741. protected _normalMatrix: Matrix;
  101742. /**
  101743. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101744. * This means that the material can keep using a previous shader while a new one is being compiled.
  101745. * This is mostly used when shader parallel compilation is supported (true by default)
  101746. */
  101747. allowShaderHotSwapping: boolean;
  101748. constructor(name: string, scene: Scene);
  101749. getEffect(): Effect;
  101750. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101751. /**
  101752. * Binds the given world matrix to the active effect
  101753. *
  101754. * @param world the matrix to bind
  101755. */
  101756. bindOnlyWorldMatrix(world: Matrix): void;
  101757. /**
  101758. * Binds the given normal matrix to the active effect
  101759. *
  101760. * @param normalMatrix the matrix to bind
  101761. */
  101762. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101763. bind(world: Matrix, mesh?: Mesh): void;
  101764. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101765. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101766. }
  101767. }
  101768. declare module BABYLON {
  101769. /**
  101770. * This groups all the flags used to control the materials channel.
  101771. */
  101772. export class MaterialFlags {
  101773. private static _DiffuseTextureEnabled;
  101774. /**
  101775. * Are diffuse textures enabled in the application.
  101776. */
  101777. static DiffuseTextureEnabled: boolean;
  101778. private static _AmbientTextureEnabled;
  101779. /**
  101780. * Are ambient textures enabled in the application.
  101781. */
  101782. static AmbientTextureEnabled: boolean;
  101783. private static _OpacityTextureEnabled;
  101784. /**
  101785. * Are opacity textures enabled in the application.
  101786. */
  101787. static OpacityTextureEnabled: boolean;
  101788. private static _ReflectionTextureEnabled;
  101789. /**
  101790. * Are reflection textures enabled in the application.
  101791. */
  101792. static ReflectionTextureEnabled: boolean;
  101793. private static _EmissiveTextureEnabled;
  101794. /**
  101795. * Are emissive textures enabled in the application.
  101796. */
  101797. static EmissiveTextureEnabled: boolean;
  101798. private static _SpecularTextureEnabled;
  101799. /**
  101800. * Are specular textures enabled in the application.
  101801. */
  101802. static SpecularTextureEnabled: boolean;
  101803. private static _BumpTextureEnabled;
  101804. /**
  101805. * Are bump textures enabled in the application.
  101806. */
  101807. static BumpTextureEnabled: boolean;
  101808. private static _LightmapTextureEnabled;
  101809. /**
  101810. * Are lightmap textures enabled in the application.
  101811. */
  101812. static LightmapTextureEnabled: boolean;
  101813. private static _RefractionTextureEnabled;
  101814. /**
  101815. * Are refraction textures enabled in the application.
  101816. */
  101817. static RefractionTextureEnabled: boolean;
  101818. private static _ColorGradingTextureEnabled;
  101819. /**
  101820. * Are color grading textures enabled in the application.
  101821. */
  101822. static ColorGradingTextureEnabled: boolean;
  101823. private static _FresnelEnabled;
  101824. /**
  101825. * Are fresnels enabled in the application.
  101826. */
  101827. static FresnelEnabled: boolean;
  101828. private static _ClearCoatTextureEnabled;
  101829. /**
  101830. * Are clear coat textures enabled in the application.
  101831. */
  101832. static ClearCoatTextureEnabled: boolean;
  101833. private static _ClearCoatBumpTextureEnabled;
  101834. /**
  101835. * Are clear coat bump textures enabled in the application.
  101836. */
  101837. static ClearCoatBumpTextureEnabled: boolean;
  101838. private static _ClearCoatTintTextureEnabled;
  101839. /**
  101840. * Are clear coat tint textures enabled in the application.
  101841. */
  101842. static ClearCoatTintTextureEnabled: boolean;
  101843. private static _SheenTextureEnabled;
  101844. /**
  101845. * Are sheen textures enabled in the application.
  101846. */
  101847. static SheenTextureEnabled: boolean;
  101848. private static _AnisotropicTextureEnabled;
  101849. /**
  101850. * Are anisotropic textures enabled in the application.
  101851. */
  101852. static AnisotropicTextureEnabled: boolean;
  101853. private static _ThicknessTextureEnabled;
  101854. /**
  101855. * Are thickness textures enabled in the application.
  101856. */
  101857. static ThicknessTextureEnabled: boolean;
  101858. }
  101859. }
  101860. declare module BABYLON {
  101861. /** @hidden */
  101862. export var defaultFragmentDeclaration: {
  101863. name: string;
  101864. shader: string;
  101865. };
  101866. }
  101867. declare module BABYLON {
  101868. /** @hidden */
  101869. export var defaultUboDeclaration: {
  101870. name: string;
  101871. shader: string;
  101872. };
  101873. }
  101874. declare module BABYLON {
  101875. /** @hidden */
  101876. export var lightFragmentDeclaration: {
  101877. name: string;
  101878. shader: string;
  101879. };
  101880. }
  101881. declare module BABYLON {
  101882. /** @hidden */
  101883. export var lightUboDeclaration: {
  101884. name: string;
  101885. shader: string;
  101886. };
  101887. }
  101888. declare module BABYLON {
  101889. /** @hidden */
  101890. export var lightsFragmentFunctions: {
  101891. name: string;
  101892. shader: string;
  101893. };
  101894. }
  101895. declare module BABYLON {
  101896. /** @hidden */
  101897. export var shadowsFragmentFunctions: {
  101898. name: string;
  101899. shader: string;
  101900. };
  101901. }
  101902. declare module BABYLON {
  101903. /** @hidden */
  101904. export var fresnelFunction: {
  101905. name: string;
  101906. shader: string;
  101907. };
  101908. }
  101909. declare module BABYLON {
  101910. /** @hidden */
  101911. export var reflectionFunction: {
  101912. name: string;
  101913. shader: string;
  101914. };
  101915. }
  101916. declare module BABYLON {
  101917. /** @hidden */
  101918. export var bumpFragmentFunctions: {
  101919. name: string;
  101920. shader: string;
  101921. };
  101922. }
  101923. declare module BABYLON {
  101924. /** @hidden */
  101925. export var logDepthDeclaration: {
  101926. name: string;
  101927. shader: string;
  101928. };
  101929. }
  101930. declare module BABYLON {
  101931. /** @hidden */
  101932. export var bumpFragment: {
  101933. name: string;
  101934. shader: string;
  101935. };
  101936. }
  101937. declare module BABYLON {
  101938. /** @hidden */
  101939. export var depthPrePass: {
  101940. name: string;
  101941. shader: string;
  101942. };
  101943. }
  101944. declare module BABYLON {
  101945. /** @hidden */
  101946. export var lightFragment: {
  101947. name: string;
  101948. shader: string;
  101949. };
  101950. }
  101951. declare module BABYLON {
  101952. /** @hidden */
  101953. export var logDepthFragment: {
  101954. name: string;
  101955. shader: string;
  101956. };
  101957. }
  101958. declare module BABYLON {
  101959. /** @hidden */
  101960. export var defaultPixelShader: {
  101961. name: string;
  101962. shader: string;
  101963. };
  101964. }
  101965. declare module BABYLON {
  101966. /** @hidden */
  101967. export var defaultVertexDeclaration: {
  101968. name: string;
  101969. shader: string;
  101970. };
  101971. }
  101972. declare module BABYLON {
  101973. /** @hidden */
  101974. export var bumpVertexDeclaration: {
  101975. name: string;
  101976. shader: string;
  101977. };
  101978. }
  101979. declare module BABYLON {
  101980. /** @hidden */
  101981. export var bumpVertex: {
  101982. name: string;
  101983. shader: string;
  101984. };
  101985. }
  101986. declare module BABYLON {
  101987. /** @hidden */
  101988. export var fogVertex: {
  101989. name: string;
  101990. shader: string;
  101991. };
  101992. }
  101993. declare module BABYLON {
  101994. /** @hidden */
  101995. export var shadowsVertex: {
  101996. name: string;
  101997. shader: string;
  101998. };
  101999. }
  102000. declare module BABYLON {
  102001. /** @hidden */
  102002. export var pointCloudVertex: {
  102003. name: string;
  102004. shader: string;
  102005. };
  102006. }
  102007. declare module BABYLON {
  102008. /** @hidden */
  102009. export var logDepthVertex: {
  102010. name: string;
  102011. shader: string;
  102012. };
  102013. }
  102014. declare module BABYLON {
  102015. /** @hidden */
  102016. export var defaultVertexShader: {
  102017. name: string;
  102018. shader: string;
  102019. };
  102020. }
  102021. declare module BABYLON {
  102022. /** @hidden */
  102023. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102024. MAINUV1: boolean;
  102025. MAINUV2: boolean;
  102026. DIFFUSE: boolean;
  102027. DIFFUSEDIRECTUV: number;
  102028. AMBIENT: boolean;
  102029. AMBIENTDIRECTUV: number;
  102030. OPACITY: boolean;
  102031. OPACITYDIRECTUV: number;
  102032. OPACITYRGB: boolean;
  102033. REFLECTION: boolean;
  102034. EMISSIVE: boolean;
  102035. EMISSIVEDIRECTUV: number;
  102036. SPECULAR: boolean;
  102037. SPECULARDIRECTUV: number;
  102038. BUMP: boolean;
  102039. BUMPDIRECTUV: number;
  102040. PARALLAX: boolean;
  102041. PARALLAXOCCLUSION: boolean;
  102042. SPECULAROVERALPHA: boolean;
  102043. CLIPPLANE: boolean;
  102044. CLIPPLANE2: boolean;
  102045. CLIPPLANE3: boolean;
  102046. CLIPPLANE4: boolean;
  102047. ALPHATEST: boolean;
  102048. DEPTHPREPASS: boolean;
  102049. ALPHAFROMDIFFUSE: boolean;
  102050. POINTSIZE: boolean;
  102051. FOG: boolean;
  102052. SPECULARTERM: boolean;
  102053. DIFFUSEFRESNEL: boolean;
  102054. OPACITYFRESNEL: boolean;
  102055. REFLECTIONFRESNEL: boolean;
  102056. REFRACTIONFRESNEL: boolean;
  102057. EMISSIVEFRESNEL: boolean;
  102058. FRESNEL: boolean;
  102059. NORMAL: boolean;
  102060. UV1: boolean;
  102061. UV2: boolean;
  102062. VERTEXCOLOR: boolean;
  102063. VERTEXALPHA: boolean;
  102064. NUM_BONE_INFLUENCERS: number;
  102065. BonesPerMesh: number;
  102066. BONETEXTURE: boolean;
  102067. INSTANCES: boolean;
  102068. GLOSSINESS: boolean;
  102069. ROUGHNESS: boolean;
  102070. EMISSIVEASILLUMINATION: boolean;
  102071. LINKEMISSIVEWITHDIFFUSE: boolean;
  102072. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102073. LIGHTMAP: boolean;
  102074. LIGHTMAPDIRECTUV: number;
  102075. OBJECTSPACE_NORMALMAP: boolean;
  102076. USELIGHTMAPASSHADOWMAP: boolean;
  102077. REFLECTIONMAP_3D: boolean;
  102078. REFLECTIONMAP_SPHERICAL: boolean;
  102079. REFLECTIONMAP_PLANAR: boolean;
  102080. REFLECTIONMAP_CUBIC: boolean;
  102081. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102082. REFLECTIONMAP_PROJECTION: boolean;
  102083. REFLECTIONMAP_SKYBOX: boolean;
  102084. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  102085. REFLECTIONMAP_EXPLICIT: boolean;
  102086. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102087. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102088. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102089. INVERTCUBICMAP: boolean;
  102090. LOGARITHMICDEPTH: boolean;
  102091. REFRACTION: boolean;
  102092. REFRACTIONMAP_3D: boolean;
  102093. REFLECTIONOVERALPHA: boolean;
  102094. TWOSIDEDLIGHTING: boolean;
  102095. SHADOWFLOAT: boolean;
  102096. MORPHTARGETS: boolean;
  102097. MORPHTARGETS_NORMAL: boolean;
  102098. MORPHTARGETS_TANGENT: boolean;
  102099. MORPHTARGETS_UV: boolean;
  102100. NUM_MORPH_INFLUENCERS: number;
  102101. NONUNIFORMSCALING: boolean;
  102102. PREMULTIPLYALPHA: boolean;
  102103. IMAGEPROCESSING: boolean;
  102104. VIGNETTE: boolean;
  102105. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102106. VIGNETTEBLENDMODEOPAQUE: boolean;
  102107. TONEMAPPING: boolean;
  102108. TONEMAPPING_ACES: boolean;
  102109. CONTRAST: boolean;
  102110. COLORCURVES: boolean;
  102111. COLORGRADING: boolean;
  102112. COLORGRADING3D: boolean;
  102113. SAMPLER3DGREENDEPTH: boolean;
  102114. SAMPLER3DBGRMAP: boolean;
  102115. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102116. MULTIVIEW: boolean;
  102117. /**
  102118. * If the reflection texture on this material is in linear color space
  102119. * @hidden
  102120. */
  102121. IS_REFLECTION_LINEAR: boolean;
  102122. /**
  102123. * If the refraction texture on this material is in linear color space
  102124. * @hidden
  102125. */
  102126. IS_REFRACTION_LINEAR: boolean;
  102127. EXPOSURE: boolean;
  102128. constructor();
  102129. setReflectionMode(modeToEnable: string): void;
  102130. }
  102131. /**
  102132. * This is the default material used in Babylon. It is the best trade off between quality
  102133. * and performances.
  102134. * @see http://doc.babylonjs.com/babylon101/materials
  102135. */
  102136. export class StandardMaterial extends PushMaterial {
  102137. private _diffuseTexture;
  102138. /**
  102139. * The basic texture of the material as viewed under a light.
  102140. */
  102141. diffuseTexture: Nullable<BaseTexture>;
  102142. private _ambientTexture;
  102143. /**
  102144. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102145. */
  102146. ambientTexture: Nullable<BaseTexture>;
  102147. private _opacityTexture;
  102148. /**
  102149. * Define the transparency of the material from a texture.
  102150. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102151. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102152. */
  102153. opacityTexture: Nullable<BaseTexture>;
  102154. private _reflectionTexture;
  102155. /**
  102156. * Define the texture used to display the reflection.
  102157. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102158. */
  102159. reflectionTexture: Nullable<BaseTexture>;
  102160. private _emissiveTexture;
  102161. /**
  102162. * Define texture of the material as if self lit.
  102163. * This will be mixed in the final result even in the absence of light.
  102164. */
  102165. emissiveTexture: Nullable<BaseTexture>;
  102166. private _specularTexture;
  102167. /**
  102168. * Define how the color and intensity of the highlight given by the light in the material.
  102169. */
  102170. specularTexture: Nullable<BaseTexture>;
  102171. private _bumpTexture;
  102172. /**
  102173. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102174. * 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.
  102175. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102176. */
  102177. bumpTexture: Nullable<BaseTexture>;
  102178. private _lightmapTexture;
  102179. /**
  102180. * Complex lighting can be computationally expensive to compute at runtime.
  102181. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102182. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102183. */
  102184. lightmapTexture: Nullable<BaseTexture>;
  102185. private _refractionTexture;
  102186. /**
  102187. * Define the texture used to display the refraction.
  102188. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102189. */
  102190. refractionTexture: Nullable<BaseTexture>;
  102191. /**
  102192. * The color of the material lit by the environmental background lighting.
  102193. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102194. */
  102195. ambientColor: Color3;
  102196. /**
  102197. * The basic color of the material as viewed under a light.
  102198. */
  102199. diffuseColor: Color3;
  102200. /**
  102201. * Define how the color and intensity of the highlight given by the light in the material.
  102202. */
  102203. specularColor: Color3;
  102204. /**
  102205. * Define the color of the material as if self lit.
  102206. * This will be mixed in the final result even in the absence of light.
  102207. */
  102208. emissiveColor: Color3;
  102209. /**
  102210. * Defines how sharp are the highlights in the material.
  102211. * The bigger the value the sharper giving a more glossy feeling to the result.
  102212. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102213. */
  102214. specularPower: number;
  102215. private _useAlphaFromDiffuseTexture;
  102216. /**
  102217. * Does the transparency come from the diffuse texture alpha channel.
  102218. */
  102219. useAlphaFromDiffuseTexture: boolean;
  102220. private _useEmissiveAsIllumination;
  102221. /**
  102222. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102223. */
  102224. useEmissiveAsIllumination: boolean;
  102225. private _linkEmissiveWithDiffuse;
  102226. /**
  102227. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102228. * the emissive level when the final color is close to one.
  102229. */
  102230. linkEmissiveWithDiffuse: boolean;
  102231. private _useSpecularOverAlpha;
  102232. /**
  102233. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102234. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102235. */
  102236. useSpecularOverAlpha: boolean;
  102237. private _useReflectionOverAlpha;
  102238. /**
  102239. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102240. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102241. */
  102242. useReflectionOverAlpha: boolean;
  102243. private _disableLighting;
  102244. /**
  102245. * Does lights from the scene impacts this material.
  102246. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102247. */
  102248. disableLighting: boolean;
  102249. private _useObjectSpaceNormalMap;
  102250. /**
  102251. * Allows using an object space normal map (instead of tangent space).
  102252. */
  102253. useObjectSpaceNormalMap: boolean;
  102254. private _useParallax;
  102255. /**
  102256. * Is parallax enabled or not.
  102257. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102258. */
  102259. useParallax: boolean;
  102260. private _useParallaxOcclusion;
  102261. /**
  102262. * Is parallax occlusion enabled or not.
  102263. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102264. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102265. */
  102266. useParallaxOcclusion: boolean;
  102267. /**
  102268. * 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.
  102269. */
  102270. parallaxScaleBias: number;
  102271. private _roughness;
  102272. /**
  102273. * Helps to define how blurry the reflections should appears in the material.
  102274. */
  102275. roughness: number;
  102276. /**
  102277. * In case of refraction, define the value of the index of refraction.
  102278. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102279. */
  102280. indexOfRefraction: number;
  102281. /**
  102282. * Invert the refraction texture alongside the y axis.
  102283. * It can be useful with procedural textures or probe for instance.
  102284. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102285. */
  102286. invertRefractionY: boolean;
  102287. /**
  102288. * Defines the alpha limits in alpha test mode.
  102289. */
  102290. alphaCutOff: number;
  102291. private _useLightmapAsShadowmap;
  102292. /**
  102293. * In case of light mapping, define whether the map contains light or shadow informations.
  102294. */
  102295. useLightmapAsShadowmap: boolean;
  102296. private _diffuseFresnelParameters;
  102297. /**
  102298. * Define the diffuse fresnel parameters of the material.
  102299. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102300. */
  102301. diffuseFresnelParameters: FresnelParameters;
  102302. private _opacityFresnelParameters;
  102303. /**
  102304. * Define the opacity fresnel parameters of the material.
  102305. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102306. */
  102307. opacityFresnelParameters: FresnelParameters;
  102308. private _reflectionFresnelParameters;
  102309. /**
  102310. * Define the reflection fresnel parameters of the material.
  102311. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102312. */
  102313. reflectionFresnelParameters: FresnelParameters;
  102314. private _refractionFresnelParameters;
  102315. /**
  102316. * Define the refraction fresnel parameters of the material.
  102317. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102318. */
  102319. refractionFresnelParameters: FresnelParameters;
  102320. private _emissiveFresnelParameters;
  102321. /**
  102322. * Define the emissive fresnel parameters of the material.
  102323. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102324. */
  102325. emissiveFresnelParameters: FresnelParameters;
  102326. private _useReflectionFresnelFromSpecular;
  102327. /**
  102328. * If true automatically deducts the fresnels values from the material specularity.
  102329. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102330. */
  102331. useReflectionFresnelFromSpecular: boolean;
  102332. private _useGlossinessFromSpecularMapAlpha;
  102333. /**
  102334. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102335. */
  102336. useGlossinessFromSpecularMapAlpha: boolean;
  102337. private _maxSimultaneousLights;
  102338. /**
  102339. * Defines the maximum number of lights that can be used in the material
  102340. */
  102341. maxSimultaneousLights: number;
  102342. private _invertNormalMapX;
  102343. /**
  102344. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102345. */
  102346. invertNormalMapX: boolean;
  102347. private _invertNormalMapY;
  102348. /**
  102349. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102350. */
  102351. invertNormalMapY: boolean;
  102352. private _twoSidedLighting;
  102353. /**
  102354. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102355. */
  102356. twoSidedLighting: boolean;
  102357. /**
  102358. * Default configuration related to image processing available in the standard Material.
  102359. */
  102360. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102361. /**
  102362. * Gets the image processing configuration used either in this material.
  102363. */
  102364. /**
  102365. * Sets the Default image processing configuration used either in the this material.
  102366. *
  102367. * If sets to null, the scene one is in use.
  102368. */
  102369. imageProcessingConfiguration: ImageProcessingConfiguration;
  102370. /**
  102371. * Keep track of the image processing observer to allow dispose and replace.
  102372. */
  102373. private _imageProcessingObserver;
  102374. /**
  102375. * Attaches a new image processing configuration to the Standard Material.
  102376. * @param configuration
  102377. */
  102378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102379. /**
  102380. * Gets wether the color curves effect is enabled.
  102381. */
  102382. /**
  102383. * Sets wether the color curves effect is enabled.
  102384. */
  102385. cameraColorCurvesEnabled: boolean;
  102386. /**
  102387. * Gets wether the color grading effect is enabled.
  102388. */
  102389. /**
  102390. * Gets wether the color grading effect is enabled.
  102391. */
  102392. cameraColorGradingEnabled: boolean;
  102393. /**
  102394. * Gets wether tonemapping is enabled or not.
  102395. */
  102396. /**
  102397. * Sets wether tonemapping is enabled or not
  102398. */
  102399. cameraToneMappingEnabled: boolean;
  102400. /**
  102401. * The camera exposure used on this material.
  102402. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102403. * This corresponds to a photographic exposure.
  102404. */
  102405. /**
  102406. * The camera exposure used on this material.
  102407. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102408. * This corresponds to a photographic exposure.
  102409. */
  102410. cameraExposure: number;
  102411. /**
  102412. * Gets The camera contrast used on this material.
  102413. */
  102414. /**
  102415. * Sets The camera contrast used on this material.
  102416. */
  102417. cameraContrast: number;
  102418. /**
  102419. * Gets the Color Grading 2D Lookup Texture.
  102420. */
  102421. /**
  102422. * Sets the Color Grading 2D Lookup Texture.
  102423. */
  102424. cameraColorGradingTexture: Nullable<BaseTexture>;
  102425. /**
  102426. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102427. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102428. * 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;
  102429. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102430. */
  102431. /**
  102432. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102433. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102434. * 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;
  102435. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102436. */
  102437. cameraColorCurves: Nullable<ColorCurves>;
  102438. /**
  102439. * Custom callback helping to override the default shader used in the material.
  102440. */
  102441. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102442. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102443. protected _worldViewProjectionMatrix: Matrix;
  102444. protected _globalAmbientColor: Color3;
  102445. protected _useLogarithmicDepth: boolean;
  102446. /**
  102447. * Instantiates a new standard material.
  102448. * This is the default material used in Babylon. It is the best trade off between quality
  102449. * and performances.
  102450. * @see http://doc.babylonjs.com/babylon101/materials
  102451. * @param name Define the name of the material in the scene
  102452. * @param scene Define the scene the material belong to
  102453. */
  102454. constructor(name: string, scene: Scene);
  102455. /**
  102456. * Gets a boolean indicating that current material needs to register RTT
  102457. */
  102458. readonly hasRenderTargetTextures: boolean;
  102459. /**
  102460. * Gets the current class name of the material e.g. "StandardMaterial"
  102461. * Mainly use in serialization.
  102462. * @returns the class name
  102463. */
  102464. getClassName(): string;
  102465. /**
  102466. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102467. * You can try switching to logarithmic depth.
  102468. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102469. */
  102470. useLogarithmicDepth: boolean;
  102471. /**
  102472. * Specifies if the material will require alpha blending
  102473. * @returns a boolean specifying if alpha blending is needed
  102474. */
  102475. needAlphaBlending(): boolean;
  102476. /**
  102477. * Specifies if this material should be rendered in alpha test mode
  102478. * @returns a boolean specifying if an alpha test is needed.
  102479. */
  102480. needAlphaTesting(): boolean;
  102481. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102482. /**
  102483. * Get the texture used for alpha test purpose.
  102484. * @returns the diffuse texture in case of the standard material.
  102485. */
  102486. getAlphaTestTexture(): Nullable<BaseTexture>;
  102487. /**
  102488. * Get if the submesh is ready to be used and all its information available.
  102489. * Child classes can use it to update shaders
  102490. * @param mesh defines the mesh to check
  102491. * @param subMesh defines which submesh to check
  102492. * @param useInstances specifies that instances should be used
  102493. * @returns a boolean indicating that the submesh is ready or not
  102494. */
  102495. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102496. /**
  102497. * Builds the material UBO layouts.
  102498. * Used internally during the effect preparation.
  102499. */
  102500. buildUniformLayout(): void;
  102501. /**
  102502. * Unbinds the material from the mesh
  102503. */
  102504. unbind(): void;
  102505. /**
  102506. * Binds the submesh to this material by preparing the effect and shader to draw
  102507. * @param world defines the world transformation matrix
  102508. * @param mesh defines the mesh containing the submesh
  102509. * @param subMesh defines the submesh to bind the material to
  102510. */
  102511. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102512. /**
  102513. * Get the list of animatables in the material.
  102514. * @returns the list of animatables object used in the material
  102515. */
  102516. getAnimatables(): IAnimatable[];
  102517. /**
  102518. * Gets the active textures from the material
  102519. * @returns an array of textures
  102520. */
  102521. getActiveTextures(): BaseTexture[];
  102522. /**
  102523. * Specifies if the material uses a texture
  102524. * @param texture defines the texture to check against the material
  102525. * @returns a boolean specifying if the material uses the texture
  102526. */
  102527. hasTexture(texture: BaseTexture): boolean;
  102528. /**
  102529. * Disposes the material
  102530. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102531. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102532. */
  102533. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102534. /**
  102535. * Makes a duplicate of the material, and gives it a new name
  102536. * @param name defines the new name for the duplicated material
  102537. * @returns the cloned material
  102538. */
  102539. clone(name: string): StandardMaterial;
  102540. /**
  102541. * Serializes this material in a JSON representation
  102542. * @returns the serialized material object
  102543. */
  102544. serialize(): any;
  102545. /**
  102546. * Creates a standard material from parsed material data
  102547. * @param source defines the JSON representation of the material
  102548. * @param scene defines the hosting scene
  102549. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102550. * @returns a new standard material
  102551. */
  102552. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102553. /**
  102554. * Are diffuse textures enabled in the application.
  102555. */
  102556. static DiffuseTextureEnabled: boolean;
  102557. /**
  102558. * Are ambient textures enabled in the application.
  102559. */
  102560. static AmbientTextureEnabled: boolean;
  102561. /**
  102562. * Are opacity textures enabled in the application.
  102563. */
  102564. static OpacityTextureEnabled: boolean;
  102565. /**
  102566. * Are reflection textures enabled in the application.
  102567. */
  102568. static ReflectionTextureEnabled: boolean;
  102569. /**
  102570. * Are emissive textures enabled in the application.
  102571. */
  102572. static EmissiveTextureEnabled: boolean;
  102573. /**
  102574. * Are specular textures enabled in the application.
  102575. */
  102576. static SpecularTextureEnabled: boolean;
  102577. /**
  102578. * Are bump textures enabled in the application.
  102579. */
  102580. static BumpTextureEnabled: boolean;
  102581. /**
  102582. * Are lightmap textures enabled in the application.
  102583. */
  102584. static LightmapTextureEnabled: boolean;
  102585. /**
  102586. * Are refraction textures enabled in the application.
  102587. */
  102588. static RefractionTextureEnabled: boolean;
  102589. /**
  102590. * Are color grading textures enabled in the application.
  102591. */
  102592. static ColorGradingTextureEnabled: boolean;
  102593. /**
  102594. * Are fresnels enabled in the application.
  102595. */
  102596. static FresnelEnabled: boolean;
  102597. }
  102598. }
  102599. declare module BABYLON {
  102600. /**
  102601. * A class extending Texture allowing drawing on a texture
  102602. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102603. */
  102604. export class DynamicTexture extends Texture {
  102605. private _generateMipMaps;
  102606. private _canvas;
  102607. private _context;
  102608. private _engine;
  102609. /**
  102610. * Creates a DynamicTexture
  102611. * @param name defines the name of the texture
  102612. * @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
  102613. * @param scene defines the scene where you want the texture
  102614. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102615. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102616. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102617. */
  102618. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102619. /**
  102620. * Get the current class name of the texture useful for serialization or dynamic coding.
  102621. * @returns "DynamicTexture"
  102622. */
  102623. getClassName(): string;
  102624. /**
  102625. * Gets the current state of canRescale
  102626. */
  102627. readonly canRescale: boolean;
  102628. private _recreate;
  102629. /**
  102630. * Scales the texture
  102631. * @param ratio the scale factor to apply to both width and height
  102632. */
  102633. scale(ratio: number): void;
  102634. /**
  102635. * Resizes the texture
  102636. * @param width the new width
  102637. * @param height the new height
  102638. */
  102639. scaleTo(width: number, height: number): void;
  102640. /**
  102641. * Gets the context of the canvas used by the texture
  102642. * @returns the canvas context of the dynamic texture
  102643. */
  102644. getContext(): CanvasRenderingContext2D;
  102645. /**
  102646. * Clears the texture
  102647. */
  102648. clear(): void;
  102649. /**
  102650. * Updates the texture
  102651. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102652. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102653. */
  102654. update(invertY?: boolean, premulAlpha?: boolean): void;
  102655. /**
  102656. * Draws text onto the texture
  102657. * @param text defines the text to be drawn
  102658. * @param x defines the placement of the text from the left
  102659. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102660. * @param font defines the font to be used with font-style, font-size, font-name
  102661. * @param color defines the color used for the text
  102662. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102663. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102664. * @param update defines whether texture is immediately update (default is true)
  102665. */
  102666. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102667. /**
  102668. * Clones the texture
  102669. * @returns the clone of the texture.
  102670. */
  102671. clone(): DynamicTexture;
  102672. /**
  102673. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102674. * @returns a serialized dynamic texture object
  102675. */
  102676. serialize(): any;
  102677. /** @hidden */
  102678. _rebuild(): void;
  102679. }
  102680. }
  102681. declare module BABYLON {
  102682. /** @hidden */
  102683. export var imageProcessingPixelShader: {
  102684. name: string;
  102685. shader: string;
  102686. };
  102687. }
  102688. declare module BABYLON {
  102689. /**
  102690. * ImageProcessingPostProcess
  102691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102692. */
  102693. export class ImageProcessingPostProcess extends PostProcess {
  102694. /**
  102695. * Default configuration related to image processing available in the PBR Material.
  102696. */
  102697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102698. /**
  102699. * Gets the image processing configuration used either in this material.
  102700. */
  102701. /**
  102702. * Sets the Default image processing configuration used either in the this material.
  102703. *
  102704. * If sets to null, the scene one is in use.
  102705. */
  102706. imageProcessingConfiguration: ImageProcessingConfiguration;
  102707. /**
  102708. * Keep track of the image processing observer to allow dispose and replace.
  102709. */
  102710. private _imageProcessingObserver;
  102711. /**
  102712. * Attaches a new image processing configuration to the PBR Material.
  102713. * @param configuration
  102714. */
  102715. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102716. /**
  102717. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102718. */
  102719. /**
  102720. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102721. */
  102722. colorCurves: Nullable<ColorCurves>;
  102723. /**
  102724. * Gets wether the color curves effect is enabled.
  102725. */
  102726. /**
  102727. * Sets wether the color curves effect is enabled.
  102728. */
  102729. colorCurvesEnabled: boolean;
  102730. /**
  102731. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102732. */
  102733. /**
  102734. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102735. */
  102736. colorGradingTexture: Nullable<BaseTexture>;
  102737. /**
  102738. * Gets wether the color grading effect is enabled.
  102739. */
  102740. /**
  102741. * Gets wether the color grading effect is enabled.
  102742. */
  102743. colorGradingEnabled: boolean;
  102744. /**
  102745. * Gets exposure used in the effect.
  102746. */
  102747. /**
  102748. * Sets exposure used in the effect.
  102749. */
  102750. exposure: number;
  102751. /**
  102752. * Gets wether tonemapping is enabled or not.
  102753. */
  102754. /**
  102755. * Sets wether tonemapping is enabled or not
  102756. */
  102757. toneMappingEnabled: boolean;
  102758. /**
  102759. * Gets the type of tone mapping effect.
  102760. */
  102761. /**
  102762. * Sets the type of tone mapping effect.
  102763. */
  102764. toneMappingType: number;
  102765. /**
  102766. * Gets contrast used in the effect.
  102767. */
  102768. /**
  102769. * Sets contrast used in the effect.
  102770. */
  102771. contrast: number;
  102772. /**
  102773. * Gets Vignette stretch size.
  102774. */
  102775. /**
  102776. * Sets Vignette stretch size.
  102777. */
  102778. vignetteStretch: number;
  102779. /**
  102780. * Gets Vignette centre X Offset.
  102781. */
  102782. /**
  102783. * Sets Vignette centre X Offset.
  102784. */
  102785. vignetteCentreX: number;
  102786. /**
  102787. * Gets Vignette centre Y Offset.
  102788. */
  102789. /**
  102790. * Sets Vignette centre Y Offset.
  102791. */
  102792. vignetteCentreY: number;
  102793. /**
  102794. * Gets Vignette weight or intensity of the vignette effect.
  102795. */
  102796. /**
  102797. * Sets Vignette weight or intensity of the vignette effect.
  102798. */
  102799. vignetteWeight: number;
  102800. /**
  102801. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102802. * if vignetteEnabled is set to true.
  102803. */
  102804. /**
  102805. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102806. * if vignetteEnabled is set to true.
  102807. */
  102808. vignetteColor: Color4;
  102809. /**
  102810. * Gets Camera field of view used by the Vignette effect.
  102811. */
  102812. /**
  102813. * Sets Camera field of view used by the Vignette effect.
  102814. */
  102815. vignetteCameraFov: number;
  102816. /**
  102817. * Gets the vignette blend mode allowing different kind of effect.
  102818. */
  102819. /**
  102820. * Sets the vignette blend mode allowing different kind of effect.
  102821. */
  102822. vignetteBlendMode: number;
  102823. /**
  102824. * Gets wether the vignette effect is enabled.
  102825. */
  102826. /**
  102827. * Sets wether the vignette effect is enabled.
  102828. */
  102829. vignetteEnabled: boolean;
  102830. private _fromLinearSpace;
  102831. /**
  102832. * Gets wether the input of the processing is in Gamma or Linear Space.
  102833. */
  102834. /**
  102835. * Sets wether the input of the processing is in Gamma or Linear Space.
  102836. */
  102837. fromLinearSpace: boolean;
  102838. /**
  102839. * Defines cache preventing GC.
  102840. */
  102841. private _defines;
  102842. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102843. /**
  102844. * "ImageProcessingPostProcess"
  102845. * @returns "ImageProcessingPostProcess"
  102846. */
  102847. getClassName(): string;
  102848. protected _updateParameters(): void;
  102849. dispose(camera?: Camera): void;
  102850. }
  102851. }
  102852. declare module BABYLON {
  102853. /**
  102854. * Class containing static functions to help procedurally build meshes
  102855. */
  102856. export class GroundBuilder {
  102857. /**
  102858. * Creates a ground mesh
  102859. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102860. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102862. * @param name defines the name of the mesh
  102863. * @param options defines the options used to create the mesh
  102864. * @param scene defines the hosting scene
  102865. * @returns the ground mesh
  102866. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102867. */
  102868. static CreateGround(name: string, options: {
  102869. width?: number;
  102870. height?: number;
  102871. subdivisions?: number;
  102872. subdivisionsX?: number;
  102873. subdivisionsY?: number;
  102874. updatable?: boolean;
  102875. }, scene: any): Mesh;
  102876. /**
  102877. * Creates a tiled ground mesh
  102878. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102879. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102880. * * 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
  102881. * * 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
  102882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102883. * @param name defines the name of the mesh
  102884. * @param options defines the options used to create the mesh
  102885. * @param scene defines the hosting scene
  102886. * @returns the tiled ground mesh
  102887. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102888. */
  102889. static CreateTiledGround(name: string, options: {
  102890. xmin: number;
  102891. zmin: number;
  102892. xmax: number;
  102893. zmax: number;
  102894. subdivisions?: {
  102895. w: number;
  102896. h: number;
  102897. };
  102898. precision?: {
  102899. w: number;
  102900. h: number;
  102901. };
  102902. updatable?: boolean;
  102903. }, scene?: Nullable<Scene>): Mesh;
  102904. /**
  102905. * Creates a ground mesh from a height map
  102906. * * The parameter `url` sets the URL of the height map image resource.
  102907. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102908. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102909. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102910. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102911. * * 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.
  102912. * * 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).
  102913. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102915. * @param name defines the name of the mesh
  102916. * @param url defines the url to the height map
  102917. * @param options defines the options used to create the mesh
  102918. * @param scene defines the hosting scene
  102919. * @returns the ground mesh
  102920. * @see https://doc.babylonjs.com/babylon101/height_map
  102921. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102922. */
  102923. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102924. width?: number;
  102925. height?: number;
  102926. subdivisions?: number;
  102927. minHeight?: number;
  102928. maxHeight?: number;
  102929. colorFilter?: Color3;
  102930. alphaFilter?: number;
  102931. updatable?: boolean;
  102932. onReady?: (mesh: GroundMesh) => void;
  102933. }, scene?: Nullable<Scene>): GroundMesh;
  102934. }
  102935. }
  102936. declare module BABYLON {
  102937. /**
  102938. * Class containing static functions to help procedurally build meshes
  102939. */
  102940. export class TorusBuilder {
  102941. /**
  102942. * Creates a torus mesh
  102943. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102944. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102945. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102949. * @param name defines the name of the mesh
  102950. * @param options defines the options used to create the mesh
  102951. * @param scene defines the hosting scene
  102952. * @returns the torus mesh
  102953. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102954. */
  102955. static CreateTorus(name: string, options: {
  102956. diameter?: number;
  102957. thickness?: number;
  102958. tessellation?: number;
  102959. updatable?: boolean;
  102960. sideOrientation?: number;
  102961. frontUVs?: Vector4;
  102962. backUVs?: Vector4;
  102963. }, scene: any): Mesh;
  102964. }
  102965. }
  102966. declare module BABYLON {
  102967. /**
  102968. * Class containing static functions to help procedurally build meshes
  102969. */
  102970. export class CylinderBuilder {
  102971. /**
  102972. * Creates a cylinder or a cone mesh
  102973. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102974. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102975. * * 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.
  102976. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102977. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102978. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102979. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102980. * * 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).
  102981. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102982. * * 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).
  102983. * * 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
  102984. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102985. * * 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
  102986. * * 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.
  102987. * * If `enclose` is false, a ring surface is one element.
  102988. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102989. * * 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
  102990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102993. * @param name defines the name of the mesh
  102994. * @param options defines the options used to create the mesh
  102995. * @param scene defines the hosting scene
  102996. * @returns the cylinder mesh
  102997. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102998. */
  102999. static CreateCylinder(name: string, options: {
  103000. height?: number;
  103001. diameterTop?: number;
  103002. diameterBottom?: number;
  103003. diameter?: number;
  103004. tessellation?: number;
  103005. subdivisions?: number;
  103006. arc?: number;
  103007. faceColors?: Color4[];
  103008. faceUV?: Vector4[];
  103009. updatable?: boolean;
  103010. hasRings?: boolean;
  103011. enclose?: boolean;
  103012. cap?: number;
  103013. sideOrientation?: number;
  103014. frontUVs?: Vector4;
  103015. backUVs?: Vector4;
  103016. }, scene: any): Mesh;
  103017. }
  103018. }
  103019. declare module BABYLON {
  103020. /**
  103021. * Options to modify the vr teleportation behavior.
  103022. */
  103023. export interface VRTeleportationOptions {
  103024. /**
  103025. * The name of the mesh which should be used as the teleportation floor. (default: null)
  103026. */
  103027. floorMeshName?: string;
  103028. /**
  103029. * A list of meshes to be used as the teleportation floor. (default: empty)
  103030. */
  103031. floorMeshes?: Mesh[];
  103032. }
  103033. /**
  103034. * Options to modify the vr experience helper's behavior.
  103035. */
  103036. export interface VRExperienceHelperOptions extends WebVROptions {
  103037. /**
  103038. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  103039. */
  103040. createDeviceOrientationCamera?: boolean;
  103041. /**
  103042. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  103043. */
  103044. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  103045. /**
  103046. * Uses the main button on the controller to toggle the laser casted. (default: true)
  103047. */
  103048. laserToggle?: boolean;
  103049. /**
  103050. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  103051. */
  103052. floorMeshes?: Mesh[];
  103053. /**
  103054. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  103055. */
  103056. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  103057. }
  103058. /**
  103059. * Event containing information after VR has been entered
  103060. */
  103061. export class OnAfterEnteringVRObservableEvent {
  103062. /**
  103063. * If entering vr was successful
  103064. */
  103065. success: boolean;
  103066. }
  103067. /**
  103068. * Helps to quickly add VR support to an existing scene.
  103069. * See http://doc.babylonjs.com/how_to/webvr_helper
  103070. */
  103071. export class VRExperienceHelper {
  103072. /** Options to modify the vr experience helper's behavior. */
  103073. webVROptions: VRExperienceHelperOptions;
  103074. private _scene;
  103075. private _position;
  103076. private _btnVR;
  103077. private _btnVRDisplayed;
  103078. private _webVRsupported;
  103079. private _webVRready;
  103080. private _webVRrequesting;
  103081. private _webVRpresenting;
  103082. private _hasEnteredVR;
  103083. private _fullscreenVRpresenting;
  103084. private _canvas;
  103085. private _webVRCamera;
  103086. private _vrDeviceOrientationCamera;
  103087. private _deviceOrientationCamera;
  103088. private _existingCamera;
  103089. private _onKeyDown;
  103090. private _onVrDisplayPresentChange;
  103091. private _onVRDisplayChanged;
  103092. private _onVRRequestPresentStart;
  103093. private _onVRRequestPresentComplete;
  103094. /**
  103095. * Observable raised right before entering VR.
  103096. */
  103097. onEnteringVRObservable: Observable<VRExperienceHelper>;
  103098. /**
  103099. * Observable raised when entering VR has completed.
  103100. */
  103101. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  103102. /**
  103103. * Observable raised when exiting VR.
  103104. */
  103105. onExitingVRObservable: Observable<VRExperienceHelper>;
  103106. /**
  103107. * Observable raised when controller mesh is loaded.
  103108. */
  103109. onControllerMeshLoadedObservable: Observable<WebVRController>;
  103110. /** Return this.onEnteringVRObservable
  103111. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  103112. */
  103113. readonly onEnteringVR: Observable<VRExperienceHelper>;
  103114. /** Return this.onExitingVRObservable
  103115. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  103116. */
  103117. readonly onExitingVR: Observable<VRExperienceHelper>;
  103118. /** Return this.onControllerMeshLoadedObservable
  103119. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  103120. */
  103121. readonly onControllerMeshLoaded: Observable<WebVRController>;
  103122. private _rayLength;
  103123. private _useCustomVRButton;
  103124. private _teleportationRequested;
  103125. private _teleportActive;
  103126. private _floorMeshName;
  103127. private _floorMeshesCollection;
  103128. private _rotationAllowed;
  103129. private _teleportBackwardsVector;
  103130. private _teleportationTarget;
  103131. private _isDefaultTeleportationTarget;
  103132. private _postProcessMove;
  103133. private _teleportationFillColor;
  103134. private _teleportationBorderColor;
  103135. private _rotationAngle;
  103136. private _haloCenter;
  103137. private _cameraGazer;
  103138. private _padSensibilityUp;
  103139. private _padSensibilityDown;
  103140. private _leftController;
  103141. private _rightController;
  103142. /**
  103143. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  103144. */
  103145. onNewMeshSelected: Observable<AbstractMesh>;
  103146. /**
  103147. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  103148. */
  103149. onNewMeshPicked: Observable<PickingInfo>;
  103150. private _circleEase;
  103151. /**
  103152. * Observable raised before camera teleportation
  103153. */
  103154. onBeforeCameraTeleport: Observable<Vector3>;
  103155. /**
  103156. * Observable raised after camera teleportation
  103157. */
  103158. onAfterCameraTeleport: Observable<Vector3>;
  103159. /**
  103160. * Observable raised when current selected mesh gets unselected
  103161. */
  103162. onSelectedMeshUnselected: Observable<AbstractMesh>;
  103163. private _raySelectionPredicate;
  103164. /**
  103165. * To be optionaly changed by user to define custom ray selection
  103166. */
  103167. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  103168. /**
  103169. * To be optionaly changed by user to define custom selection logic (after ray selection)
  103170. */
  103171. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103172. /**
  103173. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  103174. */
  103175. teleportationEnabled: boolean;
  103176. private _defaultHeight;
  103177. private _teleportationInitialized;
  103178. private _interactionsEnabled;
  103179. private _interactionsRequested;
  103180. private _displayGaze;
  103181. private _displayLaserPointer;
  103182. /**
  103183. * The mesh used to display where the user is going to teleport.
  103184. */
  103185. /**
  103186. * Sets the mesh to be used to display where the user is going to teleport.
  103187. */
  103188. teleportationTarget: Mesh;
  103189. /**
  103190. * 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
  103191. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  103192. * See http://doc.babylonjs.com/resources/baking_transformations
  103193. */
  103194. gazeTrackerMesh: Mesh;
  103195. /**
  103196. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  103197. */
  103198. updateGazeTrackerScale: boolean;
  103199. /**
  103200. * If the gaze trackers color should be updated when selecting meshes
  103201. */
  103202. updateGazeTrackerColor: boolean;
  103203. /**
  103204. * The gaze tracking mesh corresponding to the left controller
  103205. */
  103206. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  103207. /**
  103208. * The gaze tracking mesh corresponding to the right controller
  103209. */
  103210. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  103211. /**
  103212. * If the ray of the gaze should be displayed.
  103213. */
  103214. /**
  103215. * Sets if the ray of the gaze should be displayed.
  103216. */
  103217. displayGaze: boolean;
  103218. /**
  103219. * If the ray of the LaserPointer should be displayed.
  103220. */
  103221. /**
  103222. * Sets if the ray of the LaserPointer should be displayed.
  103223. */
  103224. displayLaserPointer: boolean;
  103225. /**
  103226. * The deviceOrientationCamera used as the camera when not in VR.
  103227. */
  103228. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  103229. /**
  103230. * Based on the current WebVR support, returns the current VR camera used.
  103231. */
  103232. readonly currentVRCamera: Nullable<Camera>;
  103233. /**
  103234. * The webVRCamera which is used when in VR.
  103235. */
  103236. readonly webVRCamera: WebVRFreeCamera;
  103237. /**
  103238. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  103239. */
  103240. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  103241. private readonly _teleportationRequestInitiated;
  103242. /**
  103243. * Defines wether or not Pointer lock should be requested when switching to
  103244. * full screen.
  103245. */
  103246. requestPointerLockOnFullScreen: boolean;
  103247. /**
  103248. * Instantiates a VRExperienceHelper.
  103249. * Helps to quickly add VR support to an existing scene.
  103250. * @param scene The scene the VRExperienceHelper belongs to.
  103251. * @param webVROptions Options to modify the vr experience helper's behavior.
  103252. */
  103253. constructor(scene: Scene,
  103254. /** Options to modify the vr experience helper's behavior. */
  103255. webVROptions?: VRExperienceHelperOptions);
  103256. private _onDefaultMeshLoaded;
  103257. private _onResize;
  103258. private _onFullscreenChange;
  103259. /**
  103260. * Gets a value indicating if we are currently in VR mode.
  103261. */
  103262. readonly isInVRMode: boolean;
  103263. private onVrDisplayPresentChange;
  103264. private onVRDisplayChanged;
  103265. private moveButtonToBottomRight;
  103266. private displayVRButton;
  103267. private updateButtonVisibility;
  103268. private _cachedAngularSensibility;
  103269. /**
  103270. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  103271. * Otherwise, will use the fullscreen API.
  103272. */
  103273. enterVR(): void;
  103274. /**
  103275. * Attempt to exit VR, or fullscreen.
  103276. */
  103277. exitVR(): void;
  103278. /**
  103279. * The position of the vr experience helper.
  103280. */
  103281. /**
  103282. * Sets the position of the vr experience helper.
  103283. */
  103284. position: Vector3;
  103285. /**
  103286. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  103287. */
  103288. enableInteractions(): void;
  103289. private readonly _noControllerIsActive;
  103290. private beforeRender;
  103291. private _isTeleportationFloor;
  103292. /**
  103293. * Adds a floor mesh to be used for teleportation.
  103294. * @param floorMesh the mesh to be used for teleportation.
  103295. */
  103296. addFloorMesh(floorMesh: Mesh): void;
  103297. /**
  103298. * Removes a floor mesh from being used for teleportation.
  103299. * @param floorMesh the mesh to be removed.
  103300. */
  103301. removeFloorMesh(floorMesh: Mesh): void;
  103302. /**
  103303. * Enables interactions and teleportation using the VR controllers and gaze.
  103304. * @param vrTeleportationOptions options to modify teleportation behavior.
  103305. */
  103306. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103307. private _onNewGamepadConnected;
  103308. private _tryEnableInteractionOnController;
  103309. private _onNewGamepadDisconnected;
  103310. private _enableInteractionOnController;
  103311. private _checkTeleportWithRay;
  103312. private _checkRotate;
  103313. private _checkTeleportBackwards;
  103314. private _enableTeleportationOnController;
  103315. private _createTeleportationCircles;
  103316. private _displayTeleportationTarget;
  103317. private _hideTeleportationTarget;
  103318. private _rotateCamera;
  103319. private _moveTeleportationSelectorTo;
  103320. private _workingVector;
  103321. private _workingQuaternion;
  103322. private _workingMatrix;
  103323. /**
  103324. * Teleports the users feet to the desired location
  103325. * @param location The location where the user's feet should be placed
  103326. */
  103327. teleportCamera(location: Vector3): void;
  103328. private _convertNormalToDirectionOfRay;
  103329. private _castRayAndSelectObject;
  103330. private _notifySelectedMeshUnselected;
  103331. /**
  103332. * Sets the color of the laser ray from the vr controllers.
  103333. * @param color new color for the ray.
  103334. */
  103335. changeLaserColor(color: Color3): void;
  103336. /**
  103337. * Sets the color of the ray from the vr headsets gaze.
  103338. * @param color new color for the ray.
  103339. */
  103340. changeGazeColor(color: Color3): void;
  103341. /**
  103342. * Exits VR and disposes of the vr experience helper
  103343. */
  103344. dispose(): void;
  103345. /**
  103346. * Gets the name of the VRExperienceHelper class
  103347. * @returns "VRExperienceHelper"
  103348. */
  103349. getClassName(): string;
  103350. }
  103351. }
  103352. declare module BABYLON {
  103353. /**
  103354. * Manages an XRSession
  103355. * @see https://doc.babylonjs.com/how_to/webxr
  103356. */
  103357. export class WebXRSessionManager implements IDisposable {
  103358. private scene;
  103359. /**
  103360. * Fires every time a new xrFrame arrives which can be used to update the camera
  103361. */
  103362. onXRFrameObservable: Observable<any>;
  103363. /**
  103364. * Fires when the xr session is ended either by the device or manually done
  103365. */
  103366. onXRSessionEnded: Observable<any>;
  103367. /** @hidden */
  103368. _xrSession: XRSession;
  103369. /** @hidden */
  103370. _frameOfReference: XRFrameOfReference;
  103371. /** @hidden */
  103372. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103373. /** @hidden */
  103374. _currentXRFrame: Nullable<XRFrame>;
  103375. private _xrNavigator;
  103376. private _xrDevice;
  103377. private _tmpMatrix;
  103378. /**
  103379. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103380. * @param scene The scene which the session should be created for
  103381. */
  103382. constructor(scene: Scene);
  103383. /**
  103384. * Initializes the manager
  103385. * After initialization enterXR can be called to start an XR session
  103386. * @returns Promise which resolves after it is initialized
  103387. */
  103388. initializeAsync(): Promise<void>;
  103389. /**
  103390. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  103391. * @param sessionCreationOptions xr options to create the session with
  103392. * @param frameOfReferenceType option to configure how the xr pose is expressed
  103393. * @returns Promise which resolves after it enters XR
  103394. */
  103395. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  103396. /**
  103397. * Stops the xrSession and restores the renderloop
  103398. * @returns Promise which resolves after it exits XR
  103399. */
  103400. exitXRAsync(): Promise<void>;
  103401. /**
  103402. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103403. * @param ray ray to cast into the environment
  103404. * @returns Promise which resolves with a collision point in the environment if it exists
  103405. */
  103406. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103407. /**
  103408. * Checks if a session would be supported for the creation options specified
  103409. * @param options creation options to check if they are supported
  103410. * @returns true if supported
  103411. */
  103412. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103413. /**
  103414. * @hidden
  103415. * Converts the render layer of xrSession to a render target
  103416. * @param session session to create render target for
  103417. * @param scene scene the new render target should be created for
  103418. */
  103419. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  103420. /**
  103421. * Disposes of the session manager
  103422. */
  103423. dispose(): void;
  103424. }
  103425. }
  103426. declare module BABYLON {
  103427. /**
  103428. * WebXR Camera which holds the views for the xrSession
  103429. * @see https://doc.babylonjs.com/how_to/webxr
  103430. */
  103431. export class WebXRCamera extends FreeCamera {
  103432. private static _TmpMatrix;
  103433. /**
  103434. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103435. * @param name the name of the camera
  103436. * @param scene the scene to add the camera to
  103437. */
  103438. constructor(name: string, scene: Scene);
  103439. private _updateNumberOfRigCameras;
  103440. /** @hidden */
  103441. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103442. /**
  103443. * Updates the cameras position from the current pose information of the XR session
  103444. * @param xrSessionManager the session containing pose information
  103445. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103446. */
  103447. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103448. }
  103449. }
  103450. declare module BABYLON {
  103451. /**
  103452. * States of the webXR experience
  103453. */
  103454. export enum WebXRState {
  103455. /**
  103456. * Transitioning to being in XR mode
  103457. */
  103458. ENTERING_XR = 0,
  103459. /**
  103460. * Transitioning to non XR mode
  103461. */
  103462. EXITING_XR = 1,
  103463. /**
  103464. * In XR mode and presenting
  103465. */
  103466. IN_XR = 2,
  103467. /**
  103468. * Not entered XR mode
  103469. */
  103470. NOT_IN_XR = 3
  103471. }
  103472. /**
  103473. * Helper class used to enable XR
  103474. * @see https://doc.babylonjs.com/how_to/webxr
  103475. */
  103476. export class WebXRExperienceHelper implements IDisposable {
  103477. private scene;
  103478. /**
  103479. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  103480. */
  103481. container: AbstractMesh;
  103482. /**
  103483. * Camera used to render xr content
  103484. */
  103485. camera: WebXRCamera;
  103486. /**
  103487. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103488. */
  103489. state: WebXRState;
  103490. private _setState;
  103491. private static _TmpVector;
  103492. /**
  103493. * Fires when the state of the experience helper has changed
  103494. */
  103495. onStateChangedObservable: Observable<WebXRState>;
  103496. /** @hidden */
  103497. _sessionManager: WebXRSessionManager;
  103498. private _nonVRCamera;
  103499. private _originalSceneAutoClear;
  103500. private _supported;
  103501. /**
  103502. * Creates the experience helper
  103503. * @param scene the scene to attach the experience helper to
  103504. * @returns a promise for the experience helper
  103505. */
  103506. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103507. /**
  103508. * Creates a WebXRExperienceHelper
  103509. * @param scene The scene the helper should be created in
  103510. */
  103511. private constructor();
  103512. /**
  103513. * Exits XR mode and returns the scene to its original state
  103514. * @returns promise that resolves after xr mode has exited
  103515. */
  103516. exitXRAsync(): Promise<void>;
  103517. /**
  103518. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103519. * @param sessionCreationOptions options for the XR session
  103520. * @param frameOfReference frame of reference of the XR session
  103521. * @returns promise that resolves after xr mode has entered
  103522. */
  103523. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  103524. /**
  103525. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103526. * @param ray ray to cast into the environment
  103527. * @returns Promise which resolves with a collision point in the environment if it exists
  103528. */
  103529. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103530. /**
  103531. * Updates the global position of the camera by moving the camera's container
  103532. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103533. * @param position The desired global position of the camera
  103534. */
  103535. setPositionOfCameraUsingContainer(position: Vector3): void;
  103536. /**
  103537. * Rotates the xr camera by rotating the camera's container around the camera's position
  103538. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103539. * @param rotation the desired quaternion rotation to apply to the camera
  103540. */
  103541. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103542. /**
  103543. * Checks if the creation options are supported by the xr session
  103544. * @param options creation options
  103545. * @returns true if supported
  103546. */
  103547. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103548. /**
  103549. * Disposes of the experience helper
  103550. */
  103551. dispose(): void;
  103552. }
  103553. }
  103554. declare module BABYLON {
  103555. /**
  103556. * Button which can be used to enter a different mode of XR
  103557. */
  103558. export class WebXREnterExitUIButton {
  103559. /** button element */
  103560. element: HTMLElement;
  103561. /** XR initialization options for the button */
  103562. initializationOptions: XRSessionCreationOptions;
  103563. /**
  103564. * Creates a WebXREnterExitUIButton
  103565. * @param element button element
  103566. * @param initializationOptions XR initialization options for the button
  103567. */
  103568. constructor(
  103569. /** button element */
  103570. element: HTMLElement,
  103571. /** XR initialization options for the button */
  103572. initializationOptions: XRSessionCreationOptions);
  103573. /**
  103574. * Overwritable function which can be used to update the button's visuals when the state changes
  103575. * @param activeButton the current active button in the UI
  103576. */
  103577. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103578. }
  103579. /**
  103580. * Options to create the webXR UI
  103581. */
  103582. export class WebXREnterExitUIOptions {
  103583. /**
  103584. * Context to enter xr with
  103585. */
  103586. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103587. /**
  103588. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103589. */
  103590. customButtons?: Array<WebXREnterExitUIButton>;
  103591. }
  103592. /**
  103593. * UI to allow the user to enter/exit XR mode
  103594. */
  103595. export class WebXREnterExitUI implements IDisposable {
  103596. private scene;
  103597. private _overlay;
  103598. private _buttons;
  103599. private _activeButton;
  103600. /**
  103601. * Fired every time the active button is changed.
  103602. *
  103603. * When xr is entered via a button that launches xr that button will be the callback parameter
  103604. *
  103605. * When exiting xr the callback parameter will be null)
  103606. */
  103607. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103608. /**
  103609. * Creates UI to allow the user to enter/exit XR mode
  103610. * @param scene the scene to add the ui to
  103611. * @param helper the xr experience helper to enter/exit xr with
  103612. * @param options options to configure the UI
  103613. * @returns the created ui
  103614. */
  103615. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103616. private constructor();
  103617. private _updateButtons;
  103618. /**
  103619. * Disposes of the object
  103620. */
  103621. dispose(): void;
  103622. }
  103623. }
  103624. declare module BABYLON {
  103625. /**
  103626. * Represents an XR input
  103627. */
  103628. export class WebXRController {
  103629. /**
  103630. * 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
  103631. */
  103632. grip?: AbstractMesh;
  103633. /**
  103634. * Pointer which can be used to select objects or attach a visible laser to
  103635. */
  103636. pointer: AbstractMesh;
  103637. /**
  103638. * Creates the controller
  103639. * @see https://doc.babylonjs.com/how_to/webxr
  103640. * @param scene the scene which the controller should be associated to
  103641. */
  103642. constructor(scene: Scene);
  103643. /**
  103644. * Disposes of the object
  103645. */
  103646. dispose(): void;
  103647. }
  103648. /**
  103649. * XR input used to track XR inputs such as controllers/rays
  103650. */
  103651. export class WebXRInput implements IDisposable {
  103652. private helper;
  103653. /**
  103654. * XR controllers being tracked
  103655. */
  103656. controllers: Array<WebXRController>;
  103657. private _tmpMatrix;
  103658. private _frameObserver;
  103659. /**
  103660. * Initializes the WebXRInput
  103661. * @param helper experience helper which the input should be created for
  103662. */
  103663. constructor(helper: WebXRExperienceHelper);
  103664. /**
  103665. * Disposes of the object
  103666. */
  103667. dispose(): void;
  103668. }
  103669. }
  103670. declare module BABYLON {
  103671. /**
  103672. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103673. */
  103674. export class WebXRManagedOutputCanvas implements IDisposable {
  103675. private _canvas;
  103676. /**
  103677. * xrpresent context of the canvas which can be used to display/mirror xr content
  103678. */
  103679. canvasContext: Nullable<WebGLRenderingContext>;
  103680. /**
  103681. * Initializes the canvas to be added/removed upon entering/exiting xr
  103682. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103683. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103684. */
  103685. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103686. /**
  103687. * Disposes of the object
  103688. */
  103689. dispose(): void;
  103690. private _setManagedOutputCanvas;
  103691. private _addCanvas;
  103692. private _removeCanvas;
  103693. }
  103694. }
  103695. declare module BABYLON {
  103696. /**
  103697. * Contains an array of blocks representing the octree
  103698. */
  103699. export interface IOctreeContainer<T> {
  103700. /**
  103701. * Blocks within the octree
  103702. */
  103703. blocks: Array<OctreeBlock<T>>;
  103704. }
  103705. /**
  103706. * Class used to store a cell in an octree
  103707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103708. */
  103709. export class OctreeBlock<T> {
  103710. /**
  103711. * Gets the content of the current block
  103712. */
  103713. entries: T[];
  103714. /**
  103715. * Gets the list of block children
  103716. */
  103717. blocks: Array<OctreeBlock<T>>;
  103718. private _depth;
  103719. private _maxDepth;
  103720. private _capacity;
  103721. private _minPoint;
  103722. private _maxPoint;
  103723. private _boundingVectors;
  103724. private _creationFunc;
  103725. /**
  103726. * Creates a new block
  103727. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103728. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103729. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103730. * @param depth defines the current depth of this block in the octree
  103731. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103732. * @param creationFunc defines a callback to call when an element is added to the block
  103733. */
  103734. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103735. /**
  103736. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103737. */
  103738. readonly capacity: number;
  103739. /**
  103740. * Gets the minimum vector (in world space) of the block's bounding box
  103741. */
  103742. readonly minPoint: Vector3;
  103743. /**
  103744. * Gets the maximum vector (in world space) of the block's bounding box
  103745. */
  103746. readonly maxPoint: Vector3;
  103747. /**
  103748. * Add a new element to this block
  103749. * @param entry defines the element to add
  103750. */
  103751. addEntry(entry: T): void;
  103752. /**
  103753. * Remove an element from this block
  103754. * @param entry defines the element to remove
  103755. */
  103756. removeEntry(entry: T): void;
  103757. /**
  103758. * Add an array of elements to this block
  103759. * @param entries defines the array of elements to add
  103760. */
  103761. addEntries(entries: T[]): void;
  103762. /**
  103763. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103764. * @param frustumPlanes defines the frustum planes to test
  103765. * @param selection defines the array to store current content if selection is positive
  103766. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103767. */
  103768. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103769. /**
  103770. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103771. * @param sphereCenter defines the bounding sphere center
  103772. * @param sphereRadius defines the bounding sphere radius
  103773. * @param selection defines the array to store current content if selection is positive
  103774. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103775. */
  103776. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103777. /**
  103778. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103779. * @param ray defines the ray to test with
  103780. * @param selection defines the array to store current content if selection is positive
  103781. */
  103782. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103783. /**
  103784. * Subdivide the content into child blocks (this block will then be empty)
  103785. */
  103786. createInnerBlocks(): void;
  103787. /**
  103788. * @hidden
  103789. */
  103790. 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;
  103791. }
  103792. }
  103793. declare module BABYLON {
  103794. /**
  103795. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103796. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103797. */
  103798. export class Octree<T> {
  103799. /** 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.) */
  103800. maxDepth: number;
  103801. /**
  103802. * Blocks within the octree containing objects
  103803. */
  103804. blocks: Array<OctreeBlock<T>>;
  103805. /**
  103806. * Content stored in the octree
  103807. */
  103808. dynamicContent: T[];
  103809. private _maxBlockCapacity;
  103810. private _selectionContent;
  103811. private _creationFunc;
  103812. /**
  103813. * Creates a octree
  103814. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103815. * @param creationFunc function to be used to instatiate the octree
  103816. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103817. * @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.)
  103818. */
  103819. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103820. /** 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.) */
  103821. maxDepth?: number);
  103822. /**
  103823. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103824. * @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);
  103825. * @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);
  103826. * @param entries meshes to be added to the octree blocks
  103827. */
  103828. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103829. /**
  103830. * Adds a mesh to the octree
  103831. * @param entry Mesh to add to the octree
  103832. */
  103833. addMesh(entry: T): void;
  103834. /**
  103835. * Remove an element from the octree
  103836. * @param entry defines the element to remove
  103837. */
  103838. removeMesh(entry: T): void;
  103839. /**
  103840. * Selects an array of meshes within the frustum
  103841. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103842. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103843. * @returns array of meshes within the frustum
  103844. */
  103845. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103846. /**
  103847. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103848. * @param sphereCenter defines the bounding sphere center
  103849. * @param sphereRadius defines the bounding sphere radius
  103850. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103851. * @returns an array of objects that intersect the sphere
  103852. */
  103853. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103854. /**
  103855. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103856. * @param ray defines the ray to test with
  103857. * @returns array of intersected objects
  103858. */
  103859. intersectsRay(ray: Ray): SmartArray<T>;
  103860. /**
  103861. * Adds a mesh into the octree block if it intersects the block
  103862. */
  103863. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103864. /**
  103865. * Adds a submesh into the octree block if it intersects the block
  103866. */
  103867. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103868. }
  103869. }
  103870. declare module BABYLON {
  103871. interface Scene {
  103872. /**
  103873. * @hidden
  103874. * Backing Filed
  103875. */
  103876. _selectionOctree: Octree<AbstractMesh>;
  103877. /**
  103878. * Gets the octree used to boost mesh selection (picking)
  103879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103880. */
  103881. selectionOctree: Octree<AbstractMesh>;
  103882. /**
  103883. * Creates or updates the octree used to boost selection (picking)
  103884. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103885. * @param maxCapacity defines the maximum capacity per leaf
  103886. * @param maxDepth defines the maximum depth of the octree
  103887. * @returns an octree of AbstractMesh
  103888. */
  103889. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103890. }
  103891. interface AbstractMesh {
  103892. /**
  103893. * @hidden
  103894. * Backing Field
  103895. */
  103896. _submeshesOctree: Octree<SubMesh>;
  103897. /**
  103898. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103899. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103900. * @param maxCapacity defines the maximum size of each block (64 by default)
  103901. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103902. * @returns the new octree
  103903. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103904. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103905. */
  103906. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103907. }
  103908. /**
  103909. * Defines the octree scene component responsible to manage any octrees
  103910. * in a given scene.
  103911. */
  103912. export class OctreeSceneComponent {
  103913. /**
  103914. * The component name help to identify the component in the list of scene components.
  103915. */
  103916. readonly name: string;
  103917. /**
  103918. * The scene the component belongs to.
  103919. */
  103920. scene: Scene;
  103921. /**
  103922. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103923. */
  103924. readonly checksIsEnabled: boolean;
  103925. /**
  103926. * Creates a new instance of the component for the given scene
  103927. * @param scene Defines the scene to register the component in
  103928. */
  103929. constructor(scene: Scene);
  103930. /**
  103931. * Registers the component in a given scene
  103932. */
  103933. register(): void;
  103934. /**
  103935. * Return the list of active meshes
  103936. * @returns the list of active meshes
  103937. */
  103938. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103939. /**
  103940. * Return the list of active sub meshes
  103941. * @param mesh The mesh to get the candidates sub meshes from
  103942. * @returns the list of active sub meshes
  103943. */
  103944. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103945. private _tempRay;
  103946. /**
  103947. * Return the list of sub meshes intersecting with a given local ray
  103948. * @param mesh defines the mesh to find the submesh for
  103949. * @param localRay defines the ray in local space
  103950. * @returns the list of intersecting sub meshes
  103951. */
  103952. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103953. /**
  103954. * Return the list of sub meshes colliding with a collider
  103955. * @param mesh defines the mesh to find the submesh for
  103956. * @param collider defines the collider to evaluate the collision against
  103957. * @returns the list of colliding sub meshes
  103958. */
  103959. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103960. /**
  103961. * Rebuilds the elements related to this component in case of
  103962. * context lost for instance.
  103963. */
  103964. rebuild(): void;
  103965. /**
  103966. * Disposes the component and the associated ressources.
  103967. */
  103968. dispose(): void;
  103969. }
  103970. }
  103971. declare module BABYLON {
  103972. /**
  103973. * Renders a layer on top of an existing scene
  103974. */
  103975. export class UtilityLayerRenderer implements IDisposable {
  103976. /** the original scene that will be rendered on top of */
  103977. originalScene: Scene;
  103978. private _pointerCaptures;
  103979. private _lastPointerEvents;
  103980. private static _DefaultUtilityLayer;
  103981. private static _DefaultKeepDepthUtilityLayer;
  103982. private _sharedGizmoLight;
  103983. private _renderCamera;
  103984. /**
  103985. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103986. * @returns the camera that is used when rendering the utility layer
  103987. */
  103988. getRenderCamera(): Nullable<Camera>;
  103989. /**
  103990. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103991. * @param cam the camera that should be used when rendering the utility layer
  103992. */
  103993. setRenderCamera(cam: Nullable<Camera>): void;
  103994. /**
  103995. * @hidden
  103996. * Light which used by gizmos to get light shading
  103997. */
  103998. _getSharedGizmoLight(): HemisphericLight;
  103999. /**
  104000. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  104001. */
  104002. pickUtilitySceneFirst: boolean;
  104003. /**
  104004. * 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)
  104005. */
  104006. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  104007. /**
  104008. * 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)
  104009. */
  104010. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  104011. /**
  104012. * The scene that is rendered on top of the original scene
  104013. */
  104014. utilityLayerScene: Scene;
  104015. /**
  104016. * If the utility layer should automatically be rendered on top of existing scene
  104017. */
  104018. shouldRender: boolean;
  104019. /**
  104020. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  104021. */
  104022. onlyCheckPointerDownEvents: boolean;
  104023. /**
  104024. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  104025. */
  104026. processAllEvents: boolean;
  104027. /**
  104028. * Observable raised when the pointer move from the utility layer scene to the main scene
  104029. */
  104030. onPointerOutObservable: Observable<number>;
  104031. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  104032. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  104033. private _afterRenderObserver;
  104034. private _sceneDisposeObserver;
  104035. private _originalPointerObserver;
  104036. /**
  104037. * Instantiates a UtilityLayerRenderer
  104038. * @param originalScene the original scene that will be rendered on top of
  104039. * @param handleEvents boolean indicating if the utility layer should handle events
  104040. */
  104041. constructor(
  104042. /** the original scene that will be rendered on top of */
  104043. originalScene: Scene, handleEvents?: boolean);
  104044. private _notifyObservers;
  104045. /**
  104046. * Renders the utility layers scene on top of the original scene
  104047. */
  104048. render(): void;
  104049. /**
  104050. * Disposes of the renderer
  104051. */
  104052. dispose(): void;
  104053. private _updateCamera;
  104054. }
  104055. }
  104056. declare module BABYLON {
  104057. /**
  104058. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  104059. */
  104060. export class Gizmo implements IDisposable {
  104061. /** The utility layer the gizmo will be added to */
  104062. gizmoLayer: UtilityLayerRenderer;
  104063. /**
  104064. * The root mesh of the gizmo
  104065. */
  104066. _rootMesh: Mesh;
  104067. private _attachedMesh;
  104068. /**
  104069. * Ratio for the scale of the gizmo (Default: 1)
  104070. */
  104071. scaleRatio: number;
  104072. /**
  104073. * If a custom mesh has been set (Default: false)
  104074. */
  104075. protected _customMeshSet: boolean;
  104076. /**
  104077. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  104078. * * When set, interactions will be enabled
  104079. */
  104080. attachedMesh: Nullable<AbstractMesh>;
  104081. /**
  104082. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  104083. * @param mesh The mesh to replace the default mesh of the gizmo
  104084. */
  104085. setCustomMesh(mesh: Mesh): void;
  104086. /**
  104087. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  104088. */
  104089. updateGizmoRotationToMatchAttachedMesh: boolean;
  104090. /**
  104091. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  104092. */
  104093. updateGizmoPositionToMatchAttachedMesh: boolean;
  104094. /**
  104095. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  104096. */
  104097. protected _updateScale: boolean;
  104098. protected _interactionsEnabled: boolean;
  104099. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104100. private _beforeRenderObserver;
  104101. private _tempVector;
  104102. /**
  104103. * Creates a gizmo
  104104. * @param gizmoLayer The utility layer the gizmo will be added to
  104105. */
  104106. constructor(
  104107. /** The utility layer the gizmo will be added to */
  104108. gizmoLayer?: UtilityLayerRenderer);
  104109. /**
  104110. * Updates the gizmo to match the attached mesh's position/rotation
  104111. */
  104112. protected _update(): void;
  104113. /**
  104114. * Disposes of the gizmo
  104115. */
  104116. dispose(): void;
  104117. }
  104118. }
  104119. declare module BABYLON {
  104120. /**
  104121. * Single plane drag gizmo
  104122. */
  104123. export class PlaneDragGizmo extends Gizmo {
  104124. /**
  104125. * Drag behavior responsible for the gizmos dragging interactions
  104126. */
  104127. dragBehavior: PointerDragBehavior;
  104128. private _pointerObserver;
  104129. /**
  104130. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104131. */
  104132. snapDistance: number;
  104133. /**
  104134. * Event that fires each time the gizmo snaps to a new location.
  104135. * * snapDistance is the the change in distance
  104136. */
  104137. onSnapObservable: Observable<{
  104138. snapDistance: number;
  104139. }>;
  104140. private _plane;
  104141. private _coloredMaterial;
  104142. private _hoverMaterial;
  104143. private _isEnabled;
  104144. private _parent;
  104145. /** @hidden */
  104146. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  104147. /** @hidden */
  104148. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104149. /**
  104150. * Creates a PlaneDragGizmo
  104151. * @param gizmoLayer The utility layer the gizmo will be added to
  104152. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  104153. * @param color The color of the gizmo
  104154. */
  104155. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104156. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104157. /**
  104158. * If the gizmo is enabled
  104159. */
  104160. isEnabled: boolean;
  104161. /**
  104162. * Disposes of the gizmo
  104163. */
  104164. dispose(): void;
  104165. }
  104166. }
  104167. declare module BABYLON {
  104168. /**
  104169. * Gizmo that enables dragging a mesh along 3 axis
  104170. */
  104171. export class PositionGizmo extends Gizmo {
  104172. /**
  104173. * Internal gizmo used for interactions on the x axis
  104174. */
  104175. xGizmo: AxisDragGizmo;
  104176. /**
  104177. * Internal gizmo used for interactions on the y axis
  104178. */
  104179. yGizmo: AxisDragGizmo;
  104180. /**
  104181. * Internal gizmo used for interactions on the z axis
  104182. */
  104183. zGizmo: AxisDragGizmo;
  104184. /**
  104185. * Internal gizmo used for interactions on the yz plane
  104186. */
  104187. xPlaneGizmo: PlaneDragGizmo;
  104188. /**
  104189. * Internal gizmo used for interactions on the xz plane
  104190. */
  104191. yPlaneGizmo: PlaneDragGizmo;
  104192. /**
  104193. * Internal gizmo used for interactions on the xy plane
  104194. */
  104195. zPlaneGizmo: PlaneDragGizmo;
  104196. /**
  104197. * private variables
  104198. */
  104199. private _meshAttached;
  104200. private _updateGizmoRotationToMatchAttachedMesh;
  104201. private _snapDistance;
  104202. private _scaleRatio;
  104203. /** Fires an event when any of it's sub gizmos are dragged */
  104204. onDragStartObservable: Observable<unknown>;
  104205. /** Fires an event when any of it's sub gizmos are released from dragging */
  104206. onDragEndObservable: Observable<unknown>;
  104207. /**
  104208. * If set to true, planar drag is enabled
  104209. */
  104210. private _planarGizmoEnabled;
  104211. attachedMesh: Nullable<AbstractMesh>;
  104212. /**
  104213. * Creates a PositionGizmo
  104214. * @param gizmoLayer The utility layer the gizmo will be added to
  104215. */
  104216. constructor(gizmoLayer?: UtilityLayerRenderer);
  104217. /**
  104218. * If the planar drag gizmo is enabled
  104219. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  104220. */
  104221. planarGizmoEnabled: boolean;
  104222. updateGizmoRotationToMatchAttachedMesh: boolean;
  104223. /**
  104224. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104225. */
  104226. snapDistance: number;
  104227. /**
  104228. * Ratio for the scale of the gizmo (Default: 1)
  104229. */
  104230. scaleRatio: number;
  104231. /**
  104232. * Disposes of the gizmo
  104233. */
  104234. dispose(): void;
  104235. /**
  104236. * CustomMeshes are not supported by this gizmo
  104237. * @param mesh The mesh to replace the default mesh of the gizmo
  104238. */
  104239. setCustomMesh(mesh: Mesh): void;
  104240. }
  104241. }
  104242. declare module BABYLON {
  104243. /**
  104244. * Single axis drag gizmo
  104245. */
  104246. export class AxisDragGizmo extends Gizmo {
  104247. /**
  104248. * Drag behavior responsible for the gizmos dragging interactions
  104249. */
  104250. dragBehavior: PointerDragBehavior;
  104251. private _pointerObserver;
  104252. /**
  104253. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104254. */
  104255. snapDistance: number;
  104256. /**
  104257. * Event that fires each time the gizmo snaps to a new location.
  104258. * * snapDistance is the the change in distance
  104259. */
  104260. onSnapObservable: Observable<{
  104261. snapDistance: number;
  104262. }>;
  104263. private _isEnabled;
  104264. private _parent;
  104265. private _arrow;
  104266. private _coloredMaterial;
  104267. private _hoverMaterial;
  104268. /** @hidden */
  104269. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  104270. /** @hidden */
  104271. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104272. /**
  104273. * Creates an AxisDragGizmo
  104274. * @param gizmoLayer The utility layer the gizmo will be added to
  104275. * @param dragAxis The axis which the gizmo will be able to drag on
  104276. * @param color The color of the gizmo
  104277. */
  104278. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104279. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104280. /**
  104281. * If the gizmo is enabled
  104282. */
  104283. isEnabled: boolean;
  104284. /**
  104285. * Disposes of the gizmo
  104286. */
  104287. dispose(): void;
  104288. }
  104289. }
  104290. declare module BABYLON.Debug {
  104291. /**
  104292. * The Axes viewer will show 3 axes in a specific point in space
  104293. */
  104294. export class AxesViewer {
  104295. private _xAxis;
  104296. private _yAxis;
  104297. private _zAxis;
  104298. private _scaleLinesFactor;
  104299. private _instanced;
  104300. /**
  104301. * Gets the hosting scene
  104302. */
  104303. scene: Scene;
  104304. /**
  104305. * Gets or sets a number used to scale line length
  104306. */
  104307. scaleLines: number;
  104308. /** Gets the node hierarchy used to render x-axis */
  104309. readonly xAxis: TransformNode;
  104310. /** Gets the node hierarchy used to render y-axis */
  104311. readonly yAxis: TransformNode;
  104312. /** Gets the node hierarchy used to render z-axis */
  104313. readonly zAxis: TransformNode;
  104314. /**
  104315. * Creates a new AxesViewer
  104316. * @param scene defines the hosting scene
  104317. * @param scaleLines defines a number used to scale line length (1 by default)
  104318. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  104319. * @param xAxis defines the node hierarchy used to render the x-axis
  104320. * @param yAxis defines the node hierarchy used to render the y-axis
  104321. * @param zAxis defines the node hierarchy used to render the z-axis
  104322. */
  104323. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  104324. /**
  104325. * Force the viewer to update
  104326. * @param position defines the position of the viewer
  104327. * @param xaxis defines the x axis of the viewer
  104328. * @param yaxis defines the y axis of the viewer
  104329. * @param zaxis defines the z axis of the viewer
  104330. */
  104331. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  104332. /**
  104333. * Creates an instance of this axes viewer.
  104334. * @returns a new axes viewer with instanced meshes
  104335. */
  104336. createInstance(): AxesViewer;
  104337. /** Releases resources */
  104338. dispose(): void;
  104339. private static _SetRenderingGroupId;
  104340. }
  104341. }
  104342. declare module BABYLON.Debug {
  104343. /**
  104344. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104345. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104346. */
  104347. export class BoneAxesViewer extends AxesViewer {
  104348. /**
  104349. * Gets or sets the target mesh where to display the axes viewer
  104350. */
  104351. mesh: Nullable<Mesh>;
  104352. /**
  104353. * Gets or sets the target bone where to display the axes viewer
  104354. */
  104355. bone: Nullable<Bone>;
  104356. /** Gets current position */
  104357. pos: Vector3;
  104358. /** Gets direction of X axis */
  104359. xaxis: Vector3;
  104360. /** Gets direction of Y axis */
  104361. yaxis: Vector3;
  104362. /** Gets direction of Z axis */
  104363. zaxis: Vector3;
  104364. /**
  104365. * Creates a new BoneAxesViewer
  104366. * @param scene defines the hosting scene
  104367. * @param bone defines the target bone
  104368. * @param mesh defines the target mesh
  104369. * @param scaleLines defines a scaling factor for line length (1 by default)
  104370. */
  104371. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  104372. /**
  104373. * Force the viewer to update
  104374. */
  104375. update(): void;
  104376. /** Releases resources */
  104377. dispose(): void;
  104378. }
  104379. }
  104380. declare module BABYLON {
  104381. /**
  104382. * Interface used to define scene explorer extensibility option
  104383. */
  104384. export interface IExplorerExtensibilityOption {
  104385. /**
  104386. * Define the option label
  104387. */
  104388. label: string;
  104389. /**
  104390. * Defines the action to execute on click
  104391. */
  104392. action: (entity: any) => void;
  104393. }
  104394. /**
  104395. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  104396. */
  104397. export interface IExplorerExtensibilityGroup {
  104398. /**
  104399. * Defines a predicate to test if a given type mut be extended
  104400. */
  104401. predicate: (entity: any) => boolean;
  104402. /**
  104403. * Gets the list of options added to a type
  104404. */
  104405. entries: IExplorerExtensibilityOption[];
  104406. }
  104407. /**
  104408. * Interface used to define the options to use to create the Inspector
  104409. */
  104410. export interface IInspectorOptions {
  104411. /**
  104412. * Display in overlay mode (default: false)
  104413. */
  104414. overlay?: boolean;
  104415. /**
  104416. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  104417. */
  104418. globalRoot?: HTMLElement;
  104419. /**
  104420. * Display the Scene explorer
  104421. */
  104422. showExplorer?: boolean;
  104423. /**
  104424. * Display the property inspector
  104425. */
  104426. showInspector?: boolean;
  104427. /**
  104428. * Display in embed mode (both panes on the right)
  104429. */
  104430. embedMode?: boolean;
  104431. /**
  104432. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  104433. */
  104434. handleResize?: boolean;
  104435. /**
  104436. * Allow the panes to popup (default: true)
  104437. */
  104438. enablePopup?: boolean;
  104439. /**
  104440. * Allow the panes to be closed by users (default: true)
  104441. */
  104442. enableClose?: boolean;
  104443. /**
  104444. * Optional list of extensibility entries
  104445. */
  104446. explorerExtensibility?: IExplorerExtensibilityGroup[];
  104447. /**
  104448. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  104449. */
  104450. inspectorURL?: string;
  104451. }
  104452. interface Scene {
  104453. /**
  104454. * @hidden
  104455. * Backing field
  104456. */
  104457. _debugLayer: DebugLayer;
  104458. /**
  104459. * Gets the debug layer (aka Inspector) associated with the scene
  104460. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104461. */
  104462. debugLayer: DebugLayer;
  104463. }
  104464. /**
  104465. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104466. * what is happening in your scene
  104467. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104468. */
  104469. export class DebugLayer {
  104470. /**
  104471. * Define the url to get the inspector script from.
  104472. * By default it uses the babylonjs CDN.
  104473. * @ignoreNaming
  104474. */
  104475. static InspectorURL: string;
  104476. private _scene;
  104477. private BJSINSPECTOR;
  104478. /**
  104479. * Observable triggered when a property is changed through the inspector.
  104480. */
  104481. onPropertyChangedObservable: Observable<{
  104482. object: any;
  104483. property: string;
  104484. value: any;
  104485. initialValue: any;
  104486. }>;
  104487. /**
  104488. * Instantiates a new debug layer.
  104489. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104490. * what is happening in your scene
  104491. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104492. * @param scene Defines the scene to inspect
  104493. */
  104494. constructor(scene: Scene);
  104495. /** Creates the inspector window. */
  104496. private _createInspector;
  104497. /**
  104498. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104499. * @param entity defines the entity to select
  104500. * @param lineContainerTitle defines the specific block to highlight
  104501. */
  104502. select(entity: any, lineContainerTitle?: string): void;
  104503. /** Get the inspector from bundle or global */
  104504. private _getGlobalInspector;
  104505. /**
  104506. * Get if the inspector is visible or not.
  104507. * @returns true if visible otherwise, false
  104508. */
  104509. isVisible(): boolean;
  104510. /**
  104511. * Hide the inspector and close its window.
  104512. */
  104513. hide(): void;
  104514. /**
  104515. * Launch the debugLayer.
  104516. * @param config Define the configuration of the inspector
  104517. * @return a promise fulfilled when the debug layer is visible
  104518. */
  104519. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104520. }
  104521. }
  104522. declare module BABYLON {
  104523. /**
  104524. * Class containing static functions to help procedurally build meshes
  104525. */
  104526. export class BoxBuilder {
  104527. /**
  104528. * Creates a box mesh
  104529. * * The parameter `size` sets the size (float) of each box side (default 1)
  104530. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104531. * * 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)
  104532. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104536. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104537. * @param name defines the name of the mesh
  104538. * @param options defines the options used to create the mesh
  104539. * @param scene defines the hosting scene
  104540. * @returns the box mesh
  104541. */
  104542. static CreateBox(name: string, options: {
  104543. size?: number;
  104544. width?: number;
  104545. height?: number;
  104546. depth?: number;
  104547. faceUV?: Vector4[];
  104548. faceColors?: Color4[];
  104549. sideOrientation?: number;
  104550. frontUVs?: Vector4;
  104551. backUVs?: Vector4;
  104552. wrap?: boolean;
  104553. topBaseAt?: number;
  104554. bottomBaseAt?: number;
  104555. updatable?: boolean;
  104556. }, scene?: Nullable<Scene>): Mesh;
  104557. }
  104558. }
  104559. declare module BABYLON {
  104560. /**
  104561. * Class containing static functions to help procedurally build meshes
  104562. */
  104563. export class SphereBuilder {
  104564. /**
  104565. * Creates a sphere mesh
  104566. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104567. * * 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`)
  104568. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104569. * * 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
  104570. * * 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)
  104571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104574. * @param name defines the name of the mesh
  104575. * @param options defines the options used to create the mesh
  104576. * @param scene defines the hosting scene
  104577. * @returns the sphere mesh
  104578. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104579. */
  104580. static CreateSphere(name: string, options: {
  104581. segments?: number;
  104582. diameter?: number;
  104583. diameterX?: number;
  104584. diameterY?: number;
  104585. diameterZ?: number;
  104586. arc?: number;
  104587. slice?: number;
  104588. sideOrientation?: number;
  104589. frontUVs?: Vector4;
  104590. backUVs?: Vector4;
  104591. updatable?: boolean;
  104592. }, scene: any): Mesh;
  104593. }
  104594. }
  104595. declare module BABYLON.Debug {
  104596. /**
  104597. * Used to show the physics impostor around the specific mesh
  104598. */
  104599. export class PhysicsViewer {
  104600. /** @hidden */
  104601. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104602. /** @hidden */
  104603. protected _meshes: Array<Nullable<AbstractMesh>>;
  104604. /** @hidden */
  104605. protected _scene: Nullable<Scene>;
  104606. /** @hidden */
  104607. protected _numMeshes: number;
  104608. /** @hidden */
  104609. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104610. private _renderFunction;
  104611. private _utilityLayer;
  104612. private _debugBoxMesh;
  104613. private _debugSphereMesh;
  104614. private _debugCylinderMesh;
  104615. private _debugMaterial;
  104616. private _debugMeshMeshes;
  104617. /**
  104618. * Creates a new PhysicsViewer
  104619. * @param scene defines the hosting scene
  104620. */
  104621. constructor(scene: Scene);
  104622. /** @hidden */
  104623. protected _updateDebugMeshes(): void;
  104624. /**
  104625. * Renders a specified physic impostor
  104626. * @param impostor defines the impostor to render
  104627. * @param targetMesh defines the mesh represented by the impostor
  104628. * @returns the new debug mesh used to render the impostor
  104629. */
  104630. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104631. /**
  104632. * Hides a specified physic impostor
  104633. * @param impostor defines the impostor to hide
  104634. */
  104635. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104636. private _getDebugMaterial;
  104637. private _getDebugBoxMesh;
  104638. private _getDebugSphereMesh;
  104639. private _getDebugCylinderMesh;
  104640. private _getDebugMeshMesh;
  104641. private _getDebugMesh;
  104642. /** Releases all resources */
  104643. dispose(): void;
  104644. }
  104645. }
  104646. declare module BABYLON {
  104647. /**
  104648. * Class containing static functions to help procedurally build meshes
  104649. */
  104650. export class LinesBuilder {
  104651. /**
  104652. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104653. * * 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
  104654. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104655. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104656. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104657. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104658. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104659. * * 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
  104660. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104663. * @param name defines the name of the new line system
  104664. * @param options defines the options used to create the line system
  104665. * @param scene defines the hosting scene
  104666. * @returns a new line system mesh
  104667. */
  104668. static CreateLineSystem(name: string, options: {
  104669. lines: Vector3[][];
  104670. updatable?: boolean;
  104671. instance?: Nullable<LinesMesh>;
  104672. colors?: Nullable<Color4[][]>;
  104673. useVertexAlpha?: boolean;
  104674. }, scene: Nullable<Scene>): LinesMesh;
  104675. /**
  104676. * Creates a line mesh
  104677. * 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
  104678. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104679. * * The parameter `points` is an array successive Vector3
  104680. * * 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
  104681. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104682. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104683. * * When updating an instance, remember that only point positions can change, not the number of points
  104684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104686. * @param name defines the name of the new line system
  104687. * @param options defines the options used to create the line system
  104688. * @param scene defines the hosting scene
  104689. * @returns a new line mesh
  104690. */
  104691. static CreateLines(name: string, options: {
  104692. points: Vector3[];
  104693. updatable?: boolean;
  104694. instance?: Nullable<LinesMesh>;
  104695. colors?: Color4[];
  104696. useVertexAlpha?: boolean;
  104697. }, scene?: Nullable<Scene>): LinesMesh;
  104698. /**
  104699. * Creates a dashed line mesh
  104700. * * 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
  104701. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104702. * * The parameter `points` is an array successive Vector3
  104703. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104704. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104705. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104706. * * 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
  104707. * * When updating an instance, remember that only point positions can change, not the number of points
  104708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104709. * @param name defines the name of the mesh
  104710. * @param options defines the options used to create the mesh
  104711. * @param scene defines the hosting scene
  104712. * @returns the dashed line mesh
  104713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104714. */
  104715. static CreateDashedLines(name: string, options: {
  104716. points: Vector3[];
  104717. dashSize?: number;
  104718. gapSize?: number;
  104719. dashNb?: number;
  104720. updatable?: boolean;
  104721. instance?: LinesMesh;
  104722. }, scene?: Nullable<Scene>): LinesMesh;
  104723. }
  104724. }
  104725. declare module BABYLON {
  104726. /**
  104727. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104728. * in order to better appreciate the issue one might have.
  104729. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104730. */
  104731. export class RayHelper {
  104732. /**
  104733. * Defines the ray we are currently tryin to visualize.
  104734. */
  104735. ray: Nullable<Ray>;
  104736. private _renderPoints;
  104737. private _renderLine;
  104738. private _renderFunction;
  104739. private _scene;
  104740. private _updateToMeshFunction;
  104741. private _attachedToMesh;
  104742. private _meshSpaceDirection;
  104743. private _meshSpaceOrigin;
  104744. /**
  104745. * Helper function to create a colored helper in a scene in one line.
  104746. * @param ray Defines the ray we are currently tryin to visualize
  104747. * @param scene Defines the scene the ray is used in
  104748. * @param color Defines the color we want to see the ray in
  104749. * @returns The newly created ray helper.
  104750. */
  104751. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104752. /**
  104753. * Instantiate a new ray helper.
  104754. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104755. * in order to better appreciate the issue one might have.
  104756. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104757. * @param ray Defines the ray we are currently tryin to visualize
  104758. */
  104759. constructor(ray: Ray);
  104760. /**
  104761. * Shows the ray we are willing to debug.
  104762. * @param scene Defines the scene the ray needs to be rendered in
  104763. * @param color Defines the color the ray needs to be rendered in
  104764. */
  104765. show(scene: Scene, color?: Color3): void;
  104766. /**
  104767. * Hides the ray we are debugging.
  104768. */
  104769. hide(): void;
  104770. private _render;
  104771. /**
  104772. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104773. * @param mesh Defines the mesh we want the helper attached to
  104774. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104775. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104776. * @param length Defines the length of the ray
  104777. */
  104778. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104779. /**
  104780. * Detach the ray helper from the mesh it has previously been attached to.
  104781. */
  104782. detachFromMesh(): void;
  104783. private _updateToMesh;
  104784. /**
  104785. * Dispose the helper and release its associated resources.
  104786. */
  104787. dispose(): void;
  104788. }
  104789. }
  104790. declare module BABYLON.Debug {
  104791. /**
  104792. * Class used to render a debug view of a given skeleton
  104793. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104794. */
  104795. export class SkeletonViewer {
  104796. /** defines the skeleton to render */
  104797. skeleton: Skeleton;
  104798. /** defines the mesh attached to the skeleton */
  104799. mesh: AbstractMesh;
  104800. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104801. autoUpdateBonesMatrices: boolean;
  104802. /** defines the rendering group id to use with the viewer */
  104803. renderingGroupId: number;
  104804. /** Gets or sets the color used to render the skeleton */
  104805. color: Color3;
  104806. private _scene;
  104807. private _debugLines;
  104808. private _debugMesh;
  104809. private _isEnabled;
  104810. private _renderFunction;
  104811. private _utilityLayer;
  104812. /**
  104813. * Returns the mesh used to render the bones
  104814. */
  104815. readonly debugMesh: Nullable<LinesMesh>;
  104816. /**
  104817. * Creates a new SkeletonViewer
  104818. * @param skeleton defines the skeleton to render
  104819. * @param mesh defines the mesh attached to the skeleton
  104820. * @param scene defines the hosting scene
  104821. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104822. * @param renderingGroupId defines the rendering group id to use with the viewer
  104823. */
  104824. constructor(
  104825. /** defines the skeleton to render */
  104826. skeleton: Skeleton,
  104827. /** defines the mesh attached to the skeleton */
  104828. mesh: AbstractMesh, scene: Scene,
  104829. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104830. autoUpdateBonesMatrices?: boolean,
  104831. /** defines the rendering group id to use with the viewer */
  104832. renderingGroupId?: number);
  104833. /** Gets or sets a boolean indicating if the viewer is enabled */
  104834. isEnabled: boolean;
  104835. private _getBonePosition;
  104836. private _getLinesForBonesWithLength;
  104837. private _getLinesForBonesNoLength;
  104838. /** Update the viewer to sync with current skeleton state */
  104839. update(): void;
  104840. /** Release associated resources */
  104841. dispose(): void;
  104842. }
  104843. }
  104844. declare module BABYLON {
  104845. /**
  104846. * Options to create the null engine
  104847. */
  104848. export class NullEngineOptions {
  104849. /**
  104850. * Render width (Default: 512)
  104851. */
  104852. renderWidth: number;
  104853. /**
  104854. * Render height (Default: 256)
  104855. */
  104856. renderHeight: number;
  104857. /**
  104858. * Texture size (Default: 512)
  104859. */
  104860. textureSize: number;
  104861. /**
  104862. * If delta time between frames should be constant
  104863. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104864. */
  104865. deterministicLockstep: boolean;
  104866. /**
  104867. * Maximum about of steps between frames (Default: 4)
  104868. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104869. */
  104870. lockstepMaxSteps: number;
  104871. }
  104872. /**
  104873. * The null engine class provides support for headless version of babylon.js.
  104874. * This can be used in server side scenario or for testing purposes
  104875. */
  104876. export class NullEngine extends Engine {
  104877. private _options;
  104878. /**
  104879. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104880. */
  104881. isDeterministicLockStep(): boolean;
  104882. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104883. getLockstepMaxSteps(): number;
  104884. /**
  104885. * Sets hardware scaling, used to save performance if needed
  104886. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104887. */
  104888. getHardwareScalingLevel(): number;
  104889. constructor(options?: NullEngineOptions);
  104890. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104891. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104892. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104893. getRenderWidth(useScreen?: boolean): number;
  104894. getRenderHeight(useScreen?: boolean): number;
  104895. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104896. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104897. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104898. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104899. bindSamplers(effect: Effect): void;
  104900. enableEffect(effect: Effect): void;
  104901. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104902. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104903. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104904. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104905. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104906. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104907. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104908. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104909. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104910. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104911. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104912. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104913. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104914. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104915. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104916. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104917. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104918. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104919. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104920. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104921. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104922. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104923. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104924. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104925. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104926. bindBuffers(vertexBuffers: {
  104927. [key: string]: VertexBuffer;
  104928. }, indexBuffer: DataBuffer, effect: Effect): void;
  104929. wipeCaches(bruteForce?: boolean): void;
  104930. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104931. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104932. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104933. /** @hidden */
  104934. _createTexture(): WebGLTexture;
  104935. /** @hidden */
  104936. _releaseTexture(texture: InternalTexture): void;
  104937. 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;
  104938. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104939. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104940. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104941. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104942. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104943. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104944. areAllEffectsReady(): boolean;
  104945. /**
  104946. * @hidden
  104947. * Get the current error code of the webGL context
  104948. * @returns the error code
  104949. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104950. */
  104951. getError(): number;
  104952. /** @hidden */
  104953. _getUnpackAlignement(): number;
  104954. /** @hidden */
  104955. _unpackFlipY(value: boolean): void;
  104956. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104957. /**
  104958. * Updates a dynamic vertex buffer.
  104959. * @param vertexBuffer the vertex buffer to update
  104960. * @param data the data used to update the vertex buffer
  104961. * @param byteOffset the byte offset of the data (optional)
  104962. * @param byteLength the byte length of the data (optional)
  104963. */
  104964. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104965. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104966. /** @hidden */
  104967. _bindTexture(channel: number, texture: InternalTexture): void;
  104968. /** @hidden */
  104969. _releaseBuffer(buffer: DataBuffer): boolean;
  104970. releaseEffects(): void;
  104971. displayLoadingUI(): void;
  104972. hideLoadingUI(): void;
  104973. /** @hidden */
  104974. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104975. /** @hidden */
  104976. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104977. /** @hidden */
  104978. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104979. /** @hidden */
  104980. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104981. }
  104982. }
  104983. declare module BABYLON {
  104984. /** @hidden */
  104985. export class _OcclusionDataStorage {
  104986. /** @hidden */
  104987. occlusionInternalRetryCounter: number;
  104988. /** @hidden */
  104989. isOcclusionQueryInProgress: boolean;
  104990. /** @hidden */
  104991. isOccluded: boolean;
  104992. /** @hidden */
  104993. occlusionRetryCount: number;
  104994. /** @hidden */
  104995. occlusionType: number;
  104996. /** @hidden */
  104997. occlusionQueryAlgorithmType: number;
  104998. }
  104999. interface Engine {
  105000. /**
  105001. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  105002. * @return the new query
  105003. */
  105004. createQuery(): WebGLQuery;
  105005. /**
  105006. * Delete and release a webGL query
  105007. * @param query defines the query to delete
  105008. * @return the current engine
  105009. */
  105010. deleteQuery(query: WebGLQuery): Engine;
  105011. /**
  105012. * Check if a given query has resolved and got its value
  105013. * @param query defines the query to check
  105014. * @returns true if the query got its value
  105015. */
  105016. isQueryResultAvailable(query: WebGLQuery): boolean;
  105017. /**
  105018. * Gets the value of a given query
  105019. * @param query defines the query to check
  105020. * @returns the value of the query
  105021. */
  105022. getQueryResult(query: WebGLQuery): number;
  105023. /**
  105024. * Initiates an occlusion query
  105025. * @param algorithmType defines the algorithm to use
  105026. * @param query defines the query to use
  105027. * @returns the current engine
  105028. * @see http://doc.babylonjs.com/features/occlusionquery
  105029. */
  105030. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  105031. /**
  105032. * Ends an occlusion query
  105033. * @see http://doc.babylonjs.com/features/occlusionquery
  105034. * @param algorithmType defines the algorithm to use
  105035. * @returns the current engine
  105036. */
  105037. endOcclusionQuery(algorithmType: number): Engine;
  105038. /**
  105039. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  105040. * Please note that only one query can be issued at a time
  105041. * @returns a time token used to track the time span
  105042. */
  105043. startTimeQuery(): Nullable<_TimeToken>;
  105044. /**
  105045. * Ends a time query
  105046. * @param token defines the token used to measure the time span
  105047. * @returns the time spent (in ns)
  105048. */
  105049. endTimeQuery(token: _TimeToken): int;
  105050. /** @hidden */
  105051. _currentNonTimestampToken: Nullable<_TimeToken>;
  105052. /** @hidden */
  105053. _createTimeQuery(): WebGLQuery;
  105054. /** @hidden */
  105055. _deleteTimeQuery(query: WebGLQuery): void;
  105056. /** @hidden */
  105057. _getGlAlgorithmType(algorithmType: number): number;
  105058. /** @hidden */
  105059. _getTimeQueryResult(query: WebGLQuery): any;
  105060. /** @hidden */
  105061. _getTimeQueryAvailability(query: WebGLQuery): any;
  105062. }
  105063. interface AbstractMesh {
  105064. /**
  105065. * Backing filed
  105066. * @hidden
  105067. */
  105068. __occlusionDataStorage: _OcclusionDataStorage;
  105069. /**
  105070. * Access property
  105071. * @hidden
  105072. */
  105073. _occlusionDataStorage: _OcclusionDataStorage;
  105074. /**
  105075. * 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.
  105076. * The default value is -1 which means don't break the query and wait till the result
  105077. * @see http://doc.babylonjs.com/features/occlusionquery
  105078. */
  105079. occlusionRetryCount: number;
  105080. /**
  105081. * 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:
  105082. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  105083. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  105084. * * 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.
  105085. * @see http://doc.babylonjs.com/features/occlusionquery
  105086. */
  105087. occlusionType: number;
  105088. /**
  105089. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  105090. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  105091. * * 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.
  105092. * @see http://doc.babylonjs.com/features/occlusionquery
  105093. */
  105094. occlusionQueryAlgorithmType: number;
  105095. /**
  105096. * 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
  105097. * @see http://doc.babylonjs.com/features/occlusionquery
  105098. */
  105099. isOccluded: boolean;
  105100. /**
  105101. * Flag to check the progress status of the query
  105102. * @see http://doc.babylonjs.com/features/occlusionquery
  105103. */
  105104. isOcclusionQueryInProgress: boolean;
  105105. }
  105106. }
  105107. declare module BABYLON {
  105108. /** @hidden */
  105109. export var _forceTransformFeedbackToBundle: boolean;
  105110. interface Engine {
  105111. /**
  105112. * Creates a webGL transform feedback object
  105113. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  105114. * @returns the webGL transform feedback object
  105115. */
  105116. createTransformFeedback(): WebGLTransformFeedback;
  105117. /**
  105118. * Delete a webGL transform feedback object
  105119. * @param value defines the webGL transform feedback object to delete
  105120. */
  105121. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  105122. /**
  105123. * Bind a webGL transform feedback object to the webgl context
  105124. * @param value defines the webGL transform feedback object to bind
  105125. */
  105126. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  105127. /**
  105128. * Begins a transform feedback operation
  105129. * @param usePoints defines if points or triangles must be used
  105130. */
  105131. beginTransformFeedback(usePoints: boolean): void;
  105132. /**
  105133. * Ends a transform feedback operation
  105134. */
  105135. endTransformFeedback(): void;
  105136. /**
  105137. * Specify the varyings to use with transform feedback
  105138. * @param program defines the associated webGL program
  105139. * @param value defines the list of strings representing the varying names
  105140. */
  105141. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  105142. /**
  105143. * Bind a webGL buffer for a transform feedback operation
  105144. * @param value defines the webGL buffer to bind
  105145. */
  105146. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  105147. }
  105148. }
  105149. declare module BABYLON {
  105150. /**
  105151. * Creation options of the multi render target texture.
  105152. */
  105153. export interface IMultiRenderTargetOptions {
  105154. /**
  105155. * Define if the texture needs to create mip maps after render.
  105156. */
  105157. generateMipMaps?: boolean;
  105158. /**
  105159. * Define the types of all the draw buffers we want to create
  105160. */
  105161. types?: number[];
  105162. /**
  105163. * Define the sampling modes of all the draw buffers we want to create
  105164. */
  105165. samplingModes?: number[];
  105166. /**
  105167. * Define if a depth buffer is required
  105168. */
  105169. generateDepthBuffer?: boolean;
  105170. /**
  105171. * Define if a stencil buffer is required
  105172. */
  105173. generateStencilBuffer?: boolean;
  105174. /**
  105175. * Define if a depth texture is required instead of a depth buffer
  105176. */
  105177. generateDepthTexture?: boolean;
  105178. /**
  105179. * Define the number of desired draw buffers
  105180. */
  105181. textureCount?: number;
  105182. /**
  105183. * Define if aspect ratio should be adapted to the texture or stay the scene one
  105184. */
  105185. doNotChangeAspectRatio?: boolean;
  105186. /**
  105187. * Define the default type of the buffers we are creating
  105188. */
  105189. defaultType?: number;
  105190. }
  105191. /**
  105192. * A multi render target, like a render target provides the ability to render to a texture.
  105193. * Unlike the render target, it can render to several draw buffers in one draw.
  105194. * This is specially interesting in deferred rendering or for any effects requiring more than
  105195. * just one color from a single pass.
  105196. */
  105197. export class MultiRenderTarget extends RenderTargetTexture {
  105198. private _internalTextures;
  105199. private _textures;
  105200. private _multiRenderTargetOptions;
  105201. /**
  105202. * Get if draw buffers are currently supported by the used hardware and browser.
  105203. */
  105204. readonly isSupported: boolean;
  105205. /**
  105206. * Get the list of textures generated by the multi render target.
  105207. */
  105208. readonly textures: Texture[];
  105209. /**
  105210. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  105211. */
  105212. readonly depthTexture: Texture;
  105213. /**
  105214. * Set the wrapping mode on U of all the textures we are rendering to.
  105215. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105216. */
  105217. wrapU: number;
  105218. /**
  105219. * Set the wrapping mode on V of all the textures we are rendering to.
  105220. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105221. */
  105222. wrapV: number;
  105223. /**
  105224. * Instantiate a new multi render target texture.
  105225. * A multi render target, like a render target provides the ability to render to a texture.
  105226. * Unlike the render target, it can render to several draw buffers in one draw.
  105227. * This is specially interesting in deferred rendering or for any effects requiring more than
  105228. * just one color from a single pass.
  105229. * @param name Define the name of the texture
  105230. * @param size Define the size of the buffers to render to
  105231. * @param count Define the number of target we are rendering into
  105232. * @param scene Define the scene the texture belongs to
  105233. * @param options Define the options used to create the multi render target
  105234. */
  105235. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  105236. /** @hidden */
  105237. _rebuild(): void;
  105238. private _createInternalTextures;
  105239. private _createTextures;
  105240. /**
  105241. * Define the number of samples used if MSAA is enabled.
  105242. */
  105243. samples: number;
  105244. /**
  105245. * Resize all the textures in the multi render target.
  105246. * Be carrefull as it will recreate all the data in the new texture.
  105247. * @param size Define the new size
  105248. */
  105249. resize(size: any): void;
  105250. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  105251. /**
  105252. * Dispose the render targets and their associated resources
  105253. */
  105254. dispose(): void;
  105255. /**
  105256. * Release all the underlying texture used as draw buffers.
  105257. */
  105258. releaseInternalTextures(): void;
  105259. }
  105260. }
  105261. declare module BABYLON {
  105262. interface Engine {
  105263. /**
  105264. * Unbind a list of render target textures from the webGL context
  105265. * This is used only when drawBuffer extension or webGL2 are active
  105266. * @param textures defines the render target textures to unbind
  105267. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105268. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105269. */
  105270. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  105271. /**
  105272. * Create a multi render target texture
  105273. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  105274. * @param size defines the size of the texture
  105275. * @param options defines the creation options
  105276. * @returns the cube texture as an InternalTexture
  105277. */
  105278. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  105279. /**
  105280. * Update the sample count for a given multiple render target texture
  105281. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105282. * @param textures defines the textures to update
  105283. * @param samples defines the sample count to set
  105284. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105285. */
  105286. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  105287. }
  105288. }
  105289. declare module BABYLON {
  105290. /**
  105291. * Gather the list of clipboard event types as constants.
  105292. */
  105293. export class ClipboardEventTypes {
  105294. /**
  105295. * The clipboard event is fired when a copy command is active (pressed).
  105296. */
  105297. static readonly COPY: number;
  105298. /**
  105299. * The clipboard event is fired when a cut command is active (pressed).
  105300. */
  105301. static readonly CUT: number;
  105302. /**
  105303. * The clipboard event is fired when a paste command is active (pressed).
  105304. */
  105305. static readonly PASTE: number;
  105306. }
  105307. /**
  105308. * This class is used to store clipboard related info for the onClipboardObservable event.
  105309. */
  105310. export class ClipboardInfo {
  105311. /**
  105312. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105313. */
  105314. type: number;
  105315. /**
  105316. * Defines the related dom event
  105317. */
  105318. event: ClipboardEvent;
  105319. /**
  105320. *Creates an instance of ClipboardInfo.
  105321. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  105322. * @param event Defines the related dom event
  105323. */
  105324. constructor(
  105325. /**
  105326. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105327. */
  105328. type: number,
  105329. /**
  105330. * Defines the related dom event
  105331. */
  105332. event: ClipboardEvent);
  105333. /**
  105334. * Get the clipboard event's type from the keycode.
  105335. * @param keyCode Defines the keyCode for the current keyboard event.
  105336. * @return {number}
  105337. */
  105338. static GetTypeFromCharacter(keyCode: number): number;
  105339. }
  105340. }
  105341. declare module BABYLON {
  105342. /**
  105343. * Class used to represent data loading progression
  105344. */
  105345. export class SceneLoaderProgressEvent {
  105346. /** defines if data length to load can be evaluated */
  105347. readonly lengthComputable: boolean;
  105348. /** defines the loaded data length */
  105349. readonly loaded: number;
  105350. /** defines the data length to load */
  105351. readonly total: number;
  105352. /**
  105353. * Create a new progress event
  105354. * @param lengthComputable defines if data length to load can be evaluated
  105355. * @param loaded defines the loaded data length
  105356. * @param total defines the data length to load
  105357. */
  105358. constructor(
  105359. /** defines if data length to load can be evaluated */
  105360. lengthComputable: boolean,
  105361. /** defines the loaded data length */
  105362. loaded: number,
  105363. /** defines the data length to load */
  105364. total: number);
  105365. /**
  105366. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105367. * @param event defines the source event
  105368. * @returns a new SceneLoaderProgressEvent
  105369. */
  105370. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105371. }
  105372. /**
  105373. * Interface used by SceneLoader plugins to define supported file extensions
  105374. */
  105375. export interface ISceneLoaderPluginExtensions {
  105376. /**
  105377. * Defines the list of supported extensions
  105378. */
  105379. [extension: string]: {
  105380. isBinary: boolean;
  105381. };
  105382. }
  105383. /**
  105384. * Interface used by SceneLoader plugin factory
  105385. */
  105386. export interface ISceneLoaderPluginFactory {
  105387. /**
  105388. * Defines the name of the factory
  105389. */
  105390. name: string;
  105391. /**
  105392. * Function called to create a new plugin
  105393. * @return the new plugin
  105394. */
  105395. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105396. /**
  105397. * Boolean indicating if the plugin can direct load specific data
  105398. */
  105399. canDirectLoad?: (data: string) => boolean;
  105400. }
  105401. /**
  105402. * Interface used to define a SceneLoader plugin
  105403. */
  105404. export interface ISceneLoaderPlugin {
  105405. /**
  105406. * The friendly name of this plugin.
  105407. */
  105408. name: string;
  105409. /**
  105410. * The file extensions supported by this plugin.
  105411. */
  105412. extensions: string | ISceneLoaderPluginExtensions;
  105413. /**
  105414. * Import meshes into a scene.
  105415. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105416. * @param scene The scene to import into
  105417. * @param data The data to import
  105418. * @param rootUrl The root url for scene and resources
  105419. * @param meshes The meshes array to import into
  105420. * @param particleSystems The particle systems array to import into
  105421. * @param skeletons The skeletons array to import into
  105422. * @param onError The callback when import fails
  105423. * @returns True if successful or false otherwise
  105424. */
  105425. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105426. /**
  105427. * Load into a scene.
  105428. * @param scene The scene to load into
  105429. * @param data The data to import
  105430. * @param rootUrl The root url for scene and resources
  105431. * @param onError The callback when import fails
  105432. * @returns true if successful or false otherwise
  105433. */
  105434. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105435. /**
  105436. * The callback that returns true if the data can be directly loaded.
  105437. */
  105438. canDirectLoad?: (data: string) => boolean;
  105439. /**
  105440. * The callback that allows custom handling of the root url based on the response url.
  105441. */
  105442. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105443. /**
  105444. * Load into an asset container.
  105445. * @param scene The scene to load into
  105446. * @param data The data to import
  105447. * @param rootUrl The root url for scene and resources
  105448. * @param onError The callback when import fails
  105449. * @returns The loaded asset container
  105450. */
  105451. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105452. }
  105453. /**
  105454. * Interface used to define an async SceneLoader plugin
  105455. */
  105456. export interface ISceneLoaderPluginAsync {
  105457. /**
  105458. * The friendly name of this plugin.
  105459. */
  105460. name: string;
  105461. /**
  105462. * The file extensions supported by this plugin.
  105463. */
  105464. extensions: string | ISceneLoaderPluginExtensions;
  105465. /**
  105466. * Import meshes into a scene.
  105467. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105468. * @param scene The scene to import into
  105469. * @param data The data to import
  105470. * @param rootUrl The root url for scene and resources
  105471. * @param onProgress The callback when the load progresses
  105472. * @param fileName Defines the name of the file to load
  105473. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105474. */
  105475. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105476. meshes: AbstractMesh[];
  105477. particleSystems: IParticleSystem[];
  105478. skeletons: Skeleton[];
  105479. animationGroups: AnimationGroup[];
  105480. }>;
  105481. /**
  105482. * Load into a scene.
  105483. * @param scene The scene to load into
  105484. * @param data The data to import
  105485. * @param rootUrl The root url for scene and resources
  105486. * @param onProgress The callback when the load progresses
  105487. * @param fileName Defines the name of the file to load
  105488. * @returns Nothing
  105489. */
  105490. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105491. /**
  105492. * The callback that returns true if the data can be directly loaded.
  105493. */
  105494. canDirectLoad?: (data: string) => boolean;
  105495. /**
  105496. * The callback that allows custom handling of the root url based on the response url.
  105497. */
  105498. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105499. /**
  105500. * Load into an asset container.
  105501. * @param scene The scene to load into
  105502. * @param data The data to import
  105503. * @param rootUrl The root url for scene and resources
  105504. * @param onProgress The callback when the load progresses
  105505. * @param fileName Defines the name of the file to load
  105506. * @returns The loaded asset container
  105507. */
  105508. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105509. }
  105510. /**
  105511. * Class used to load scene from various file formats using registered plugins
  105512. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105513. */
  105514. export class SceneLoader {
  105515. /**
  105516. * No logging while loading
  105517. */
  105518. static readonly NO_LOGGING: number;
  105519. /**
  105520. * Minimal logging while loading
  105521. */
  105522. static readonly MINIMAL_LOGGING: number;
  105523. /**
  105524. * Summary logging while loading
  105525. */
  105526. static readonly SUMMARY_LOGGING: number;
  105527. /**
  105528. * Detailled logging while loading
  105529. */
  105530. static readonly DETAILED_LOGGING: number;
  105531. /**
  105532. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105533. */
  105534. static ForceFullSceneLoadingForIncremental: boolean;
  105535. /**
  105536. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105537. */
  105538. static ShowLoadingScreen: boolean;
  105539. /**
  105540. * Defines the current logging level (while loading the scene)
  105541. * @ignorenaming
  105542. */
  105543. static loggingLevel: number;
  105544. /**
  105545. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105546. */
  105547. static CleanBoneMatrixWeights: boolean;
  105548. /**
  105549. * Event raised when a plugin is used to load a scene
  105550. */
  105551. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105552. private static _registeredPlugins;
  105553. private static _getDefaultPlugin;
  105554. private static _getPluginForExtension;
  105555. private static _getPluginForDirectLoad;
  105556. private static _getPluginForFilename;
  105557. private static _getDirectLoad;
  105558. private static _loadData;
  105559. private static _getFileInfo;
  105560. /**
  105561. * Gets a plugin that can load the given extension
  105562. * @param extension defines the extension to load
  105563. * @returns a plugin or null if none works
  105564. */
  105565. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105566. /**
  105567. * Gets a boolean indicating that the given extension can be loaded
  105568. * @param extension defines the extension to load
  105569. * @returns true if the extension is supported
  105570. */
  105571. static IsPluginForExtensionAvailable(extension: string): boolean;
  105572. /**
  105573. * Adds a new plugin to the list of registered plugins
  105574. * @param plugin defines the plugin to add
  105575. */
  105576. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105577. /**
  105578. * Import meshes into a scene
  105579. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105580. * @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)
  105581. * @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)
  105582. * @param scene the instance of BABYLON.Scene to append to
  105583. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105584. * @param onProgress a callback with a progress event for each file being loaded
  105585. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105586. * @param pluginExtension the extension used to determine the plugin
  105587. * @returns The loaded plugin
  105588. */
  105589. 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>;
  105590. /**
  105591. * Import meshes into a scene
  105592. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105593. * @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)
  105594. * @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)
  105595. * @param scene the instance of BABYLON.Scene to append to
  105596. * @param onProgress a callback with a progress event for each file being loaded
  105597. * @param pluginExtension the extension used to determine the plugin
  105598. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105599. */
  105600. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105601. meshes: AbstractMesh[];
  105602. particleSystems: IParticleSystem[];
  105603. skeletons: Skeleton[];
  105604. animationGroups: AnimationGroup[];
  105605. }>;
  105606. /**
  105607. * Load a scene
  105608. * @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)
  105609. * @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)
  105610. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105611. * @param onSuccess a callback with the scene when import succeeds
  105612. * @param onProgress a callback with a progress event for each file being loaded
  105613. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105614. * @param pluginExtension the extension used to determine the plugin
  105615. * @returns The loaded plugin
  105616. */
  105617. 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>;
  105618. /**
  105619. * Load a scene
  105620. * @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)
  105621. * @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)
  105622. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105623. * @param onProgress a callback with a progress event for each file being loaded
  105624. * @param pluginExtension the extension used to determine the plugin
  105625. * @returns The loaded scene
  105626. */
  105627. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105628. /**
  105629. * Append a scene
  105630. * @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)
  105631. * @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)
  105632. * @param scene is the instance of BABYLON.Scene to append to
  105633. * @param onSuccess a callback with the scene when import succeeds
  105634. * @param onProgress a callback with a progress event for each file being loaded
  105635. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105636. * @param pluginExtension the extension used to determine the plugin
  105637. * @returns The loaded plugin
  105638. */
  105639. 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>;
  105640. /**
  105641. * Append a scene
  105642. * @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)
  105643. * @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)
  105644. * @param scene is the instance of BABYLON.Scene to append to
  105645. * @param onProgress a callback with a progress event for each file being loaded
  105646. * @param pluginExtension the extension used to determine the plugin
  105647. * @returns The given scene
  105648. */
  105649. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105650. /**
  105651. * Load a scene into an asset container
  105652. * @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)
  105653. * @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)
  105654. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105655. * @param onSuccess a callback with the scene when import succeeds
  105656. * @param onProgress a callback with a progress event for each file being loaded
  105657. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105658. * @param pluginExtension the extension used to determine the plugin
  105659. * @returns The loaded plugin
  105660. */
  105661. 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>;
  105662. /**
  105663. * Load a scene into an asset container
  105664. * @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)
  105665. * @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)
  105666. * @param scene is the instance of Scene to append to
  105667. * @param onProgress a callback with a progress event for each file being loaded
  105668. * @param pluginExtension the extension used to determine the plugin
  105669. * @returns The loaded asset container
  105670. */
  105671. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105672. }
  105673. }
  105674. declare module BABYLON {
  105675. /**
  105676. * Google Daydream controller
  105677. */
  105678. export class DaydreamController extends WebVRController {
  105679. /**
  105680. * Base Url for the controller model.
  105681. */
  105682. static MODEL_BASE_URL: string;
  105683. /**
  105684. * File name for the controller model.
  105685. */
  105686. static MODEL_FILENAME: string;
  105687. /**
  105688. * Gamepad Id prefix used to identify Daydream Controller.
  105689. */
  105690. static readonly GAMEPAD_ID_PREFIX: string;
  105691. /**
  105692. * Creates a new DaydreamController from a gamepad
  105693. * @param vrGamepad the gamepad that the controller should be created from
  105694. */
  105695. constructor(vrGamepad: any);
  105696. /**
  105697. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105698. * @param scene scene in which to add meshes
  105699. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105700. */
  105701. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105702. /**
  105703. * Called once for each button that changed state since the last frame
  105704. * @param buttonIdx Which button index changed
  105705. * @param state New state of the button
  105706. * @param changes Which properties on the state changed since last frame
  105707. */
  105708. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105709. }
  105710. }
  105711. declare module BABYLON {
  105712. /**
  105713. * Gear VR Controller
  105714. */
  105715. export class GearVRController extends WebVRController {
  105716. /**
  105717. * Base Url for the controller model.
  105718. */
  105719. static MODEL_BASE_URL: string;
  105720. /**
  105721. * File name for the controller model.
  105722. */
  105723. static MODEL_FILENAME: string;
  105724. /**
  105725. * Gamepad Id prefix used to identify this controller.
  105726. */
  105727. static readonly GAMEPAD_ID_PREFIX: string;
  105728. private readonly _buttonIndexToObservableNameMap;
  105729. /**
  105730. * Creates a new GearVRController from a gamepad
  105731. * @param vrGamepad the gamepad that the controller should be created from
  105732. */
  105733. constructor(vrGamepad: any);
  105734. /**
  105735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105736. * @param scene scene in which to add meshes
  105737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105738. */
  105739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105740. /**
  105741. * Called once for each button that changed state since the last frame
  105742. * @param buttonIdx Which button index changed
  105743. * @param state New state of the button
  105744. * @param changes Which properties on the state changed since last frame
  105745. */
  105746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105747. }
  105748. }
  105749. declare module BABYLON {
  105750. /**
  105751. * Generic Controller
  105752. */
  105753. export class GenericController extends WebVRController {
  105754. /**
  105755. * Base Url for the controller model.
  105756. */
  105757. static readonly MODEL_BASE_URL: string;
  105758. /**
  105759. * File name for the controller model.
  105760. */
  105761. static readonly MODEL_FILENAME: string;
  105762. /**
  105763. * Creates a new GenericController from a gamepad
  105764. * @param vrGamepad the gamepad that the controller should be created from
  105765. */
  105766. constructor(vrGamepad: any);
  105767. /**
  105768. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105769. * @param scene scene in which to add meshes
  105770. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105771. */
  105772. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105773. /**
  105774. * Called once for each button that changed state since the last frame
  105775. * @param buttonIdx Which button index changed
  105776. * @param state New state of the button
  105777. * @param changes Which properties on the state changed since last frame
  105778. */
  105779. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105780. }
  105781. }
  105782. declare module BABYLON {
  105783. /**
  105784. * Oculus Touch Controller
  105785. */
  105786. export class OculusTouchController extends WebVRController {
  105787. /**
  105788. * Base Url for the controller model.
  105789. */
  105790. static MODEL_BASE_URL: string;
  105791. /**
  105792. * File name for the left controller model.
  105793. */
  105794. static MODEL_LEFT_FILENAME: string;
  105795. /**
  105796. * File name for the right controller model.
  105797. */
  105798. static MODEL_RIGHT_FILENAME: string;
  105799. /**
  105800. * Fired when the secondary trigger on this controller is modified
  105801. */
  105802. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105803. /**
  105804. * Fired when the thumb rest on this controller is modified
  105805. */
  105806. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105807. /**
  105808. * Creates a new OculusTouchController from a gamepad
  105809. * @param vrGamepad the gamepad that the controller should be created from
  105810. */
  105811. constructor(vrGamepad: any);
  105812. /**
  105813. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105814. * @param scene scene in which to add meshes
  105815. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105816. */
  105817. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105818. /**
  105819. * Fired when the A button on this controller is modified
  105820. */
  105821. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105822. /**
  105823. * Fired when the B button on this controller is modified
  105824. */
  105825. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105826. /**
  105827. * Fired when the X button on this controller is modified
  105828. */
  105829. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105830. /**
  105831. * Fired when the Y button on this controller is modified
  105832. */
  105833. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105834. /**
  105835. * Called once for each button that changed state since the last frame
  105836. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105837. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105838. * 2) secondary trigger (same)
  105839. * 3) A (right) X (left), touch, pressed = value
  105840. * 4) B / Y
  105841. * 5) thumb rest
  105842. * @param buttonIdx Which button index changed
  105843. * @param state New state of the button
  105844. * @param changes Which properties on the state changed since last frame
  105845. */
  105846. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105847. }
  105848. }
  105849. declare module BABYLON {
  105850. /**
  105851. * Vive Controller
  105852. */
  105853. export class ViveController extends WebVRController {
  105854. /**
  105855. * Base Url for the controller model.
  105856. */
  105857. static MODEL_BASE_URL: string;
  105858. /**
  105859. * File name for the controller model.
  105860. */
  105861. static MODEL_FILENAME: string;
  105862. /**
  105863. * Creates a new ViveController from a gamepad
  105864. * @param vrGamepad the gamepad that the controller should be created from
  105865. */
  105866. constructor(vrGamepad: any);
  105867. /**
  105868. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105869. * @param scene scene in which to add meshes
  105870. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105871. */
  105872. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105873. /**
  105874. * Fired when the left button on this controller is modified
  105875. */
  105876. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105877. /**
  105878. * Fired when the right button on this controller is modified
  105879. */
  105880. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105881. /**
  105882. * Fired when the menu button on this controller is modified
  105883. */
  105884. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105885. /**
  105886. * Called once for each button that changed state since the last frame
  105887. * Vive mapping:
  105888. * 0: touchpad
  105889. * 1: trigger
  105890. * 2: left AND right buttons
  105891. * 3: menu button
  105892. * @param buttonIdx Which button index changed
  105893. * @param state New state of the button
  105894. * @param changes Which properties on the state changed since last frame
  105895. */
  105896. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105897. }
  105898. }
  105899. declare module BABYLON {
  105900. /**
  105901. * Defines the WindowsMotionController object that the state of the windows motion controller
  105902. */
  105903. export class WindowsMotionController extends WebVRController {
  105904. /**
  105905. * The base url used to load the left and right controller models
  105906. */
  105907. static MODEL_BASE_URL: string;
  105908. /**
  105909. * The name of the left controller model file
  105910. */
  105911. static MODEL_LEFT_FILENAME: string;
  105912. /**
  105913. * The name of the right controller model file
  105914. */
  105915. static MODEL_RIGHT_FILENAME: string;
  105916. /**
  105917. * The controller name prefix for this controller type
  105918. */
  105919. static readonly GAMEPAD_ID_PREFIX: string;
  105920. /**
  105921. * The controller id pattern for this controller type
  105922. */
  105923. private static readonly GAMEPAD_ID_PATTERN;
  105924. private _loadedMeshInfo;
  105925. private readonly _mapping;
  105926. /**
  105927. * Fired when the trackpad on this controller is clicked
  105928. */
  105929. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105930. /**
  105931. * Fired when the trackpad on this controller is modified
  105932. */
  105933. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105934. /**
  105935. * The current x and y values of this controller's trackpad
  105936. */
  105937. trackpad: StickValues;
  105938. /**
  105939. * Creates a new WindowsMotionController from a gamepad
  105940. * @param vrGamepad the gamepad that the controller should be created from
  105941. */
  105942. constructor(vrGamepad: any);
  105943. /**
  105944. * Fired when the trigger on this controller is modified
  105945. */
  105946. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105947. /**
  105948. * Fired when the menu button on this controller is modified
  105949. */
  105950. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105951. /**
  105952. * Fired when the grip button on this controller is modified
  105953. */
  105954. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105955. /**
  105956. * Fired when the thumbstick button on this controller is modified
  105957. */
  105958. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105959. /**
  105960. * Fired when the touchpad button on this controller is modified
  105961. */
  105962. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105963. /**
  105964. * Fired when the touchpad values on this controller are modified
  105965. */
  105966. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105967. private _updateTrackpad;
  105968. /**
  105969. * Called once per frame by the engine.
  105970. */
  105971. update(): void;
  105972. /**
  105973. * Called once for each button that changed state since the last frame
  105974. * @param buttonIdx Which button index changed
  105975. * @param state New state of the button
  105976. * @param changes Which properties on the state changed since last frame
  105977. */
  105978. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105979. /**
  105980. * Moves the buttons on the controller mesh based on their current state
  105981. * @param buttonName the name of the button to move
  105982. * @param buttonValue the value of the button which determines the buttons new position
  105983. */
  105984. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105985. /**
  105986. * Moves the axis on the controller mesh based on its current state
  105987. * @param axis the index of the axis
  105988. * @param axisValue the value of the axis which determines the meshes new position
  105989. * @hidden
  105990. */
  105991. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105992. /**
  105993. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105994. * @param scene scene in which to add meshes
  105995. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105996. */
  105997. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105998. /**
  105999. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106000. * can be transformed by button presses and axes values, based on this._mapping.
  106001. *
  106002. * @param scene scene in which the meshes exist
  106003. * @param meshes list of meshes that make up the controller model to process
  106004. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106005. */
  106006. private processModel;
  106007. private createMeshInfo;
  106008. /**
  106009. * Gets the ray of the controller in the direction the controller is pointing
  106010. * @param length the length the resulting ray should be
  106011. * @returns a ray in the direction the controller is pointing
  106012. */
  106013. getForwardRay(length?: number): Ray;
  106014. /**
  106015. * Disposes of the controller
  106016. */
  106017. dispose(): void;
  106018. }
  106019. }
  106020. declare module BABYLON {
  106021. /**
  106022. * Class containing static functions to help procedurally build meshes
  106023. */
  106024. export class PolyhedronBuilder {
  106025. /**
  106026. * Creates a polyhedron mesh
  106027. * * 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
  106028. * * The parameter `size` (positive float, default 1) sets the polygon size
  106029. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106030. * * 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`
  106031. * * 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
  106032. * * 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)`)
  106033. * * 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
  106034. * * 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
  106035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106038. * @param name defines the name of the mesh
  106039. * @param options defines the options used to create the mesh
  106040. * @param scene defines the hosting scene
  106041. * @returns the polyhedron mesh
  106042. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106043. */
  106044. static CreatePolyhedron(name: string, options: {
  106045. type?: number;
  106046. size?: number;
  106047. sizeX?: number;
  106048. sizeY?: number;
  106049. sizeZ?: number;
  106050. custom?: any;
  106051. faceUV?: Vector4[];
  106052. faceColors?: Color4[];
  106053. flat?: boolean;
  106054. updatable?: boolean;
  106055. sideOrientation?: number;
  106056. frontUVs?: Vector4;
  106057. backUVs?: Vector4;
  106058. }, scene?: Nullable<Scene>): Mesh;
  106059. }
  106060. }
  106061. declare module BABYLON {
  106062. /**
  106063. * Gizmo that enables scaling a mesh along 3 axis
  106064. */
  106065. export class ScaleGizmo extends Gizmo {
  106066. /**
  106067. * Internal gizmo used for interactions on the x axis
  106068. */
  106069. xGizmo: AxisScaleGizmo;
  106070. /**
  106071. * Internal gizmo used for interactions on the y axis
  106072. */
  106073. yGizmo: AxisScaleGizmo;
  106074. /**
  106075. * Internal gizmo used for interactions on the z axis
  106076. */
  106077. zGizmo: AxisScaleGizmo;
  106078. /**
  106079. * Internal gizmo used to scale all axis equally
  106080. */
  106081. uniformScaleGizmo: AxisScaleGizmo;
  106082. private _meshAttached;
  106083. private _updateGizmoRotationToMatchAttachedMesh;
  106084. private _snapDistance;
  106085. private _scaleRatio;
  106086. private _uniformScalingMesh;
  106087. private _octahedron;
  106088. /** Fires an event when any of it's sub gizmos are dragged */
  106089. onDragStartObservable: Observable<unknown>;
  106090. /** Fires an event when any of it's sub gizmos are released from dragging */
  106091. onDragEndObservable: Observable<unknown>;
  106092. attachedMesh: Nullable<AbstractMesh>;
  106093. /**
  106094. * Creates a ScaleGizmo
  106095. * @param gizmoLayer The utility layer the gizmo will be added to
  106096. */
  106097. constructor(gizmoLayer?: UtilityLayerRenderer);
  106098. updateGizmoRotationToMatchAttachedMesh: boolean;
  106099. /**
  106100. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106101. */
  106102. snapDistance: number;
  106103. /**
  106104. * Ratio for the scale of the gizmo (Default: 1)
  106105. */
  106106. scaleRatio: number;
  106107. /**
  106108. * Disposes of the gizmo
  106109. */
  106110. dispose(): void;
  106111. }
  106112. }
  106113. declare module BABYLON {
  106114. /**
  106115. * Single axis scale gizmo
  106116. */
  106117. export class AxisScaleGizmo extends Gizmo {
  106118. /**
  106119. * Drag behavior responsible for the gizmos dragging interactions
  106120. */
  106121. dragBehavior: PointerDragBehavior;
  106122. private _pointerObserver;
  106123. /**
  106124. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106125. */
  106126. snapDistance: number;
  106127. /**
  106128. * Event that fires each time the gizmo snaps to a new location.
  106129. * * snapDistance is the the change in distance
  106130. */
  106131. onSnapObservable: Observable<{
  106132. snapDistance: number;
  106133. }>;
  106134. /**
  106135. * If the scaling operation should be done on all axis (default: false)
  106136. */
  106137. uniformScaling: boolean;
  106138. private _isEnabled;
  106139. private _parent;
  106140. private _arrow;
  106141. private _coloredMaterial;
  106142. private _hoverMaterial;
  106143. /**
  106144. * Creates an AxisScaleGizmo
  106145. * @param gizmoLayer The utility layer the gizmo will be added to
  106146. * @param dragAxis The axis which the gizmo will be able to scale on
  106147. * @param color The color of the gizmo
  106148. */
  106149. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  106150. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106151. /**
  106152. * If the gizmo is enabled
  106153. */
  106154. isEnabled: boolean;
  106155. /**
  106156. * Disposes of the gizmo
  106157. */
  106158. dispose(): void;
  106159. /**
  106160. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106161. * @param mesh The mesh to replace the default mesh of the gizmo
  106162. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  106163. */
  106164. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  106165. }
  106166. }
  106167. declare module BABYLON {
  106168. /**
  106169. * Bounding box gizmo
  106170. */
  106171. export class BoundingBoxGizmo extends Gizmo {
  106172. private _lineBoundingBox;
  106173. private _rotateSpheresParent;
  106174. private _scaleBoxesParent;
  106175. private _boundingDimensions;
  106176. private _renderObserver;
  106177. private _pointerObserver;
  106178. private _scaleDragSpeed;
  106179. private _tmpQuaternion;
  106180. private _tmpVector;
  106181. private _tmpRotationMatrix;
  106182. /**
  106183. * 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)
  106184. */
  106185. ignoreChildren: boolean;
  106186. /**
  106187. * 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)
  106188. */
  106189. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  106190. /**
  106191. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  106192. */
  106193. rotationSphereSize: number;
  106194. /**
  106195. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  106196. */
  106197. scaleBoxSize: number;
  106198. /**
  106199. * 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)
  106200. */
  106201. fixedDragMeshScreenSize: boolean;
  106202. /**
  106203. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  106204. */
  106205. fixedDragMeshScreenSizeDistanceFactor: number;
  106206. /**
  106207. * Fired when a rotation sphere or scale box is dragged
  106208. */
  106209. onDragStartObservable: Observable<{}>;
  106210. /**
  106211. * Fired when a scale box is dragged
  106212. */
  106213. onScaleBoxDragObservable: Observable<{}>;
  106214. /**
  106215. * Fired when a scale box drag is ended
  106216. */
  106217. onScaleBoxDragEndObservable: Observable<{}>;
  106218. /**
  106219. * Fired when a rotation sphere is dragged
  106220. */
  106221. onRotationSphereDragObservable: Observable<{}>;
  106222. /**
  106223. * Fired when a rotation sphere drag is ended
  106224. */
  106225. onRotationSphereDragEndObservable: Observable<{}>;
  106226. /**
  106227. * 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)
  106228. */
  106229. scalePivot: Nullable<Vector3>;
  106230. /**
  106231. * Mesh used as a pivot to rotate the attached mesh
  106232. */
  106233. private _anchorMesh;
  106234. private _existingMeshScale;
  106235. private _dragMesh;
  106236. private pointerDragBehavior;
  106237. private coloredMaterial;
  106238. private hoverColoredMaterial;
  106239. /**
  106240. * Sets the color of the bounding box gizmo
  106241. * @param color the color to set
  106242. */
  106243. setColor(color: Color3): void;
  106244. /**
  106245. * Creates an BoundingBoxGizmo
  106246. * @param gizmoLayer The utility layer the gizmo will be added to
  106247. * @param color The color of the gizmo
  106248. */
  106249. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106250. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106251. private _selectNode;
  106252. /**
  106253. * Updates the bounding box information for the Gizmo
  106254. */
  106255. updateBoundingBox(): void;
  106256. private _updateRotationSpheres;
  106257. private _updateScaleBoxes;
  106258. /**
  106259. * Enables rotation on the specified axis and disables rotation on the others
  106260. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106261. */
  106262. setEnabledRotationAxis(axis: string): void;
  106263. /**
  106264. * Enables/disables scaling
  106265. * @param enable if scaling should be enabled
  106266. */
  106267. setEnabledScaling(enable: boolean): void;
  106268. private _updateDummy;
  106269. /**
  106270. * Enables a pointer drag behavior on the bounding box of the gizmo
  106271. */
  106272. enableDragBehavior(): void;
  106273. /**
  106274. * Disposes of the gizmo
  106275. */
  106276. dispose(): void;
  106277. /**
  106278. * 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)
  106279. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106280. * @returns the bounding box mesh with the passed in mesh as a child
  106281. */
  106282. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106283. /**
  106284. * CustomMeshes are not supported by this gizmo
  106285. * @param mesh The mesh to replace the default mesh of the gizmo
  106286. */
  106287. setCustomMesh(mesh: Mesh): void;
  106288. }
  106289. }
  106290. declare module BABYLON {
  106291. /**
  106292. * Single plane rotation gizmo
  106293. */
  106294. export class PlaneRotationGizmo extends Gizmo {
  106295. /**
  106296. * Drag behavior responsible for the gizmos dragging interactions
  106297. */
  106298. dragBehavior: PointerDragBehavior;
  106299. private _pointerObserver;
  106300. /**
  106301. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106302. */
  106303. snapDistance: number;
  106304. /**
  106305. * Event that fires each time the gizmo snaps to a new location.
  106306. * * snapDistance is the the change in distance
  106307. */
  106308. onSnapObservable: Observable<{
  106309. snapDistance: number;
  106310. }>;
  106311. private _isEnabled;
  106312. private _parent;
  106313. /**
  106314. * Creates a PlaneRotationGizmo
  106315. * @param gizmoLayer The utility layer the gizmo will be added to
  106316. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106317. * @param color The color of the gizmo
  106318. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106319. */
  106320. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106321. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106322. /**
  106323. * If the gizmo is enabled
  106324. */
  106325. isEnabled: boolean;
  106326. /**
  106327. * Disposes of the gizmo
  106328. */
  106329. dispose(): void;
  106330. }
  106331. }
  106332. declare module BABYLON {
  106333. /**
  106334. * Gizmo that enables rotating a mesh along 3 axis
  106335. */
  106336. export class RotationGizmo extends Gizmo {
  106337. /**
  106338. * Internal gizmo used for interactions on the x axis
  106339. */
  106340. xGizmo: PlaneRotationGizmo;
  106341. /**
  106342. * Internal gizmo used for interactions on the y axis
  106343. */
  106344. yGizmo: PlaneRotationGizmo;
  106345. /**
  106346. * Internal gizmo used for interactions on the z axis
  106347. */
  106348. zGizmo: PlaneRotationGizmo;
  106349. /** Fires an event when any of it's sub gizmos are dragged */
  106350. onDragStartObservable: Observable<unknown>;
  106351. /** Fires an event when any of it's sub gizmos are released from dragging */
  106352. onDragEndObservable: Observable<unknown>;
  106353. private _meshAttached;
  106354. attachedMesh: Nullable<AbstractMesh>;
  106355. /**
  106356. * Creates a RotationGizmo
  106357. * @param gizmoLayer The utility layer the gizmo will be added to
  106358. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106359. */
  106360. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106361. updateGizmoRotationToMatchAttachedMesh: boolean;
  106362. /**
  106363. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106364. */
  106365. snapDistance: number;
  106366. /**
  106367. * Ratio for the scale of the gizmo (Default: 1)
  106368. */
  106369. scaleRatio: number;
  106370. /**
  106371. * Disposes of the gizmo
  106372. */
  106373. dispose(): void;
  106374. /**
  106375. * CustomMeshes are not supported by this gizmo
  106376. * @param mesh The mesh to replace the default mesh of the gizmo
  106377. */
  106378. setCustomMesh(mesh: Mesh): void;
  106379. }
  106380. }
  106381. declare module BABYLON {
  106382. /**
  106383. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106384. */
  106385. export class GizmoManager implements IDisposable {
  106386. private scene;
  106387. /**
  106388. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106389. */
  106390. gizmos: {
  106391. positionGizmo: Nullable<PositionGizmo>;
  106392. rotationGizmo: Nullable<RotationGizmo>;
  106393. scaleGizmo: Nullable<ScaleGizmo>;
  106394. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106395. };
  106396. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106397. clearGizmoOnEmptyPointerEvent: boolean;
  106398. /** Fires an event when the manager is attached to a mesh */
  106399. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106400. private _gizmosEnabled;
  106401. private _pointerObserver;
  106402. private _attachedMesh;
  106403. private _boundingBoxColor;
  106404. private _defaultUtilityLayer;
  106405. private _defaultKeepDepthUtilityLayer;
  106406. /**
  106407. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106408. */
  106409. boundingBoxDragBehavior: SixDofDragBehavior;
  106410. /**
  106411. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106412. */
  106413. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106414. /**
  106415. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106416. */
  106417. usePointerToAttachGizmos: boolean;
  106418. /**
  106419. * Utility layer that the bounding box gizmo belongs to
  106420. */
  106421. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106422. /**
  106423. * Utility layer that all gizmos besides bounding box belong to
  106424. */
  106425. readonly utilityLayer: UtilityLayerRenderer;
  106426. /**
  106427. * Instatiates a gizmo manager
  106428. * @param scene the scene to overlay the gizmos on top of
  106429. */
  106430. constructor(scene: Scene);
  106431. /**
  106432. * Attaches a set of gizmos to the specified mesh
  106433. * @param mesh The mesh the gizmo's should be attached to
  106434. */
  106435. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106436. /**
  106437. * If the position gizmo is enabled
  106438. */
  106439. positionGizmoEnabled: boolean;
  106440. /**
  106441. * If the rotation gizmo is enabled
  106442. */
  106443. rotationGizmoEnabled: boolean;
  106444. /**
  106445. * If the scale gizmo is enabled
  106446. */
  106447. scaleGizmoEnabled: boolean;
  106448. /**
  106449. * If the boundingBox gizmo is enabled
  106450. */
  106451. boundingBoxGizmoEnabled: boolean;
  106452. /**
  106453. * Disposes of the gizmo manager
  106454. */
  106455. dispose(): void;
  106456. }
  106457. }
  106458. declare module BABYLON {
  106459. /**
  106460. * A directional light is defined by a direction (what a surprise!).
  106461. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106462. * 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.
  106463. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106464. */
  106465. export class DirectionalLight extends ShadowLight {
  106466. private _shadowFrustumSize;
  106467. /**
  106468. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106469. */
  106470. /**
  106471. * Specifies a fix frustum size for the shadow generation.
  106472. */
  106473. shadowFrustumSize: number;
  106474. private _shadowOrthoScale;
  106475. /**
  106476. * Gets the shadow projection scale against the optimal computed one.
  106477. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106478. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106479. */
  106480. /**
  106481. * Sets the shadow projection scale against the optimal computed one.
  106482. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106483. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106484. */
  106485. shadowOrthoScale: number;
  106486. /**
  106487. * Automatically compute the projection matrix to best fit (including all the casters)
  106488. * on each frame.
  106489. */
  106490. autoUpdateExtends: boolean;
  106491. private _orthoLeft;
  106492. private _orthoRight;
  106493. private _orthoTop;
  106494. private _orthoBottom;
  106495. /**
  106496. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106497. * The directional light is emitted from everywhere in the given direction.
  106498. * It can cast shadows.
  106499. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106500. * @param name The friendly name of the light
  106501. * @param direction The direction of the light
  106502. * @param scene The scene the light belongs to
  106503. */
  106504. constructor(name: string, direction: Vector3, scene: Scene);
  106505. /**
  106506. * Returns the string "DirectionalLight".
  106507. * @return The class name
  106508. */
  106509. getClassName(): string;
  106510. /**
  106511. * Returns the integer 1.
  106512. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106513. */
  106514. getTypeID(): number;
  106515. /**
  106516. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106517. * Returns the DirectionalLight Shadow projection matrix.
  106518. */
  106519. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106520. /**
  106521. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106522. * Returns the DirectionalLight Shadow projection matrix.
  106523. */
  106524. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106525. /**
  106526. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106527. * Returns the DirectionalLight Shadow projection matrix.
  106528. */
  106529. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106530. protected _buildUniformLayout(): void;
  106531. /**
  106532. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106533. * @param effect The effect to update
  106534. * @param lightIndex The index of the light in the effect to update
  106535. * @returns The directional light
  106536. */
  106537. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106538. /**
  106539. * Gets the minZ used for shadow according to both the scene and the light.
  106540. *
  106541. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106542. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106543. * @param activeCamera The camera we are returning the min for
  106544. * @returns the depth min z
  106545. */
  106546. getDepthMinZ(activeCamera: Camera): number;
  106547. /**
  106548. * Gets the maxZ used for shadow according to both the scene and the light.
  106549. *
  106550. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106551. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106552. * @param activeCamera The camera we are returning the max for
  106553. * @returns the depth max z
  106554. */
  106555. getDepthMaxZ(activeCamera: Camera): number;
  106556. /**
  106557. * Prepares the list of defines specific to the light type.
  106558. * @param defines the list of defines
  106559. * @param lightIndex defines the index of the light for the effect
  106560. */
  106561. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106562. }
  106563. }
  106564. declare module BABYLON {
  106565. /**
  106566. * Class containing static functions to help procedurally build meshes
  106567. */
  106568. export class HemisphereBuilder {
  106569. /**
  106570. * Creates a hemisphere mesh
  106571. * @param name defines the name of the mesh
  106572. * @param options defines the options used to create the mesh
  106573. * @param scene defines the hosting scene
  106574. * @returns the hemisphere mesh
  106575. */
  106576. static CreateHemisphere(name: string, options: {
  106577. segments?: number;
  106578. diameter?: number;
  106579. sideOrientation?: number;
  106580. }, scene: any): Mesh;
  106581. }
  106582. }
  106583. declare module BABYLON {
  106584. /**
  106585. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106586. * These values define a cone of light starting from the position, emitting toward the direction.
  106587. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106588. * and the exponent defines the speed of the decay of the light with distance (reach).
  106589. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106590. */
  106591. export class SpotLight extends ShadowLight {
  106592. private _angle;
  106593. private _innerAngle;
  106594. private _cosHalfAngle;
  106595. private _lightAngleScale;
  106596. private _lightAngleOffset;
  106597. /**
  106598. * Gets the cone angle of the spot light in Radians.
  106599. */
  106600. /**
  106601. * Sets the cone angle of the spot light in Radians.
  106602. */
  106603. angle: number;
  106604. /**
  106605. * Only used in gltf falloff mode, this defines the angle where
  106606. * the directional falloff will start before cutting at angle which could be seen
  106607. * as outer angle.
  106608. */
  106609. /**
  106610. * Only used in gltf falloff mode, this defines the angle where
  106611. * the directional falloff will start before cutting at angle which could be seen
  106612. * as outer angle.
  106613. */
  106614. innerAngle: number;
  106615. private _shadowAngleScale;
  106616. /**
  106617. * Allows scaling the angle of the light for shadow generation only.
  106618. */
  106619. /**
  106620. * Allows scaling the angle of the light for shadow generation only.
  106621. */
  106622. shadowAngleScale: number;
  106623. /**
  106624. * The light decay speed with the distance from the emission spot.
  106625. */
  106626. exponent: number;
  106627. private _projectionTextureMatrix;
  106628. /**
  106629. * Allows reading the projecton texture
  106630. */
  106631. readonly projectionTextureMatrix: Matrix;
  106632. protected _projectionTextureLightNear: number;
  106633. /**
  106634. * Gets the near clip of the Spotlight for texture projection.
  106635. */
  106636. /**
  106637. * Sets the near clip of the Spotlight for texture projection.
  106638. */
  106639. projectionTextureLightNear: number;
  106640. protected _projectionTextureLightFar: number;
  106641. /**
  106642. * Gets the far clip of the Spotlight for texture projection.
  106643. */
  106644. /**
  106645. * Sets the far clip of the Spotlight for texture projection.
  106646. */
  106647. projectionTextureLightFar: number;
  106648. protected _projectionTextureUpDirection: Vector3;
  106649. /**
  106650. * Gets the Up vector of the Spotlight for texture projection.
  106651. */
  106652. /**
  106653. * Sets the Up vector of the Spotlight for texture projection.
  106654. */
  106655. projectionTextureUpDirection: Vector3;
  106656. private _projectionTexture;
  106657. /**
  106658. * Gets the projection texture of the light.
  106659. */
  106660. /**
  106661. * Sets the projection texture of the light.
  106662. */
  106663. projectionTexture: Nullable<BaseTexture>;
  106664. private _projectionTextureViewLightDirty;
  106665. private _projectionTextureProjectionLightDirty;
  106666. private _projectionTextureDirty;
  106667. private _projectionTextureViewTargetVector;
  106668. private _projectionTextureViewLightMatrix;
  106669. private _projectionTextureProjectionLightMatrix;
  106670. private _projectionTextureScalingMatrix;
  106671. /**
  106672. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106673. * It can cast shadows.
  106674. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106675. * @param name The light friendly name
  106676. * @param position The position of the spot light in the scene
  106677. * @param direction The direction of the light in the scene
  106678. * @param angle The cone angle of the light in Radians
  106679. * @param exponent The light decay speed with the distance from the emission spot
  106680. * @param scene The scene the lights belongs to
  106681. */
  106682. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106683. /**
  106684. * Returns the string "SpotLight".
  106685. * @returns the class name
  106686. */
  106687. getClassName(): string;
  106688. /**
  106689. * Returns the integer 2.
  106690. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106691. */
  106692. getTypeID(): number;
  106693. /**
  106694. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106695. */
  106696. protected _setDirection(value: Vector3): void;
  106697. /**
  106698. * Overrides the position setter to recompute the projection texture view light Matrix.
  106699. */
  106700. protected _setPosition(value: Vector3): void;
  106701. /**
  106702. * 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.
  106703. * Returns the SpotLight.
  106704. */
  106705. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106706. protected _computeProjectionTextureViewLightMatrix(): void;
  106707. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106708. /**
  106709. * Main function for light texture projection matrix computing.
  106710. */
  106711. protected _computeProjectionTextureMatrix(): void;
  106712. protected _buildUniformLayout(): void;
  106713. private _computeAngleValues;
  106714. /**
  106715. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106716. * @param effect The effect to update
  106717. * @param lightIndex The index of the light in the effect to update
  106718. * @returns The spot light
  106719. */
  106720. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106721. /**
  106722. * Disposes the light and the associated resources.
  106723. */
  106724. dispose(): void;
  106725. /**
  106726. * Prepares the list of defines specific to the light type.
  106727. * @param defines the list of defines
  106728. * @param lightIndex defines the index of the light for the effect
  106729. */
  106730. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106731. }
  106732. }
  106733. declare module BABYLON {
  106734. /**
  106735. * Gizmo that enables viewing a light
  106736. */
  106737. export class LightGizmo extends Gizmo {
  106738. private _lightMesh;
  106739. private _material;
  106740. private cachedPosition;
  106741. private cachedForward;
  106742. /**
  106743. * Creates a LightGizmo
  106744. * @param gizmoLayer The utility layer the gizmo will be added to
  106745. */
  106746. constructor(gizmoLayer?: UtilityLayerRenderer);
  106747. private _light;
  106748. /**
  106749. * The light that the gizmo is attached to
  106750. */
  106751. light: Nullable<Light>;
  106752. /**
  106753. * @hidden
  106754. * Updates the gizmo to match the attached mesh's position/rotation
  106755. */
  106756. protected _update(): void;
  106757. private static _Scale;
  106758. /**
  106759. * Creates the lines for a light mesh
  106760. */
  106761. private static _createLightLines;
  106762. /**
  106763. * Disposes of the light gizmo
  106764. */
  106765. dispose(): void;
  106766. private static _CreateHemisphericLightMesh;
  106767. private static _CreatePointLightMesh;
  106768. private static _CreateSpotLightMesh;
  106769. private static _CreateDirectionalLightMesh;
  106770. }
  106771. }
  106772. declare module BABYLON {
  106773. /** @hidden */
  106774. export var backgroundFragmentDeclaration: {
  106775. name: string;
  106776. shader: string;
  106777. };
  106778. }
  106779. declare module BABYLON {
  106780. /** @hidden */
  106781. export var backgroundUboDeclaration: {
  106782. name: string;
  106783. shader: string;
  106784. };
  106785. }
  106786. declare module BABYLON {
  106787. /** @hidden */
  106788. export var backgroundPixelShader: {
  106789. name: string;
  106790. shader: string;
  106791. };
  106792. }
  106793. declare module BABYLON {
  106794. /** @hidden */
  106795. export var backgroundVertexDeclaration: {
  106796. name: string;
  106797. shader: string;
  106798. };
  106799. }
  106800. declare module BABYLON {
  106801. /** @hidden */
  106802. export var backgroundVertexShader: {
  106803. name: string;
  106804. shader: string;
  106805. };
  106806. }
  106807. declare module BABYLON {
  106808. /**
  106809. * Background material used to create an efficient environement around your scene.
  106810. */
  106811. export class BackgroundMaterial extends PushMaterial {
  106812. /**
  106813. * Standard reflectance value at parallel view angle.
  106814. */
  106815. static StandardReflectance0: number;
  106816. /**
  106817. * Standard reflectance value at grazing angle.
  106818. */
  106819. static StandardReflectance90: number;
  106820. protected _primaryColor: Color3;
  106821. /**
  106822. * Key light Color (multiply against the environement texture)
  106823. */
  106824. primaryColor: Color3;
  106825. protected __perceptualColor: Nullable<Color3>;
  106826. /**
  106827. * Experimental Internal Use Only.
  106828. *
  106829. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106830. * This acts as a helper to set the primary color to a more "human friendly" value.
  106831. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106832. * output color as close as possible from the chosen value.
  106833. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106834. * part of lighting setup.)
  106835. */
  106836. _perceptualColor: Nullable<Color3>;
  106837. protected _primaryColorShadowLevel: float;
  106838. /**
  106839. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106840. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106841. */
  106842. primaryColorShadowLevel: float;
  106843. protected _primaryColorHighlightLevel: float;
  106844. /**
  106845. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106846. * The primary color is used at the level chosen to define what the white area would look.
  106847. */
  106848. primaryColorHighlightLevel: float;
  106849. protected _reflectionTexture: Nullable<BaseTexture>;
  106850. /**
  106851. * Reflection Texture used in the material.
  106852. * Should be author in a specific way for the best result (refer to the documentation).
  106853. */
  106854. reflectionTexture: Nullable<BaseTexture>;
  106855. protected _reflectionBlur: float;
  106856. /**
  106857. * Reflection Texture level of blur.
  106858. *
  106859. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106860. * texture twice.
  106861. */
  106862. reflectionBlur: float;
  106863. protected _diffuseTexture: Nullable<BaseTexture>;
  106864. /**
  106865. * Diffuse Texture used in the material.
  106866. * Should be author in a specific way for the best result (refer to the documentation).
  106867. */
  106868. diffuseTexture: Nullable<BaseTexture>;
  106869. protected _shadowLights: Nullable<IShadowLight[]>;
  106870. /**
  106871. * Specify the list of lights casting shadow on the material.
  106872. * All scene shadow lights will be included if null.
  106873. */
  106874. shadowLights: Nullable<IShadowLight[]>;
  106875. protected _shadowLevel: float;
  106876. /**
  106877. * Helps adjusting the shadow to a softer level if required.
  106878. * 0 means black shadows and 1 means no shadows.
  106879. */
  106880. shadowLevel: float;
  106881. protected _sceneCenter: Vector3;
  106882. /**
  106883. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106884. * It is usually zero but might be interesting to modify according to your setup.
  106885. */
  106886. sceneCenter: Vector3;
  106887. protected _opacityFresnel: boolean;
  106888. /**
  106889. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106890. * This helps ensuring a nice transition when the camera goes under the ground.
  106891. */
  106892. opacityFresnel: boolean;
  106893. protected _reflectionFresnel: boolean;
  106894. /**
  106895. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106896. * This helps adding a mirror texture on the ground.
  106897. */
  106898. reflectionFresnel: boolean;
  106899. protected _reflectionFalloffDistance: number;
  106900. /**
  106901. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106902. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106903. */
  106904. reflectionFalloffDistance: number;
  106905. protected _reflectionAmount: number;
  106906. /**
  106907. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106908. */
  106909. reflectionAmount: number;
  106910. protected _reflectionReflectance0: number;
  106911. /**
  106912. * This specifies the weight of the reflection at grazing angle.
  106913. */
  106914. reflectionReflectance0: number;
  106915. protected _reflectionReflectance90: number;
  106916. /**
  106917. * This specifies the weight of the reflection at a perpendicular point of view.
  106918. */
  106919. reflectionReflectance90: number;
  106920. /**
  106921. * Sets the reflection reflectance fresnel values according to the default standard
  106922. * empirically know to work well :-)
  106923. */
  106924. reflectionStandardFresnelWeight: number;
  106925. protected _useRGBColor: boolean;
  106926. /**
  106927. * Helps to directly use the maps channels instead of their level.
  106928. */
  106929. useRGBColor: boolean;
  106930. protected _enableNoise: boolean;
  106931. /**
  106932. * This helps reducing the banding effect that could occur on the background.
  106933. */
  106934. enableNoise: boolean;
  106935. /**
  106936. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106937. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106938. * Recommended to be keep at 1.0 except for special cases.
  106939. */
  106940. fovMultiplier: number;
  106941. private _fovMultiplier;
  106942. /**
  106943. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106944. */
  106945. useEquirectangularFOV: boolean;
  106946. private _maxSimultaneousLights;
  106947. /**
  106948. * Number of Simultaneous lights allowed on the material.
  106949. */
  106950. maxSimultaneousLights: int;
  106951. /**
  106952. * Default configuration related to image processing available in the Background Material.
  106953. */
  106954. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106955. /**
  106956. * Keep track of the image processing observer to allow dispose and replace.
  106957. */
  106958. private _imageProcessingObserver;
  106959. /**
  106960. * Attaches a new image processing configuration to the PBR Material.
  106961. * @param configuration (if null the scene configuration will be use)
  106962. */
  106963. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106964. /**
  106965. * Gets the image processing configuration used either in this material.
  106966. */
  106967. /**
  106968. * Sets the Default image processing configuration used either in the this material.
  106969. *
  106970. * If sets to null, the scene one is in use.
  106971. */
  106972. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106973. /**
  106974. * Gets wether the color curves effect is enabled.
  106975. */
  106976. /**
  106977. * Sets wether the color curves effect is enabled.
  106978. */
  106979. cameraColorCurvesEnabled: boolean;
  106980. /**
  106981. * Gets wether the color grading effect is enabled.
  106982. */
  106983. /**
  106984. * Gets wether the color grading effect is enabled.
  106985. */
  106986. cameraColorGradingEnabled: boolean;
  106987. /**
  106988. * Gets wether tonemapping is enabled or not.
  106989. */
  106990. /**
  106991. * Sets wether tonemapping is enabled or not
  106992. */
  106993. cameraToneMappingEnabled: boolean;
  106994. /**
  106995. * The camera exposure used on this material.
  106996. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106997. * This corresponds to a photographic exposure.
  106998. */
  106999. /**
  107000. * The camera exposure used on this material.
  107001. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107002. * This corresponds to a photographic exposure.
  107003. */
  107004. cameraExposure: float;
  107005. /**
  107006. * Gets The camera contrast used on this material.
  107007. */
  107008. /**
  107009. * Sets The camera contrast used on this material.
  107010. */
  107011. cameraContrast: float;
  107012. /**
  107013. * Gets the Color Grading 2D Lookup Texture.
  107014. */
  107015. /**
  107016. * Sets the Color Grading 2D Lookup Texture.
  107017. */
  107018. cameraColorGradingTexture: Nullable<BaseTexture>;
  107019. /**
  107020. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107021. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107022. * 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;
  107023. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107024. */
  107025. /**
  107026. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107027. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107028. * 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;
  107029. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107030. */
  107031. cameraColorCurves: Nullable<ColorCurves>;
  107032. /**
  107033. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  107034. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  107035. */
  107036. switchToBGR: boolean;
  107037. private _renderTargets;
  107038. private _reflectionControls;
  107039. private _white;
  107040. private _primaryShadowColor;
  107041. private _primaryHighlightColor;
  107042. /**
  107043. * Instantiates a Background Material in the given scene
  107044. * @param name The friendly name of the material
  107045. * @param scene The scene to add the material to
  107046. */
  107047. constructor(name: string, scene: Scene);
  107048. /**
  107049. * Gets a boolean indicating that current material needs to register RTT
  107050. */
  107051. readonly hasRenderTargetTextures: boolean;
  107052. /**
  107053. * The entire material has been created in order to prevent overdraw.
  107054. * @returns false
  107055. */
  107056. needAlphaTesting(): boolean;
  107057. /**
  107058. * The entire material has been created in order to prevent overdraw.
  107059. * @returns true if blending is enable
  107060. */
  107061. needAlphaBlending(): boolean;
  107062. /**
  107063. * Checks wether the material is ready to be rendered for a given mesh.
  107064. * @param mesh The mesh to render
  107065. * @param subMesh The submesh to check against
  107066. * @param useInstances Specify wether or not the material is used with instances
  107067. * @returns true if all the dependencies are ready (Textures, Effects...)
  107068. */
  107069. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107070. /**
  107071. * Compute the primary color according to the chosen perceptual color.
  107072. */
  107073. private _computePrimaryColorFromPerceptualColor;
  107074. /**
  107075. * Compute the highlights and shadow colors according to their chosen levels.
  107076. */
  107077. private _computePrimaryColors;
  107078. /**
  107079. * Build the uniform buffer used in the material.
  107080. */
  107081. buildUniformLayout(): void;
  107082. /**
  107083. * Unbind the material.
  107084. */
  107085. unbind(): void;
  107086. /**
  107087. * Bind only the world matrix to the material.
  107088. * @param world The world matrix to bind.
  107089. */
  107090. bindOnlyWorldMatrix(world: Matrix): void;
  107091. /**
  107092. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  107093. * @param world The world matrix to bind.
  107094. * @param subMesh The submesh to bind for.
  107095. */
  107096. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107097. /**
  107098. * Dispose the material.
  107099. * @param forceDisposeEffect Force disposal of the associated effect.
  107100. * @param forceDisposeTextures Force disposal of the associated textures.
  107101. */
  107102. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107103. /**
  107104. * Clones the material.
  107105. * @param name The cloned name.
  107106. * @returns The cloned material.
  107107. */
  107108. clone(name: string): BackgroundMaterial;
  107109. /**
  107110. * Serializes the current material to its JSON representation.
  107111. * @returns The JSON representation.
  107112. */
  107113. serialize(): any;
  107114. /**
  107115. * Gets the class name of the material
  107116. * @returns "BackgroundMaterial"
  107117. */
  107118. getClassName(): string;
  107119. /**
  107120. * Parse a JSON input to create back a background material.
  107121. * @param source The JSON data to parse
  107122. * @param scene The scene to create the parsed material in
  107123. * @param rootUrl The root url of the assets the material depends upon
  107124. * @returns the instantiated BackgroundMaterial.
  107125. */
  107126. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  107127. }
  107128. }
  107129. declare module BABYLON {
  107130. /**
  107131. * Represents the different options available during the creation of
  107132. * a Environment helper.
  107133. *
  107134. * This can control the default ground, skybox and image processing setup of your scene.
  107135. */
  107136. export interface IEnvironmentHelperOptions {
  107137. /**
  107138. * Specifies wether or not to create a ground.
  107139. * True by default.
  107140. */
  107141. createGround: boolean;
  107142. /**
  107143. * Specifies the ground size.
  107144. * 15 by default.
  107145. */
  107146. groundSize: number;
  107147. /**
  107148. * The texture used on the ground for the main color.
  107149. * Comes from the BabylonJS CDN by default.
  107150. *
  107151. * Remarks: Can be either a texture or a url.
  107152. */
  107153. groundTexture: string | BaseTexture;
  107154. /**
  107155. * The color mixed in the ground texture by default.
  107156. * BabylonJS clearColor by default.
  107157. */
  107158. groundColor: Color3;
  107159. /**
  107160. * Specifies the ground opacity.
  107161. * 1 by default.
  107162. */
  107163. groundOpacity: number;
  107164. /**
  107165. * Enables the ground to receive shadows.
  107166. * True by default.
  107167. */
  107168. enableGroundShadow: boolean;
  107169. /**
  107170. * Helps preventing the shadow to be fully black on the ground.
  107171. * 0.5 by default.
  107172. */
  107173. groundShadowLevel: number;
  107174. /**
  107175. * Creates a mirror texture attach to the ground.
  107176. * false by default.
  107177. */
  107178. enableGroundMirror: boolean;
  107179. /**
  107180. * Specifies the ground mirror size ratio.
  107181. * 0.3 by default as the default kernel is 64.
  107182. */
  107183. groundMirrorSizeRatio: number;
  107184. /**
  107185. * Specifies the ground mirror blur kernel size.
  107186. * 64 by default.
  107187. */
  107188. groundMirrorBlurKernel: number;
  107189. /**
  107190. * Specifies the ground mirror visibility amount.
  107191. * 1 by default
  107192. */
  107193. groundMirrorAmount: number;
  107194. /**
  107195. * Specifies the ground mirror reflectance weight.
  107196. * This uses the standard weight of the background material to setup the fresnel effect
  107197. * of the mirror.
  107198. * 1 by default.
  107199. */
  107200. groundMirrorFresnelWeight: number;
  107201. /**
  107202. * Specifies the ground mirror Falloff distance.
  107203. * This can helps reducing the size of the reflection.
  107204. * 0 by Default.
  107205. */
  107206. groundMirrorFallOffDistance: number;
  107207. /**
  107208. * Specifies the ground mirror texture type.
  107209. * Unsigned Int by Default.
  107210. */
  107211. groundMirrorTextureType: number;
  107212. /**
  107213. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  107214. * the shown objects.
  107215. */
  107216. groundYBias: number;
  107217. /**
  107218. * Specifies wether or not to create a skybox.
  107219. * True by default.
  107220. */
  107221. createSkybox: boolean;
  107222. /**
  107223. * Specifies the skybox size.
  107224. * 20 by default.
  107225. */
  107226. skyboxSize: number;
  107227. /**
  107228. * The texture used on the skybox for the main color.
  107229. * Comes from the BabylonJS CDN by default.
  107230. *
  107231. * Remarks: Can be either a texture or a url.
  107232. */
  107233. skyboxTexture: string | BaseTexture;
  107234. /**
  107235. * The color mixed in the skybox texture by default.
  107236. * BabylonJS clearColor by default.
  107237. */
  107238. skyboxColor: Color3;
  107239. /**
  107240. * The background rotation around the Y axis of the scene.
  107241. * This helps aligning the key lights of your scene with the background.
  107242. * 0 by default.
  107243. */
  107244. backgroundYRotation: number;
  107245. /**
  107246. * Compute automatically the size of the elements to best fit with the scene.
  107247. */
  107248. sizeAuto: boolean;
  107249. /**
  107250. * Default position of the rootMesh if autoSize is not true.
  107251. */
  107252. rootPosition: Vector3;
  107253. /**
  107254. * Sets up the image processing in the scene.
  107255. * true by default.
  107256. */
  107257. setupImageProcessing: boolean;
  107258. /**
  107259. * The texture used as your environment texture in the scene.
  107260. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107261. *
  107262. * Remarks: Can be either a texture or a url.
  107263. */
  107264. environmentTexture: string | BaseTexture;
  107265. /**
  107266. * The value of the exposure to apply to the scene.
  107267. * 0.6 by default if setupImageProcessing is true.
  107268. */
  107269. cameraExposure: number;
  107270. /**
  107271. * The value of the contrast to apply to the scene.
  107272. * 1.6 by default if setupImageProcessing is true.
  107273. */
  107274. cameraContrast: number;
  107275. /**
  107276. * Specifies wether or not tonemapping should be enabled in the scene.
  107277. * true by default if setupImageProcessing is true.
  107278. */
  107279. toneMappingEnabled: boolean;
  107280. }
  107281. /**
  107282. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107283. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107284. * It also helps with the default setup of your imageProcessing configuration.
  107285. */
  107286. export class EnvironmentHelper {
  107287. /**
  107288. * Default ground texture URL.
  107289. */
  107290. private static _groundTextureCDNUrl;
  107291. /**
  107292. * Default skybox texture URL.
  107293. */
  107294. private static _skyboxTextureCDNUrl;
  107295. /**
  107296. * Default environment texture URL.
  107297. */
  107298. private static _environmentTextureCDNUrl;
  107299. /**
  107300. * Creates the default options for the helper.
  107301. */
  107302. private static _getDefaultOptions;
  107303. private _rootMesh;
  107304. /**
  107305. * Gets the root mesh created by the helper.
  107306. */
  107307. readonly rootMesh: Mesh;
  107308. private _skybox;
  107309. /**
  107310. * Gets the skybox created by the helper.
  107311. */
  107312. readonly skybox: Nullable<Mesh>;
  107313. private _skyboxTexture;
  107314. /**
  107315. * Gets the skybox texture created by the helper.
  107316. */
  107317. readonly skyboxTexture: Nullable<BaseTexture>;
  107318. private _skyboxMaterial;
  107319. /**
  107320. * Gets the skybox material created by the helper.
  107321. */
  107322. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107323. private _ground;
  107324. /**
  107325. * Gets the ground mesh created by the helper.
  107326. */
  107327. readonly ground: Nullable<Mesh>;
  107328. private _groundTexture;
  107329. /**
  107330. * Gets the ground texture created by the helper.
  107331. */
  107332. readonly groundTexture: Nullable<BaseTexture>;
  107333. private _groundMirror;
  107334. /**
  107335. * Gets the ground mirror created by the helper.
  107336. */
  107337. readonly groundMirror: Nullable<MirrorTexture>;
  107338. /**
  107339. * Gets the ground mirror render list to helps pushing the meshes
  107340. * you wish in the ground reflection.
  107341. */
  107342. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107343. private _groundMaterial;
  107344. /**
  107345. * Gets the ground material created by the helper.
  107346. */
  107347. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107348. /**
  107349. * Stores the creation options.
  107350. */
  107351. private readonly _scene;
  107352. private _options;
  107353. /**
  107354. * This observable will be notified with any error during the creation of the environment,
  107355. * mainly texture creation errors.
  107356. */
  107357. onErrorObservable: Observable<{
  107358. message?: string;
  107359. exception?: any;
  107360. }>;
  107361. /**
  107362. * constructor
  107363. * @param options Defines the options we want to customize the helper
  107364. * @param scene The scene to add the material to
  107365. */
  107366. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107367. /**
  107368. * Updates the background according to the new options
  107369. * @param options
  107370. */
  107371. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107372. /**
  107373. * Sets the primary color of all the available elements.
  107374. * @param color the main color to affect to the ground and the background
  107375. */
  107376. setMainColor(color: Color3): void;
  107377. /**
  107378. * Setup the image processing according to the specified options.
  107379. */
  107380. private _setupImageProcessing;
  107381. /**
  107382. * Setup the environment texture according to the specified options.
  107383. */
  107384. private _setupEnvironmentTexture;
  107385. /**
  107386. * Setup the background according to the specified options.
  107387. */
  107388. private _setupBackground;
  107389. /**
  107390. * Get the scene sizes according to the setup.
  107391. */
  107392. private _getSceneSize;
  107393. /**
  107394. * Setup the ground according to the specified options.
  107395. */
  107396. private _setupGround;
  107397. /**
  107398. * Setup the ground material according to the specified options.
  107399. */
  107400. private _setupGroundMaterial;
  107401. /**
  107402. * Setup the ground diffuse texture according to the specified options.
  107403. */
  107404. private _setupGroundDiffuseTexture;
  107405. /**
  107406. * Setup the ground mirror texture according to the specified options.
  107407. */
  107408. private _setupGroundMirrorTexture;
  107409. /**
  107410. * Setup the ground to receive the mirror texture.
  107411. */
  107412. private _setupMirrorInGroundMaterial;
  107413. /**
  107414. * Setup the skybox according to the specified options.
  107415. */
  107416. private _setupSkybox;
  107417. /**
  107418. * Setup the skybox material according to the specified options.
  107419. */
  107420. private _setupSkyboxMaterial;
  107421. /**
  107422. * Setup the skybox reflection texture according to the specified options.
  107423. */
  107424. private _setupSkyboxReflectionTexture;
  107425. private _errorHandler;
  107426. /**
  107427. * Dispose all the elements created by the Helper.
  107428. */
  107429. dispose(): void;
  107430. }
  107431. }
  107432. declare module BABYLON {
  107433. /**
  107434. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107435. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107436. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107437. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107438. */
  107439. export class PhotoDome extends TransformNode {
  107440. /**
  107441. * Define the image as a Monoscopic panoramic 360 image.
  107442. */
  107443. static readonly MODE_MONOSCOPIC: number;
  107444. /**
  107445. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107446. */
  107447. static readonly MODE_TOPBOTTOM: number;
  107448. /**
  107449. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107450. */
  107451. static readonly MODE_SIDEBYSIDE: number;
  107452. private _useDirectMapping;
  107453. /**
  107454. * The texture being displayed on the sphere
  107455. */
  107456. protected _photoTexture: Texture;
  107457. /**
  107458. * Gets or sets the texture being displayed on the sphere
  107459. */
  107460. photoTexture: Texture;
  107461. /**
  107462. * Observable raised when an error occured while loading the 360 image
  107463. */
  107464. onLoadErrorObservable: Observable<string>;
  107465. /**
  107466. * The skybox material
  107467. */
  107468. protected _material: BackgroundMaterial;
  107469. /**
  107470. * The surface used for the skybox
  107471. */
  107472. protected _mesh: Mesh;
  107473. /**
  107474. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107475. * Also see the options.resolution property.
  107476. */
  107477. fovMultiplier: number;
  107478. private _imageMode;
  107479. /**
  107480. * Gets or set the current video mode for the video. It can be:
  107481. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107482. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107483. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107484. */
  107485. imageMode: number;
  107486. /**
  107487. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107488. * @param name Element's name, child elements will append suffixes for their own names.
  107489. * @param urlsOfPhoto defines the url of the photo to display
  107490. * @param options defines an object containing optional or exposed sub element properties
  107491. * @param onError defines a callback called when an error occured while loading the texture
  107492. */
  107493. constructor(name: string, urlOfPhoto: string, options: {
  107494. resolution?: number;
  107495. size?: number;
  107496. useDirectMapping?: boolean;
  107497. faceForward?: boolean;
  107498. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107499. private _onBeforeCameraRenderObserver;
  107500. private _changeImageMode;
  107501. /**
  107502. * Releases resources associated with this node.
  107503. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107504. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107505. */
  107506. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107507. }
  107508. }
  107509. declare module BABYLON {
  107510. /** @hidden */
  107511. export var rgbdDecodePixelShader: {
  107512. name: string;
  107513. shader: string;
  107514. };
  107515. }
  107516. declare module BABYLON {
  107517. /**
  107518. * Class used to host texture specific utilities
  107519. */
  107520. export class BRDFTextureTools {
  107521. /**
  107522. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107523. * @param texture the texture to expand.
  107524. */
  107525. private static _ExpandDefaultBRDFTexture;
  107526. /**
  107527. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107528. * @param scene defines the hosting scene
  107529. * @returns the environment BRDF texture
  107530. */
  107531. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107532. private static _environmentBRDFBase64Texture;
  107533. }
  107534. }
  107535. declare module BABYLON {
  107536. /**
  107537. * @hidden
  107538. */
  107539. export interface IMaterialClearCoatDefines {
  107540. CLEARCOAT: boolean;
  107541. CLEARCOAT_DEFAULTIOR: boolean;
  107542. CLEARCOAT_TEXTURE: boolean;
  107543. CLEARCOAT_TEXTUREDIRECTUV: number;
  107544. CLEARCOAT_BUMP: boolean;
  107545. CLEARCOAT_BUMPDIRECTUV: number;
  107546. CLEARCOAT_TINT: boolean;
  107547. CLEARCOAT_TINT_TEXTURE: boolean;
  107548. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107549. /** @hidden */
  107550. _areTexturesDirty: boolean;
  107551. }
  107552. /**
  107553. * Define the code related to the clear coat parameters of the pbr material.
  107554. */
  107555. export class PBRClearCoatConfiguration {
  107556. /**
  107557. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107558. * The default fits with a polyurethane material.
  107559. */
  107560. private static readonly _DefaultIndexOfRefraction;
  107561. private _isEnabled;
  107562. /**
  107563. * Defines if the clear coat is enabled in the material.
  107564. */
  107565. isEnabled: boolean;
  107566. /**
  107567. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107568. */
  107569. intensity: number;
  107570. /**
  107571. * Defines the clear coat layer roughness.
  107572. */
  107573. roughness: number;
  107574. private _indexOfRefraction;
  107575. /**
  107576. * Defines the index of refraction of the clear coat.
  107577. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107578. * The default fits with a polyurethane material.
  107579. * Changing the default value is more performance intensive.
  107580. */
  107581. indexOfRefraction: number;
  107582. private _texture;
  107583. /**
  107584. * Stores the clear coat values in a texture.
  107585. */
  107586. texture: Nullable<BaseTexture>;
  107587. private _bumpTexture;
  107588. /**
  107589. * Define the clear coat specific bump texture.
  107590. */
  107591. bumpTexture: Nullable<BaseTexture>;
  107592. private _isTintEnabled;
  107593. /**
  107594. * Defines if the clear coat tint is enabled in the material.
  107595. */
  107596. isTintEnabled: boolean;
  107597. /**
  107598. * Defines the clear coat tint of the material.
  107599. * This is only use if tint is enabled
  107600. */
  107601. tintColor: Color3;
  107602. /**
  107603. * Defines the distance at which the tint color should be found in the
  107604. * clear coat media.
  107605. * This is only use if tint is enabled
  107606. */
  107607. tintColorAtDistance: number;
  107608. /**
  107609. * Defines the clear coat layer thickness.
  107610. * This is only use if tint is enabled
  107611. */
  107612. tintThickness: number;
  107613. private _tintTexture;
  107614. /**
  107615. * Stores the clear tint values in a texture.
  107616. * rgb is tint
  107617. * a is a thickness factor
  107618. */
  107619. tintTexture: Nullable<BaseTexture>;
  107620. /** @hidden */
  107621. private _internalMarkAllSubMeshesAsTexturesDirty;
  107622. /** @hidden */
  107623. _markAllSubMeshesAsTexturesDirty(): void;
  107624. /**
  107625. * Instantiate a new istance of clear coat configuration.
  107626. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107627. */
  107628. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107629. /**
  107630. * Gets wehter the submesh is ready to be used or not.
  107631. * @param defines the list of "defines" to update.
  107632. * @param scene defines the scene the material belongs to.
  107633. * @param engine defines the engine the material belongs to.
  107634. * @param disableBumpMap defines wether the material disables bump or not.
  107635. * @returns - boolean indicating that the submesh is ready or not.
  107636. */
  107637. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107638. /**
  107639. * Checks to see if a texture is used in the material.
  107640. * @param defines the list of "defines" to update.
  107641. * @param scene defines the scene to the material belongs to.
  107642. */
  107643. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107644. /**
  107645. * Binds the material data.
  107646. * @param uniformBuffer defines the Uniform buffer to fill in.
  107647. * @param scene defines the scene the material belongs to.
  107648. * @param engine defines the engine the material belongs to.
  107649. * @param disableBumpMap defines wether the material disables bump or not.
  107650. * @param isFrozen defines wether the material is frozen or not.
  107651. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107652. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107653. */
  107654. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107655. /**
  107656. * Checks to see if a texture is used in the material.
  107657. * @param texture - Base texture to use.
  107658. * @returns - Boolean specifying if a texture is used in the material.
  107659. */
  107660. hasTexture(texture: BaseTexture): boolean;
  107661. /**
  107662. * Returns an array of the actively used textures.
  107663. * @param activeTextures Array of BaseTextures
  107664. */
  107665. getActiveTextures(activeTextures: BaseTexture[]): void;
  107666. /**
  107667. * Returns the animatable textures.
  107668. * @param animatables Array of animatable textures.
  107669. */
  107670. getAnimatables(animatables: IAnimatable[]): void;
  107671. /**
  107672. * Disposes the resources of the material.
  107673. * @param forceDisposeTextures - Forces the disposal of all textures.
  107674. */
  107675. dispose(forceDisposeTextures?: boolean): void;
  107676. /**
  107677. * Get the current class name of the texture useful for serialization or dynamic coding.
  107678. * @returns "PBRClearCoatConfiguration"
  107679. */
  107680. getClassName(): string;
  107681. /**
  107682. * Add fallbacks to the effect fallbacks list.
  107683. * @param defines defines the Base texture to use.
  107684. * @param fallbacks defines the current fallback list.
  107685. * @param currentRank defines the current fallback rank.
  107686. * @returns the new fallback rank.
  107687. */
  107688. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107689. /**
  107690. * Add the required uniforms to the current list.
  107691. * @param uniforms defines the current uniform list.
  107692. */
  107693. static AddUniforms(uniforms: string[]): void;
  107694. /**
  107695. * Add the required samplers to the current list.
  107696. * @param samplers defines the current sampler list.
  107697. */
  107698. static AddSamplers(samplers: string[]): void;
  107699. /**
  107700. * Add the required uniforms to the current buffer.
  107701. * @param uniformBuffer defines the current uniform buffer.
  107702. */
  107703. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107704. /**
  107705. * Makes a duplicate of the current configuration into another one.
  107706. * @param clearCoatConfiguration define the config where to copy the info
  107707. */
  107708. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107709. /**
  107710. * Serializes this clear coat configuration.
  107711. * @returns - An object with the serialized config.
  107712. */
  107713. serialize(): any;
  107714. /**
  107715. * Parses a anisotropy Configuration from a serialized object.
  107716. * @param source - Serialized object.
  107717. * @param scene Defines the scene we are parsing for
  107718. * @param rootUrl Defines the rootUrl to load from
  107719. */
  107720. parse(source: any, scene: Scene, rootUrl: string): void;
  107721. }
  107722. }
  107723. declare module BABYLON {
  107724. /**
  107725. * @hidden
  107726. */
  107727. export interface IMaterialAnisotropicDefines {
  107728. ANISOTROPIC: boolean;
  107729. ANISOTROPIC_TEXTURE: boolean;
  107730. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107731. MAINUV1: boolean;
  107732. _areTexturesDirty: boolean;
  107733. _needUVs: boolean;
  107734. }
  107735. /**
  107736. * Define the code related to the anisotropic parameters of the pbr material.
  107737. */
  107738. export class PBRAnisotropicConfiguration {
  107739. private _isEnabled;
  107740. /**
  107741. * Defines if the anisotropy is enabled in the material.
  107742. */
  107743. isEnabled: boolean;
  107744. /**
  107745. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107746. */
  107747. intensity: number;
  107748. /**
  107749. * Defines if the effect is along the tangents, bitangents or in between.
  107750. * By default, the effect is "strectching" the highlights along the tangents.
  107751. */
  107752. direction: Vector2;
  107753. private _texture;
  107754. /**
  107755. * Stores the anisotropy values in a texture.
  107756. * rg is direction (like normal from -1 to 1)
  107757. * b is a intensity
  107758. */
  107759. texture: Nullable<BaseTexture>;
  107760. /** @hidden */
  107761. private _internalMarkAllSubMeshesAsTexturesDirty;
  107762. /** @hidden */
  107763. _markAllSubMeshesAsTexturesDirty(): void;
  107764. /**
  107765. * Instantiate a new istance of anisotropy configuration.
  107766. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107767. */
  107768. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107769. /**
  107770. * Specifies that the submesh is ready to be used.
  107771. * @param defines the list of "defines" to update.
  107772. * @param scene defines the scene the material belongs to.
  107773. * @returns - boolean indicating that the submesh is ready or not.
  107774. */
  107775. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107776. /**
  107777. * Checks to see if a texture is used in the material.
  107778. * @param defines the list of "defines" to update.
  107779. * @param mesh the mesh we are preparing the defines for.
  107780. * @param scene defines the scene the material belongs to.
  107781. */
  107782. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107783. /**
  107784. * Binds the material data.
  107785. * @param uniformBuffer defines the Uniform buffer to fill in.
  107786. * @param scene defines the scene the material belongs to.
  107787. * @param isFrozen defines wether the material is frozen or not.
  107788. */
  107789. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107790. /**
  107791. * Checks to see if a texture is used in the material.
  107792. * @param texture - Base texture to use.
  107793. * @returns - Boolean specifying if a texture is used in the material.
  107794. */
  107795. hasTexture(texture: BaseTexture): boolean;
  107796. /**
  107797. * Returns an array of the actively used textures.
  107798. * @param activeTextures Array of BaseTextures
  107799. */
  107800. getActiveTextures(activeTextures: BaseTexture[]): void;
  107801. /**
  107802. * Returns the animatable textures.
  107803. * @param animatables Array of animatable textures.
  107804. */
  107805. getAnimatables(animatables: IAnimatable[]): void;
  107806. /**
  107807. * Disposes the resources of the material.
  107808. * @param forceDisposeTextures - Forces the disposal of all textures.
  107809. */
  107810. dispose(forceDisposeTextures?: boolean): void;
  107811. /**
  107812. * Get the current class name of the texture useful for serialization or dynamic coding.
  107813. * @returns "PBRAnisotropicConfiguration"
  107814. */
  107815. getClassName(): string;
  107816. /**
  107817. * Add fallbacks to the effect fallbacks list.
  107818. * @param defines defines the Base texture to use.
  107819. * @param fallbacks defines the current fallback list.
  107820. * @param currentRank defines the current fallback rank.
  107821. * @returns the new fallback rank.
  107822. */
  107823. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107824. /**
  107825. * Add the required uniforms to the current list.
  107826. * @param uniforms defines the current uniform list.
  107827. */
  107828. static AddUniforms(uniforms: string[]): void;
  107829. /**
  107830. * Add the required uniforms to the current buffer.
  107831. * @param uniformBuffer defines the current uniform buffer.
  107832. */
  107833. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107834. /**
  107835. * Add the required samplers to the current list.
  107836. * @param samplers defines the current sampler list.
  107837. */
  107838. static AddSamplers(samplers: string[]): void;
  107839. /**
  107840. * Makes a duplicate of the current configuration into another one.
  107841. * @param anisotropicConfiguration define the config where to copy the info
  107842. */
  107843. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107844. /**
  107845. * Serializes this anisotropy configuration.
  107846. * @returns - An object with the serialized config.
  107847. */
  107848. serialize(): any;
  107849. /**
  107850. * Parses a anisotropy Configuration from a serialized object.
  107851. * @param source - Serialized object.
  107852. * @param scene Defines the scene we are parsing for
  107853. * @param rootUrl Defines the rootUrl to load from
  107854. */
  107855. parse(source: any, scene: Scene, rootUrl: string): void;
  107856. }
  107857. }
  107858. declare module BABYLON {
  107859. /**
  107860. * @hidden
  107861. */
  107862. export interface IMaterialBRDFDefines {
  107863. BRDF_V_HEIGHT_CORRELATED: boolean;
  107864. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107865. SPHERICAL_HARMONICS: boolean;
  107866. /** @hidden */
  107867. _areMiscDirty: boolean;
  107868. }
  107869. /**
  107870. * Define the code related to the BRDF parameters of the pbr material.
  107871. */
  107872. export class PBRBRDFConfiguration {
  107873. /**
  107874. * Default value used for the energy conservation.
  107875. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107876. */
  107877. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107878. /**
  107879. * Default value used for the Smith Visibility Height Correlated mode.
  107880. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107881. */
  107882. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107883. /**
  107884. * Default value used for the IBL diffuse part.
  107885. * This can help switching back to the polynomials mode globally which is a tiny bit
  107886. * less GPU intensive at the drawback of a lower quality.
  107887. */
  107888. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107889. private _useEnergyConservation;
  107890. /**
  107891. * Defines if the material uses energy conservation.
  107892. */
  107893. useEnergyConservation: boolean;
  107894. private _useSmithVisibilityHeightCorrelated;
  107895. /**
  107896. * LEGACY Mode set to false
  107897. * Defines if the material uses height smith correlated visibility term.
  107898. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107899. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107900. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107901. * Not relying on height correlated will also disable energy conservation.
  107902. */
  107903. useSmithVisibilityHeightCorrelated: boolean;
  107904. private _useSphericalHarmonics;
  107905. /**
  107906. * LEGACY Mode set to false
  107907. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107908. * diffuse part of the IBL.
  107909. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107910. * to the ground truth.
  107911. */
  107912. useSphericalHarmonics: boolean;
  107913. /** @hidden */
  107914. private _internalMarkAllSubMeshesAsMiscDirty;
  107915. /** @hidden */
  107916. _markAllSubMeshesAsMiscDirty(): void;
  107917. /**
  107918. * Instantiate a new istance of clear coat configuration.
  107919. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107920. */
  107921. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107922. /**
  107923. * Checks to see if a texture is used in the material.
  107924. * @param defines the list of "defines" to update.
  107925. */
  107926. prepareDefines(defines: IMaterialBRDFDefines): void;
  107927. /**
  107928. * Get the current class name of the texture useful for serialization or dynamic coding.
  107929. * @returns "PBRClearCoatConfiguration"
  107930. */
  107931. getClassName(): string;
  107932. /**
  107933. * Makes a duplicate of the current configuration into another one.
  107934. * @param brdfConfiguration define the config where to copy the info
  107935. */
  107936. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107937. /**
  107938. * Serializes this BRDF configuration.
  107939. * @returns - An object with the serialized config.
  107940. */
  107941. serialize(): any;
  107942. /**
  107943. * Parses a anisotropy Configuration from a serialized object.
  107944. * @param source - Serialized object.
  107945. * @param scene Defines the scene we are parsing for
  107946. * @param rootUrl Defines the rootUrl to load from
  107947. */
  107948. parse(source: any, scene: Scene, rootUrl: string): void;
  107949. }
  107950. }
  107951. declare module BABYLON {
  107952. /**
  107953. * @hidden
  107954. */
  107955. export interface IMaterialSheenDefines {
  107956. SHEEN: boolean;
  107957. SHEEN_TEXTURE: boolean;
  107958. SHEEN_TEXTUREDIRECTUV: number;
  107959. SHEEN_LINKWITHALBEDO: boolean;
  107960. /** @hidden */
  107961. _areTexturesDirty: boolean;
  107962. }
  107963. /**
  107964. * Define the code related to the Sheen parameters of the pbr material.
  107965. */
  107966. export class PBRSheenConfiguration {
  107967. private _isEnabled;
  107968. /**
  107969. * Defines if the material uses sheen.
  107970. */
  107971. isEnabled: boolean;
  107972. private _linkSheenWithAlbedo;
  107973. /**
  107974. * Defines if the sheen is linked to the sheen color.
  107975. */
  107976. linkSheenWithAlbedo: boolean;
  107977. /**
  107978. * Defines the sheen intensity.
  107979. */
  107980. intensity: number;
  107981. /**
  107982. * Defines the sheen color.
  107983. */
  107984. color: Color3;
  107985. private _texture;
  107986. /**
  107987. * Stores the sheen tint values in a texture.
  107988. * rgb is tint
  107989. * a is a intensity
  107990. */
  107991. texture: Nullable<BaseTexture>;
  107992. /** @hidden */
  107993. private _internalMarkAllSubMeshesAsTexturesDirty;
  107994. /** @hidden */
  107995. _markAllSubMeshesAsTexturesDirty(): void;
  107996. /**
  107997. * Instantiate a new istance of clear coat configuration.
  107998. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107999. */
  108000. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108001. /**
  108002. * Specifies that the submesh is ready to be used.
  108003. * @param defines the list of "defines" to update.
  108004. * @param scene defines the scene the material belongs to.
  108005. * @returns - boolean indicating that the submesh is ready or not.
  108006. */
  108007. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  108008. /**
  108009. * Checks to see if a texture is used in the material.
  108010. * @param defines the list of "defines" to update.
  108011. * @param scene defines the scene the material belongs to.
  108012. */
  108013. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  108014. /**
  108015. * Binds the material data.
  108016. * @param uniformBuffer defines the Uniform buffer to fill in.
  108017. * @param scene defines the scene the material belongs to.
  108018. * @param isFrozen defines wether the material is frozen or not.
  108019. */
  108020. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108021. /**
  108022. * Checks to see if a texture is used in the material.
  108023. * @param texture - Base texture to use.
  108024. * @returns - Boolean specifying if a texture is used in the material.
  108025. */
  108026. hasTexture(texture: BaseTexture): boolean;
  108027. /**
  108028. * Returns an array of the actively used textures.
  108029. * @param activeTextures Array of BaseTextures
  108030. */
  108031. getActiveTextures(activeTextures: BaseTexture[]): void;
  108032. /**
  108033. * Returns the animatable textures.
  108034. * @param animatables Array of animatable textures.
  108035. */
  108036. getAnimatables(animatables: IAnimatable[]): void;
  108037. /**
  108038. * Disposes the resources of the material.
  108039. * @param forceDisposeTextures - Forces the disposal of all textures.
  108040. */
  108041. dispose(forceDisposeTextures?: boolean): void;
  108042. /**
  108043. * Get the current class name of the texture useful for serialization or dynamic coding.
  108044. * @returns "PBRSheenConfiguration"
  108045. */
  108046. getClassName(): string;
  108047. /**
  108048. * Add fallbacks to the effect fallbacks list.
  108049. * @param defines defines the Base texture to use.
  108050. * @param fallbacks defines the current fallback list.
  108051. * @param currentRank defines the current fallback rank.
  108052. * @returns the new fallback rank.
  108053. */
  108054. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108055. /**
  108056. * Add the required uniforms to the current list.
  108057. * @param uniforms defines the current uniform list.
  108058. */
  108059. static AddUniforms(uniforms: string[]): void;
  108060. /**
  108061. * Add the required uniforms to the current buffer.
  108062. * @param uniformBuffer defines the current uniform buffer.
  108063. */
  108064. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108065. /**
  108066. * Add the required samplers to the current list.
  108067. * @param samplers defines the current sampler list.
  108068. */
  108069. static AddSamplers(samplers: string[]): void;
  108070. /**
  108071. * Makes a duplicate of the current configuration into another one.
  108072. * @param sheenConfiguration define the config where to copy the info
  108073. */
  108074. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  108075. /**
  108076. * Serializes this BRDF configuration.
  108077. * @returns - An object with the serialized config.
  108078. */
  108079. serialize(): any;
  108080. /**
  108081. * Parses a anisotropy Configuration from a serialized object.
  108082. * @param source - Serialized object.
  108083. * @param scene Defines the scene we are parsing for
  108084. * @param rootUrl Defines the rootUrl to load from
  108085. */
  108086. parse(source: any, scene: Scene, rootUrl: string): void;
  108087. }
  108088. }
  108089. declare module BABYLON {
  108090. /**
  108091. * @hidden
  108092. */
  108093. export interface IMaterialSubSurfaceDefines {
  108094. SUBSURFACE: boolean;
  108095. SS_REFRACTION: boolean;
  108096. SS_TRANSLUCENCY: boolean;
  108097. SS_SCATERRING: boolean;
  108098. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108099. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108100. SS_REFRACTIONMAP_3D: boolean;
  108101. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108102. SS_LODINREFRACTIONALPHA: boolean;
  108103. SS_GAMMAREFRACTION: boolean;
  108104. SS_RGBDREFRACTION: boolean;
  108105. SS_LINEARSPECULARREFRACTION: boolean;
  108106. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108107. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108108. /** @hidden */
  108109. _areTexturesDirty: boolean;
  108110. }
  108111. /**
  108112. * Define the code related to the sub surface parameters of the pbr material.
  108113. */
  108114. export class PBRSubSurfaceConfiguration {
  108115. private _isRefractionEnabled;
  108116. /**
  108117. * Defines if the refraction is enabled in the material.
  108118. */
  108119. isRefractionEnabled: boolean;
  108120. private _isTranslucencyEnabled;
  108121. /**
  108122. * Defines if the translucency is enabled in the material.
  108123. */
  108124. isTranslucencyEnabled: boolean;
  108125. private _isScatteringEnabled;
  108126. /**
  108127. * Defines the refraction intensity of the material.
  108128. * The refraction when enabled replaces the Diffuse part of the material.
  108129. * The intensity helps transitionning between diffuse and refraction.
  108130. */
  108131. refractionIntensity: number;
  108132. /**
  108133. * Defines the translucency intensity of the material.
  108134. * When translucency has been enabled, this defines how much of the "translucency"
  108135. * is addded to the diffuse part of the material.
  108136. */
  108137. translucencyIntensity: number;
  108138. /**
  108139. * Defines the scattering intensity of the material.
  108140. * When scattering has been enabled, this defines how much of the "scattered light"
  108141. * is addded to the diffuse part of the material.
  108142. */
  108143. scatteringIntensity: number;
  108144. private _thicknessTexture;
  108145. /**
  108146. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  108147. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  108148. * 0 would mean minimumThickness
  108149. * 1 would mean maximumThickness
  108150. * The other channels might be use as a mask to vary the different effects intensity.
  108151. */
  108152. thicknessTexture: Nullable<BaseTexture>;
  108153. private _refractionTexture;
  108154. /**
  108155. * Defines the texture to use for refraction.
  108156. */
  108157. refractionTexture: Nullable<BaseTexture>;
  108158. private _indexOfRefraction;
  108159. /**
  108160. * Defines the index of refraction used in the material.
  108161. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108162. */
  108163. indexOfRefraction: number;
  108164. private _invertRefractionY;
  108165. /**
  108166. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108167. */
  108168. invertRefractionY: boolean;
  108169. private _linkRefractionWithTransparency;
  108170. /**
  108171. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108172. * Materials half opaque for instance using refraction could benefit from this control.
  108173. */
  108174. linkRefractionWithTransparency: boolean;
  108175. /**
  108176. * Defines the minimum thickness stored in the thickness map.
  108177. * If no thickness map is defined, this value will be used to simulate thickness.
  108178. */
  108179. minimumThickness: number;
  108180. /**
  108181. * Defines the maximum thickness stored in the thickness map.
  108182. */
  108183. maximumThickness: number;
  108184. /**
  108185. * Defines the volume tint of the material.
  108186. * This is used for both translucency and scattering.
  108187. */
  108188. tintColor: Color3;
  108189. /**
  108190. * Defines the distance at which the tint color should be found in the media.
  108191. * This is used for refraction only.
  108192. */
  108193. tintColorAtDistance: number;
  108194. /**
  108195. * Defines how far each channel transmit through the media.
  108196. * It is defined as a color to simplify it selection.
  108197. */
  108198. diffusionDistance: Color3;
  108199. private _useMaskFromThicknessTexture;
  108200. /**
  108201. * Stores the intensity of the different subsurface effects in the thickness texture.
  108202. * * the green channel is the translucency intensity.
  108203. * * the blue channel is the scattering intensity.
  108204. * * the alpha channel is the refraction intensity.
  108205. */
  108206. useMaskFromThicknessTexture: boolean;
  108207. /** @hidden */
  108208. private _internalMarkAllSubMeshesAsTexturesDirty;
  108209. /** @hidden */
  108210. _markAllSubMeshesAsTexturesDirty(): void;
  108211. /**
  108212. * Instantiate a new istance of sub surface configuration.
  108213. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108214. */
  108215. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108216. /**
  108217. * Gets wehter the submesh is ready to be used or not.
  108218. * @param defines the list of "defines" to update.
  108219. * @param scene defines the scene the material belongs to.
  108220. * @returns - boolean indicating that the submesh is ready or not.
  108221. */
  108222. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  108223. /**
  108224. * Checks to see if a texture is used in the material.
  108225. * @param defines the list of "defines" to update.
  108226. * @param scene defines the scene to the material belongs to.
  108227. */
  108228. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  108229. /**
  108230. * Binds the material data.
  108231. * @param uniformBuffer defines the Uniform buffer to fill in.
  108232. * @param scene defines the scene the material belongs to.
  108233. * @param engine defines the engine the material belongs to.
  108234. * @param isFrozen defines wether the material is frozen or not.
  108235. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  108236. */
  108237. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  108238. /**
  108239. * Unbinds the material from the mesh.
  108240. * @param activeEffect defines the effect that should be unbound from.
  108241. * @returns true if unbound, otherwise false
  108242. */
  108243. unbind(activeEffect: Effect): boolean;
  108244. /**
  108245. * Returns the texture used for refraction or null if none is used.
  108246. * @param scene defines the scene the material belongs to.
  108247. * @returns - Refraction texture if present. If no refraction texture and refraction
  108248. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108249. */
  108250. private _getRefractionTexture;
  108251. /**
  108252. * Returns true if alpha blending should be disabled.
  108253. */
  108254. readonly disableAlphaBlending: boolean;
  108255. /**
  108256. * Fills the list of render target textures.
  108257. * @param renderTargets the list of render targets to update
  108258. */
  108259. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108260. /**
  108261. * Checks to see if a texture is used in the material.
  108262. * @param texture - Base texture to use.
  108263. * @returns - Boolean specifying if a texture is used in the material.
  108264. */
  108265. hasTexture(texture: BaseTexture): boolean;
  108266. /**
  108267. * Gets a boolean indicating that current material needs to register RTT
  108268. * @returns true if this uses a render target otherwise false.
  108269. */
  108270. hasRenderTargetTextures(): boolean;
  108271. /**
  108272. * Returns an array of the actively used textures.
  108273. * @param activeTextures Array of BaseTextures
  108274. */
  108275. getActiveTextures(activeTextures: BaseTexture[]): void;
  108276. /**
  108277. * Returns the animatable textures.
  108278. * @param animatables Array of animatable textures.
  108279. */
  108280. getAnimatables(animatables: IAnimatable[]): void;
  108281. /**
  108282. * Disposes the resources of the material.
  108283. * @param forceDisposeTextures - Forces the disposal of all textures.
  108284. */
  108285. dispose(forceDisposeTextures?: boolean): void;
  108286. /**
  108287. * Get the current class name of the texture useful for serialization or dynamic coding.
  108288. * @returns "PBRSubSurfaceConfiguration"
  108289. */
  108290. getClassName(): string;
  108291. /**
  108292. * Add fallbacks to the effect fallbacks list.
  108293. * @param defines defines the Base texture to use.
  108294. * @param fallbacks defines the current fallback list.
  108295. * @param currentRank defines the current fallback rank.
  108296. * @returns the new fallback rank.
  108297. */
  108298. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108299. /**
  108300. * Add the required uniforms to the current list.
  108301. * @param uniforms defines the current uniform list.
  108302. */
  108303. static AddUniforms(uniforms: string[]): void;
  108304. /**
  108305. * Add the required samplers to the current list.
  108306. * @param samplers defines the current sampler list.
  108307. */
  108308. static AddSamplers(samplers: string[]): void;
  108309. /**
  108310. * Add the required uniforms to the current buffer.
  108311. * @param uniformBuffer defines the current uniform buffer.
  108312. */
  108313. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108314. /**
  108315. * Makes a duplicate of the current configuration into another one.
  108316. * @param configuration define the config where to copy the info
  108317. */
  108318. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108319. /**
  108320. * Serializes this Sub Surface configuration.
  108321. * @returns - An object with the serialized config.
  108322. */
  108323. serialize(): any;
  108324. /**
  108325. * Parses a anisotropy Configuration from a serialized object.
  108326. * @param source - Serialized object.
  108327. * @param scene Defines the scene we are parsing for
  108328. * @param rootUrl Defines the rootUrl to load from
  108329. */
  108330. parse(source: any, scene: Scene, rootUrl: string): void;
  108331. }
  108332. }
  108333. declare module BABYLON {
  108334. /** @hidden */
  108335. export var pbrFragmentDeclaration: {
  108336. name: string;
  108337. shader: string;
  108338. };
  108339. }
  108340. declare module BABYLON {
  108341. /** @hidden */
  108342. export var pbrUboDeclaration: {
  108343. name: string;
  108344. shader: string;
  108345. };
  108346. }
  108347. declare module BABYLON {
  108348. /** @hidden */
  108349. export var pbrFragmentExtraDeclaration: {
  108350. name: string;
  108351. shader: string;
  108352. };
  108353. }
  108354. declare module BABYLON {
  108355. /** @hidden */
  108356. export var pbrFragmentSamplersDeclaration: {
  108357. name: string;
  108358. shader: string;
  108359. };
  108360. }
  108361. declare module BABYLON {
  108362. /** @hidden */
  108363. export var pbrHelperFunctions: {
  108364. name: string;
  108365. shader: string;
  108366. };
  108367. }
  108368. declare module BABYLON {
  108369. /** @hidden */
  108370. export var harmonicsFunctions: {
  108371. name: string;
  108372. shader: string;
  108373. };
  108374. }
  108375. declare module BABYLON {
  108376. /** @hidden */
  108377. export var pbrDirectLightingSetupFunctions: {
  108378. name: string;
  108379. shader: string;
  108380. };
  108381. }
  108382. declare module BABYLON {
  108383. /** @hidden */
  108384. export var pbrDirectLightingFalloffFunctions: {
  108385. name: string;
  108386. shader: string;
  108387. };
  108388. }
  108389. declare module BABYLON {
  108390. /** @hidden */
  108391. export var pbrBRDFFunctions: {
  108392. name: string;
  108393. shader: string;
  108394. };
  108395. }
  108396. declare module BABYLON {
  108397. /** @hidden */
  108398. export var pbrDirectLightingFunctions: {
  108399. name: string;
  108400. shader: string;
  108401. };
  108402. }
  108403. declare module BABYLON {
  108404. /** @hidden */
  108405. export var pbrIBLFunctions: {
  108406. name: string;
  108407. shader: string;
  108408. };
  108409. }
  108410. declare module BABYLON {
  108411. /** @hidden */
  108412. export var pbrDebug: {
  108413. name: string;
  108414. shader: string;
  108415. };
  108416. }
  108417. declare module BABYLON {
  108418. /** @hidden */
  108419. export var pbrPixelShader: {
  108420. name: string;
  108421. shader: string;
  108422. };
  108423. }
  108424. declare module BABYLON {
  108425. /** @hidden */
  108426. export var pbrVertexDeclaration: {
  108427. name: string;
  108428. shader: string;
  108429. };
  108430. }
  108431. declare module BABYLON {
  108432. /** @hidden */
  108433. export var pbrVertexShader: {
  108434. name: string;
  108435. shader: string;
  108436. };
  108437. }
  108438. declare module BABYLON {
  108439. /**
  108440. * Manages the defines for the PBR Material.
  108441. * @hidden
  108442. */
  108443. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108444. PBR: boolean;
  108445. MAINUV1: boolean;
  108446. MAINUV2: boolean;
  108447. UV1: boolean;
  108448. UV2: boolean;
  108449. ALBEDO: boolean;
  108450. ALBEDODIRECTUV: number;
  108451. VERTEXCOLOR: boolean;
  108452. AMBIENT: boolean;
  108453. AMBIENTDIRECTUV: number;
  108454. AMBIENTINGRAYSCALE: boolean;
  108455. OPACITY: boolean;
  108456. VERTEXALPHA: boolean;
  108457. OPACITYDIRECTUV: number;
  108458. OPACITYRGB: boolean;
  108459. ALPHATEST: boolean;
  108460. DEPTHPREPASS: boolean;
  108461. ALPHABLEND: boolean;
  108462. ALPHAFROMALBEDO: boolean;
  108463. ALPHATESTVALUE: string;
  108464. SPECULAROVERALPHA: boolean;
  108465. RADIANCEOVERALPHA: boolean;
  108466. ALPHAFRESNEL: boolean;
  108467. LINEARALPHAFRESNEL: boolean;
  108468. PREMULTIPLYALPHA: boolean;
  108469. EMISSIVE: boolean;
  108470. EMISSIVEDIRECTUV: number;
  108471. REFLECTIVITY: boolean;
  108472. REFLECTIVITYDIRECTUV: number;
  108473. SPECULARTERM: boolean;
  108474. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108475. MICROSURFACEAUTOMATIC: boolean;
  108476. LODBASEDMICROSFURACE: boolean;
  108477. MICROSURFACEMAP: boolean;
  108478. MICROSURFACEMAPDIRECTUV: number;
  108479. METALLICWORKFLOW: boolean;
  108480. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108481. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108482. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108483. AOSTOREINMETALMAPRED: boolean;
  108484. ENVIRONMENTBRDF: boolean;
  108485. ENVIRONMENTBRDF_RGBD: boolean;
  108486. NORMAL: boolean;
  108487. TANGENT: boolean;
  108488. BUMP: boolean;
  108489. BUMPDIRECTUV: number;
  108490. OBJECTSPACE_NORMALMAP: boolean;
  108491. PARALLAX: boolean;
  108492. PARALLAXOCCLUSION: boolean;
  108493. NORMALXYSCALE: boolean;
  108494. LIGHTMAP: boolean;
  108495. LIGHTMAPDIRECTUV: number;
  108496. USELIGHTMAPASSHADOWMAP: boolean;
  108497. GAMMALIGHTMAP: boolean;
  108498. REFLECTION: boolean;
  108499. REFLECTIONMAP_3D: boolean;
  108500. REFLECTIONMAP_SPHERICAL: boolean;
  108501. REFLECTIONMAP_PLANAR: boolean;
  108502. REFLECTIONMAP_CUBIC: boolean;
  108503. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108504. REFLECTIONMAP_PROJECTION: boolean;
  108505. REFLECTIONMAP_SKYBOX: boolean;
  108506. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108507. REFLECTIONMAP_EXPLICIT: boolean;
  108508. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108509. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108510. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108511. INVERTCUBICMAP: boolean;
  108512. USESPHERICALFROMREFLECTIONMAP: boolean;
  108513. USEIRRADIANCEMAP: boolean;
  108514. SPHERICAL_HARMONICS: boolean;
  108515. USESPHERICALINVERTEX: boolean;
  108516. REFLECTIONMAP_OPPOSITEZ: boolean;
  108517. LODINREFLECTIONALPHA: boolean;
  108518. GAMMAREFLECTION: boolean;
  108519. RGBDREFLECTION: boolean;
  108520. LINEARSPECULARREFLECTION: boolean;
  108521. RADIANCEOCCLUSION: boolean;
  108522. HORIZONOCCLUSION: boolean;
  108523. INSTANCES: boolean;
  108524. NUM_BONE_INFLUENCERS: number;
  108525. BonesPerMesh: number;
  108526. BONETEXTURE: boolean;
  108527. NONUNIFORMSCALING: boolean;
  108528. MORPHTARGETS: boolean;
  108529. MORPHTARGETS_NORMAL: boolean;
  108530. MORPHTARGETS_TANGENT: boolean;
  108531. MORPHTARGETS_UV: boolean;
  108532. NUM_MORPH_INFLUENCERS: number;
  108533. IMAGEPROCESSING: boolean;
  108534. VIGNETTE: boolean;
  108535. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108536. VIGNETTEBLENDMODEOPAQUE: boolean;
  108537. TONEMAPPING: boolean;
  108538. TONEMAPPING_ACES: boolean;
  108539. CONTRAST: boolean;
  108540. COLORCURVES: boolean;
  108541. COLORGRADING: boolean;
  108542. COLORGRADING3D: boolean;
  108543. SAMPLER3DGREENDEPTH: boolean;
  108544. SAMPLER3DBGRMAP: boolean;
  108545. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108546. EXPOSURE: boolean;
  108547. MULTIVIEW: boolean;
  108548. USEPHYSICALLIGHTFALLOFF: boolean;
  108549. USEGLTFLIGHTFALLOFF: boolean;
  108550. TWOSIDEDLIGHTING: boolean;
  108551. SHADOWFLOAT: boolean;
  108552. CLIPPLANE: boolean;
  108553. CLIPPLANE2: boolean;
  108554. CLIPPLANE3: boolean;
  108555. CLIPPLANE4: boolean;
  108556. POINTSIZE: boolean;
  108557. FOG: boolean;
  108558. LOGARITHMICDEPTH: boolean;
  108559. FORCENORMALFORWARD: boolean;
  108560. SPECULARAA: boolean;
  108561. CLEARCOAT: boolean;
  108562. CLEARCOAT_DEFAULTIOR: boolean;
  108563. CLEARCOAT_TEXTURE: boolean;
  108564. CLEARCOAT_TEXTUREDIRECTUV: number;
  108565. CLEARCOAT_BUMP: boolean;
  108566. CLEARCOAT_BUMPDIRECTUV: number;
  108567. CLEARCOAT_TINT: boolean;
  108568. CLEARCOAT_TINT_TEXTURE: boolean;
  108569. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108570. ANISOTROPIC: boolean;
  108571. ANISOTROPIC_TEXTURE: boolean;
  108572. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108573. BRDF_V_HEIGHT_CORRELATED: boolean;
  108574. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108575. SHEEN: boolean;
  108576. SHEEN_TEXTURE: boolean;
  108577. SHEEN_TEXTUREDIRECTUV: number;
  108578. SHEEN_LINKWITHALBEDO: boolean;
  108579. SUBSURFACE: boolean;
  108580. SS_REFRACTION: boolean;
  108581. SS_TRANSLUCENCY: boolean;
  108582. SS_SCATERRING: boolean;
  108583. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108584. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108585. SS_REFRACTIONMAP_3D: boolean;
  108586. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108587. SS_LODINREFRACTIONALPHA: boolean;
  108588. SS_GAMMAREFRACTION: boolean;
  108589. SS_RGBDREFRACTION: boolean;
  108590. SS_LINEARSPECULARREFRACTION: boolean;
  108591. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108592. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108593. UNLIT: boolean;
  108594. DEBUGMODE: number;
  108595. /**
  108596. * Initializes the PBR Material defines.
  108597. */
  108598. constructor();
  108599. /**
  108600. * Resets the PBR Material defines.
  108601. */
  108602. reset(): void;
  108603. }
  108604. /**
  108605. * The Physically based material base class of BJS.
  108606. *
  108607. * This offers the main features of a standard PBR material.
  108608. * For more information, please refer to the documentation :
  108609. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108610. */
  108611. export abstract class PBRBaseMaterial extends PushMaterial {
  108612. /**
  108613. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108614. */
  108615. static readonly PBRMATERIAL_OPAQUE: number;
  108616. /**
  108617. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108618. */
  108619. static readonly PBRMATERIAL_ALPHATEST: number;
  108620. /**
  108621. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108622. */
  108623. static readonly PBRMATERIAL_ALPHABLEND: number;
  108624. /**
  108625. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108626. * They are also discarded below the alpha cutoff threshold to improve performances.
  108627. */
  108628. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108629. /**
  108630. * Defines the default value of how much AO map is occluding the analytical lights
  108631. * (point spot...).
  108632. */
  108633. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108634. /**
  108635. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108636. */
  108637. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108638. /**
  108639. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108640. * to enhance interoperability with other engines.
  108641. */
  108642. static readonly LIGHTFALLOFF_GLTF: number;
  108643. /**
  108644. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108645. * to enhance interoperability with other materials.
  108646. */
  108647. static readonly LIGHTFALLOFF_STANDARD: number;
  108648. /**
  108649. * Intensity of the direct lights e.g. the four lights available in your scene.
  108650. * This impacts both the direct diffuse and specular highlights.
  108651. */
  108652. protected _directIntensity: number;
  108653. /**
  108654. * Intensity of the emissive part of the material.
  108655. * This helps controlling the emissive effect without modifying the emissive color.
  108656. */
  108657. protected _emissiveIntensity: number;
  108658. /**
  108659. * Intensity of the environment e.g. how much the environment will light the object
  108660. * either through harmonics for rough material or through the refelction for shiny ones.
  108661. */
  108662. protected _environmentIntensity: number;
  108663. /**
  108664. * This is a special control allowing the reduction of the specular highlights coming from the
  108665. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108666. */
  108667. protected _specularIntensity: number;
  108668. /**
  108669. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108670. */
  108671. private _lightingInfos;
  108672. /**
  108673. * Debug Control allowing disabling the bump map on this material.
  108674. */
  108675. protected _disableBumpMap: boolean;
  108676. /**
  108677. * AKA Diffuse Texture in standard nomenclature.
  108678. */
  108679. protected _albedoTexture: Nullable<BaseTexture>;
  108680. /**
  108681. * AKA Occlusion Texture in other nomenclature.
  108682. */
  108683. protected _ambientTexture: Nullable<BaseTexture>;
  108684. /**
  108685. * AKA Occlusion Texture Intensity in other nomenclature.
  108686. */
  108687. protected _ambientTextureStrength: number;
  108688. /**
  108689. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108690. * 1 means it completely occludes it
  108691. * 0 mean it has no impact
  108692. */
  108693. protected _ambientTextureImpactOnAnalyticalLights: number;
  108694. /**
  108695. * Stores the alpha values in a texture.
  108696. */
  108697. protected _opacityTexture: Nullable<BaseTexture>;
  108698. /**
  108699. * Stores the reflection values in a texture.
  108700. */
  108701. protected _reflectionTexture: Nullable<BaseTexture>;
  108702. /**
  108703. * Stores the emissive values in a texture.
  108704. */
  108705. protected _emissiveTexture: Nullable<BaseTexture>;
  108706. /**
  108707. * AKA Specular texture in other nomenclature.
  108708. */
  108709. protected _reflectivityTexture: Nullable<BaseTexture>;
  108710. /**
  108711. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108712. */
  108713. protected _metallicTexture: Nullable<BaseTexture>;
  108714. /**
  108715. * Specifies the metallic scalar of the metallic/roughness workflow.
  108716. * Can also be used to scale the metalness values of the metallic texture.
  108717. */
  108718. protected _metallic: Nullable<number>;
  108719. /**
  108720. * Specifies the roughness scalar of the metallic/roughness workflow.
  108721. * Can also be used to scale the roughness values of the metallic texture.
  108722. */
  108723. protected _roughness: Nullable<number>;
  108724. /**
  108725. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108726. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108727. */
  108728. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108729. /**
  108730. * Stores surface normal data used to displace a mesh in a texture.
  108731. */
  108732. protected _bumpTexture: Nullable<BaseTexture>;
  108733. /**
  108734. * Stores the pre-calculated light information of a mesh in a texture.
  108735. */
  108736. protected _lightmapTexture: Nullable<BaseTexture>;
  108737. /**
  108738. * The color of a material in ambient lighting.
  108739. */
  108740. protected _ambientColor: Color3;
  108741. /**
  108742. * AKA Diffuse Color in other nomenclature.
  108743. */
  108744. protected _albedoColor: Color3;
  108745. /**
  108746. * AKA Specular Color in other nomenclature.
  108747. */
  108748. protected _reflectivityColor: Color3;
  108749. /**
  108750. * The color applied when light is reflected from a material.
  108751. */
  108752. protected _reflectionColor: Color3;
  108753. /**
  108754. * The color applied when light is emitted from a material.
  108755. */
  108756. protected _emissiveColor: Color3;
  108757. /**
  108758. * AKA Glossiness in other nomenclature.
  108759. */
  108760. protected _microSurface: number;
  108761. /**
  108762. * Specifies that the material will use the light map as a show map.
  108763. */
  108764. protected _useLightmapAsShadowmap: boolean;
  108765. /**
  108766. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108767. * makes the reflect vector face the model (under horizon).
  108768. */
  108769. protected _useHorizonOcclusion: boolean;
  108770. /**
  108771. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108772. * too much the area relying on ambient texture to define their ambient occlusion.
  108773. */
  108774. protected _useRadianceOcclusion: boolean;
  108775. /**
  108776. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108777. */
  108778. protected _useAlphaFromAlbedoTexture: boolean;
  108779. /**
  108780. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108781. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108782. */
  108783. protected _useSpecularOverAlpha: boolean;
  108784. /**
  108785. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108786. */
  108787. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108788. /**
  108789. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108790. */
  108791. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108792. /**
  108793. * Specifies if the metallic texture contains the roughness information in its green channel.
  108794. */
  108795. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108796. /**
  108797. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108798. */
  108799. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108800. /**
  108801. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108802. */
  108803. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108804. /**
  108805. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108806. */
  108807. protected _useAmbientInGrayScale: boolean;
  108808. /**
  108809. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108810. * The material will try to infer what glossiness each pixel should be.
  108811. */
  108812. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108813. /**
  108814. * Defines the falloff type used in this material.
  108815. * It by default is Physical.
  108816. */
  108817. protected _lightFalloff: number;
  108818. /**
  108819. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108820. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108821. */
  108822. protected _useRadianceOverAlpha: boolean;
  108823. /**
  108824. * Allows using an object space normal map (instead of tangent space).
  108825. */
  108826. protected _useObjectSpaceNormalMap: boolean;
  108827. /**
  108828. * Allows using the bump map in parallax mode.
  108829. */
  108830. protected _useParallax: boolean;
  108831. /**
  108832. * Allows using the bump map in parallax occlusion mode.
  108833. */
  108834. protected _useParallaxOcclusion: boolean;
  108835. /**
  108836. * Controls the scale bias of the parallax mode.
  108837. */
  108838. protected _parallaxScaleBias: number;
  108839. /**
  108840. * If sets to true, disables all the lights affecting the material.
  108841. */
  108842. protected _disableLighting: boolean;
  108843. /**
  108844. * Number of Simultaneous lights allowed on the material.
  108845. */
  108846. protected _maxSimultaneousLights: number;
  108847. /**
  108848. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108849. */
  108850. protected _invertNormalMapX: boolean;
  108851. /**
  108852. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108853. */
  108854. protected _invertNormalMapY: boolean;
  108855. /**
  108856. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108857. */
  108858. protected _twoSidedLighting: boolean;
  108859. /**
  108860. * Defines the alpha limits in alpha test mode.
  108861. */
  108862. protected _alphaCutOff: number;
  108863. /**
  108864. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108865. */
  108866. protected _forceAlphaTest: boolean;
  108867. /**
  108868. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108869. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108870. */
  108871. protected _useAlphaFresnel: boolean;
  108872. /**
  108873. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108874. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108875. */
  108876. protected _useLinearAlphaFresnel: boolean;
  108877. /**
  108878. * The transparency mode of the material.
  108879. */
  108880. protected _transparencyMode: Nullable<number>;
  108881. /**
  108882. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108883. * from cos thetav and roughness:
  108884. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108885. */
  108886. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108887. /**
  108888. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108889. */
  108890. protected _forceIrradianceInFragment: boolean;
  108891. /**
  108892. * Force normal to face away from face.
  108893. */
  108894. protected _forceNormalForward: boolean;
  108895. /**
  108896. * Enables specular anti aliasing in the PBR shader.
  108897. * It will both interacts on the Geometry for analytical and IBL lighting.
  108898. * It also prefilter the roughness map based on the bump values.
  108899. */
  108900. protected _enableSpecularAntiAliasing: boolean;
  108901. /**
  108902. * Default configuration related to image processing available in the PBR Material.
  108903. */
  108904. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108905. /**
  108906. * Keep track of the image processing observer to allow dispose and replace.
  108907. */
  108908. private _imageProcessingObserver;
  108909. /**
  108910. * Attaches a new image processing configuration to the PBR Material.
  108911. * @param configuration
  108912. */
  108913. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108914. /**
  108915. * Stores the available render targets.
  108916. */
  108917. private _renderTargets;
  108918. /**
  108919. * Sets the global ambient color for the material used in lighting calculations.
  108920. */
  108921. private _globalAmbientColor;
  108922. /**
  108923. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108924. */
  108925. private _useLogarithmicDepth;
  108926. /**
  108927. * If set to true, no lighting calculations will be applied.
  108928. */
  108929. private _unlit;
  108930. private _debugMode;
  108931. /**
  108932. * @hidden
  108933. * This is reserved for the inspector.
  108934. * Defines the material debug mode.
  108935. * It helps seeing only some components of the material while troubleshooting.
  108936. */
  108937. debugMode: number;
  108938. /**
  108939. * @hidden
  108940. * This is reserved for the inspector.
  108941. * Specify from where on screen the debug mode should start.
  108942. * The value goes from -1 (full screen) to 1 (not visible)
  108943. * It helps with side by side comparison against the final render
  108944. * This defaults to -1
  108945. */
  108946. private debugLimit;
  108947. /**
  108948. * @hidden
  108949. * This is reserved for the inspector.
  108950. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108951. * You can use the factor to better multiply the final value.
  108952. */
  108953. private debugFactor;
  108954. /**
  108955. * Defines the clear coat layer parameters for the material.
  108956. */
  108957. readonly clearCoat: PBRClearCoatConfiguration;
  108958. /**
  108959. * Defines the anisotropic parameters for the material.
  108960. */
  108961. readonly anisotropy: PBRAnisotropicConfiguration;
  108962. /**
  108963. * Defines the BRDF parameters for the material.
  108964. */
  108965. readonly brdf: PBRBRDFConfiguration;
  108966. /**
  108967. * Defines the Sheen parameters for the material.
  108968. */
  108969. readonly sheen: PBRSheenConfiguration;
  108970. /**
  108971. * Defines the SubSurface parameters for the material.
  108972. */
  108973. readonly subSurface: PBRSubSurfaceConfiguration;
  108974. /**
  108975. * Custom callback helping to override the default shader used in the material.
  108976. */
  108977. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108978. /**
  108979. * Instantiates a new PBRMaterial instance.
  108980. *
  108981. * @param name The material name
  108982. * @param scene The scene the material will be use in.
  108983. */
  108984. constructor(name: string, scene: Scene);
  108985. /**
  108986. * Gets a boolean indicating that current material needs to register RTT
  108987. */
  108988. readonly hasRenderTargetTextures: boolean;
  108989. /**
  108990. * Gets the name of the material class.
  108991. */
  108992. getClassName(): string;
  108993. /**
  108994. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108995. */
  108996. /**
  108997. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108998. */
  108999. useLogarithmicDepth: boolean;
  109000. /**
  109001. * Gets the current transparency mode.
  109002. */
  109003. /**
  109004. * Sets the transparency mode of the material.
  109005. *
  109006. * | Value | Type | Description |
  109007. * | ----- | ----------------------------------- | ----------- |
  109008. * | 0 | OPAQUE | |
  109009. * | 1 | ALPHATEST | |
  109010. * | 2 | ALPHABLEND | |
  109011. * | 3 | ALPHATESTANDBLEND | |
  109012. *
  109013. */
  109014. transparencyMode: Nullable<number>;
  109015. /**
  109016. * Returns true if alpha blending should be disabled.
  109017. */
  109018. private readonly _disableAlphaBlending;
  109019. /**
  109020. * Specifies whether or not this material should be rendered in alpha blend mode.
  109021. */
  109022. needAlphaBlending(): boolean;
  109023. /**
  109024. * Specifies if the mesh will require alpha blending.
  109025. * @param mesh - BJS mesh.
  109026. */
  109027. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109028. /**
  109029. * Specifies whether or not this material should be rendered in alpha test mode.
  109030. */
  109031. needAlphaTesting(): boolean;
  109032. /**
  109033. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  109034. */
  109035. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  109036. /**
  109037. * Gets the texture used for the alpha test.
  109038. */
  109039. getAlphaTestTexture(): Nullable<BaseTexture>;
  109040. /**
  109041. * Specifies that the submesh is ready to be used.
  109042. * @param mesh - BJS mesh.
  109043. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  109044. * @param useInstances - Specifies that instances should be used.
  109045. * @returns - boolean indicating that the submesh is ready or not.
  109046. */
  109047. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109048. /**
  109049. * Specifies if the material uses metallic roughness workflow.
  109050. * @returns boolean specifiying if the material uses metallic roughness workflow.
  109051. */
  109052. isMetallicWorkflow(): boolean;
  109053. private _prepareEffect;
  109054. private _prepareDefines;
  109055. /**
  109056. * Force shader compilation
  109057. */
  109058. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  109059. clipPlane: boolean;
  109060. }>): void;
  109061. /**
  109062. * Initializes the uniform buffer layout for the shader.
  109063. */
  109064. buildUniformLayout(): void;
  109065. /**
  109066. * Unbinds the material from the mesh
  109067. */
  109068. unbind(): void;
  109069. /**
  109070. * Binds the submesh data.
  109071. * @param world - The world matrix.
  109072. * @param mesh - The BJS mesh.
  109073. * @param subMesh - A submesh of the BJS mesh.
  109074. */
  109075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109076. /**
  109077. * Returns the animatable textures.
  109078. * @returns - Array of animatable textures.
  109079. */
  109080. getAnimatables(): IAnimatable[];
  109081. /**
  109082. * Returns the texture used for reflections.
  109083. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  109084. */
  109085. private _getReflectionTexture;
  109086. /**
  109087. * Returns an array of the actively used textures.
  109088. * @returns - Array of BaseTextures
  109089. */
  109090. getActiveTextures(): BaseTexture[];
  109091. /**
  109092. * Checks to see if a texture is used in the material.
  109093. * @param texture - Base texture to use.
  109094. * @returns - Boolean specifying if a texture is used in the material.
  109095. */
  109096. hasTexture(texture: BaseTexture): boolean;
  109097. /**
  109098. * Disposes the resources of the material.
  109099. * @param forceDisposeEffect - Forces the disposal of effects.
  109100. * @param forceDisposeTextures - Forces the disposal of all textures.
  109101. */
  109102. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109103. }
  109104. }
  109105. declare module BABYLON {
  109106. /**
  109107. * The Physically based material of BJS.
  109108. *
  109109. * This offers the main features of a standard PBR material.
  109110. * For more information, please refer to the documentation :
  109111. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109112. */
  109113. export class PBRMaterial extends PBRBaseMaterial {
  109114. /**
  109115. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109116. */
  109117. static readonly PBRMATERIAL_OPAQUE: number;
  109118. /**
  109119. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109120. */
  109121. static readonly PBRMATERIAL_ALPHATEST: number;
  109122. /**
  109123. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109124. */
  109125. static readonly PBRMATERIAL_ALPHABLEND: number;
  109126. /**
  109127. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109128. * They are also discarded below the alpha cutoff threshold to improve performances.
  109129. */
  109130. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109131. /**
  109132. * Defines the default value of how much AO map is occluding the analytical lights
  109133. * (point spot...).
  109134. */
  109135. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109136. /**
  109137. * Intensity of the direct lights e.g. the four lights available in your scene.
  109138. * This impacts both the direct diffuse and specular highlights.
  109139. */
  109140. directIntensity: number;
  109141. /**
  109142. * Intensity of the emissive part of the material.
  109143. * This helps controlling the emissive effect without modifying the emissive color.
  109144. */
  109145. emissiveIntensity: number;
  109146. /**
  109147. * Intensity of the environment e.g. how much the environment will light the object
  109148. * either through harmonics for rough material or through the refelction for shiny ones.
  109149. */
  109150. environmentIntensity: number;
  109151. /**
  109152. * This is a special control allowing the reduction of the specular highlights coming from the
  109153. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109154. */
  109155. specularIntensity: number;
  109156. /**
  109157. * Debug Control allowing disabling the bump map on this material.
  109158. */
  109159. disableBumpMap: boolean;
  109160. /**
  109161. * AKA Diffuse Texture in standard nomenclature.
  109162. */
  109163. albedoTexture: BaseTexture;
  109164. /**
  109165. * AKA Occlusion Texture in other nomenclature.
  109166. */
  109167. ambientTexture: BaseTexture;
  109168. /**
  109169. * AKA Occlusion Texture Intensity in other nomenclature.
  109170. */
  109171. ambientTextureStrength: number;
  109172. /**
  109173. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109174. * 1 means it completely occludes it
  109175. * 0 mean it has no impact
  109176. */
  109177. ambientTextureImpactOnAnalyticalLights: number;
  109178. /**
  109179. * Stores the alpha values in a texture.
  109180. */
  109181. opacityTexture: BaseTexture;
  109182. /**
  109183. * Stores the reflection values in a texture.
  109184. */
  109185. reflectionTexture: Nullable<BaseTexture>;
  109186. /**
  109187. * Stores the emissive values in a texture.
  109188. */
  109189. emissiveTexture: BaseTexture;
  109190. /**
  109191. * AKA Specular texture in other nomenclature.
  109192. */
  109193. reflectivityTexture: BaseTexture;
  109194. /**
  109195. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109196. */
  109197. metallicTexture: BaseTexture;
  109198. /**
  109199. * Specifies the metallic scalar of the metallic/roughness workflow.
  109200. * Can also be used to scale the metalness values of the metallic texture.
  109201. */
  109202. metallic: Nullable<number>;
  109203. /**
  109204. * Specifies the roughness scalar of the metallic/roughness workflow.
  109205. * Can also be used to scale the roughness values of the metallic texture.
  109206. */
  109207. roughness: Nullable<number>;
  109208. /**
  109209. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109210. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109211. */
  109212. microSurfaceTexture: BaseTexture;
  109213. /**
  109214. * Stores surface normal data used to displace a mesh in a texture.
  109215. */
  109216. bumpTexture: BaseTexture;
  109217. /**
  109218. * Stores the pre-calculated light information of a mesh in a texture.
  109219. */
  109220. lightmapTexture: BaseTexture;
  109221. /**
  109222. * Stores the refracted light information in a texture.
  109223. */
  109224. refractionTexture: Nullable<BaseTexture>;
  109225. /**
  109226. * The color of a material in ambient lighting.
  109227. */
  109228. ambientColor: Color3;
  109229. /**
  109230. * AKA Diffuse Color in other nomenclature.
  109231. */
  109232. albedoColor: Color3;
  109233. /**
  109234. * AKA Specular Color in other nomenclature.
  109235. */
  109236. reflectivityColor: Color3;
  109237. /**
  109238. * The color reflected from the material.
  109239. */
  109240. reflectionColor: Color3;
  109241. /**
  109242. * The color emitted from the material.
  109243. */
  109244. emissiveColor: Color3;
  109245. /**
  109246. * AKA Glossiness in other nomenclature.
  109247. */
  109248. microSurface: number;
  109249. /**
  109250. * source material index of refraction (IOR)' / 'destination material IOR.
  109251. */
  109252. indexOfRefraction: number;
  109253. /**
  109254. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109255. */
  109256. invertRefractionY: boolean;
  109257. /**
  109258. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109259. * Materials half opaque for instance using refraction could benefit from this control.
  109260. */
  109261. linkRefractionWithTransparency: boolean;
  109262. /**
  109263. * If true, the light map contains occlusion information instead of lighting info.
  109264. */
  109265. useLightmapAsShadowmap: boolean;
  109266. /**
  109267. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109268. */
  109269. useAlphaFromAlbedoTexture: boolean;
  109270. /**
  109271. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109272. */
  109273. forceAlphaTest: boolean;
  109274. /**
  109275. * Defines the alpha limits in alpha test mode.
  109276. */
  109277. alphaCutOff: number;
  109278. /**
  109279. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109280. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109281. */
  109282. useSpecularOverAlpha: boolean;
  109283. /**
  109284. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109285. */
  109286. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109287. /**
  109288. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109289. */
  109290. useRoughnessFromMetallicTextureAlpha: boolean;
  109291. /**
  109292. * Specifies if the metallic texture contains the roughness information in its green channel.
  109293. */
  109294. useRoughnessFromMetallicTextureGreen: boolean;
  109295. /**
  109296. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109297. */
  109298. useMetallnessFromMetallicTextureBlue: boolean;
  109299. /**
  109300. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109301. */
  109302. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109303. /**
  109304. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109305. */
  109306. useAmbientInGrayScale: boolean;
  109307. /**
  109308. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109309. * The material will try to infer what glossiness each pixel should be.
  109310. */
  109311. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109312. /**
  109313. * BJS is using an harcoded light falloff based on a manually sets up range.
  109314. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109315. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109316. */
  109317. /**
  109318. * BJS is using an harcoded light falloff based on a manually sets up range.
  109319. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109320. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109321. */
  109322. usePhysicalLightFalloff: boolean;
  109323. /**
  109324. * In order to support the falloff compatibility with gltf, a special mode has been added
  109325. * to reproduce the gltf light falloff.
  109326. */
  109327. /**
  109328. * In order to support the falloff compatibility with gltf, a special mode has been added
  109329. * to reproduce the gltf light falloff.
  109330. */
  109331. useGLTFLightFalloff: boolean;
  109332. /**
  109333. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109334. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109335. */
  109336. useRadianceOverAlpha: boolean;
  109337. /**
  109338. * Allows using an object space normal map (instead of tangent space).
  109339. */
  109340. useObjectSpaceNormalMap: boolean;
  109341. /**
  109342. * Allows using the bump map in parallax mode.
  109343. */
  109344. useParallax: boolean;
  109345. /**
  109346. * Allows using the bump map in parallax occlusion mode.
  109347. */
  109348. useParallaxOcclusion: boolean;
  109349. /**
  109350. * Controls the scale bias of the parallax mode.
  109351. */
  109352. parallaxScaleBias: number;
  109353. /**
  109354. * If sets to true, disables all the lights affecting the material.
  109355. */
  109356. disableLighting: boolean;
  109357. /**
  109358. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109359. */
  109360. forceIrradianceInFragment: boolean;
  109361. /**
  109362. * Number of Simultaneous lights allowed on the material.
  109363. */
  109364. maxSimultaneousLights: number;
  109365. /**
  109366. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109367. */
  109368. invertNormalMapX: boolean;
  109369. /**
  109370. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109371. */
  109372. invertNormalMapY: boolean;
  109373. /**
  109374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109375. */
  109376. twoSidedLighting: boolean;
  109377. /**
  109378. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109379. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109380. */
  109381. useAlphaFresnel: boolean;
  109382. /**
  109383. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109384. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109385. */
  109386. useLinearAlphaFresnel: boolean;
  109387. /**
  109388. * Let user defines the brdf lookup texture used for IBL.
  109389. * A default 8bit version is embedded but you could point at :
  109390. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  109391. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109392. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109393. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109394. */
  109395. environmentBRDFTexture: Nullable<BaseTexture>;
  109396. /**
  109397. * Force normal to face away from face.
  109398. */
  109399. forceNormalForward: boolean;
  109400. /**
  109401. * Enables specular anti aliasing in the PBR shader.
  109402. * It will both interacts on the Geometry for analytical and IBL lighting.
  109403. * It also prefilter the roughness map based on the bump values.
  109404. */
  109405. enableSpecularAntiAliasing: boolean;
  109406. /**
  109407. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109408. * makes the reflect vector face the model (under horizon).
  109409. */
  109410. useHorizonOcclusion: boolean;
  109411. /**
  109412. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109413. * too much the area relying on ambient texture to define their ambient occlusion.
  109414. */
  109415. useRadianceOcclusion: boolean;
  109416. /**
  109417. * If set to true, no lighting calculations will be applied.
  109418. */
  109419. unlit: boolean;
  109420. /**
  109421. * Gets the image processing configuration used either in this material.
  109422. */
  109423. /**
  109424. * Sets the Default image processing configuration used either in the this material.
  109425. *
  109426. * If sets to null, the scene one is in use.
  109427. */
  109428. imageProcessingConfiguration: ImageProcessingConfiguration;
  109429. /**
  109430. * Gets wether the color curves effect is enabled.
  109431. */
  109432. /**
  109433. * Sets wether the color curves effect is enabled.
  109434. */
  109435. cameraColorCurvesEnabled: boolean;
  109436. /**
  109437. * Gets wether the color grading effect is enabled.
  109438. */
  109439. /**
  109440. * Gets wether the color grading effect is enabled.
  109441. */
  109442. cameraColorGradingEnabled: boolean;
  109443. /**
  109444. * Gets wether tonemapping is enabled or not.
  109445. */
  109446. /**
  109447. * Sets wether tonemapping is enabled or not
  109448. */
  109449. cameraToneMappingEnabled: boolean;
  109450. /**
  109451. * The camera exposure used on this material.
  109452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109453. * This corresponds to a photographic exposure.
  109454. */
  109455. /**
  109456. * The camera exposure used on this material.
  109457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109458. * This corresponds to a photographic exposure.
  109459. */
  109460. cameraExposure: number;
  109461. /**
  109462. * Gets The camera contrast used on this material.
  109463. */
  109464. /**
  109465. * Sets The camera contrast used on this material.
  109466. */
  109467. cameraContrast: number;
  109468. /**
  109469. * Gets the Color Grading 2D Lookup Texture.
  109470. */
  109471. /**
  109472. * Sets the Color Grading 2D Lookup Texture.
  109473. */
  109474. cameraColorGradingTexture: Nullable<BaseTexture>;
  109475. /**
  109476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109478. * 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;
  109479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109480. */
  109481. /**
  109482. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109483. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109484. * 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;
  109485. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109486. */
  109487. cameraColorCurves: Nullable<ColorCurves>;
  109488. /**
  109489. * Instantiates a new PBRMaterial instance.
  109490. *
  109491. * @param name The material name
  109492. * @param scene The scene the material will be use in.
  109493. */
  109494. constructor(name: string, scene: Scene);
  109495. /**
  109496. * Returns the name of this material class.
  109497. */
  109498. getClassName(): string;
  109499. /**
  109500. * Makes a duplicate of the current material.
  109501. * @param name - name to use for the new material.
  109502. */
  109503. clone(name: string): PBRMaterial;
  109504. /**
  109505. * Serializes this PBR Material.
  109506. * @returns - An object with the serialized material.
  109507. */
  109508. serialize(): any;
  109509. /**
  109510. * Parses a PBR Material from a serialized object.
  109511. * @param source - Serialized object.
  109512. * @param scene - BJS scene instance.
  109513. * @param rootUrl - url for the scene object
  109514. * @returns - PBRMaterial
  109515. */
  109516. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109517. }
  109518. }
  109519. declare module BABYLON {
  109520. /**
  109521. * Direct draw surface info
  109522. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109523. */
  109524. export interface DDSInfo {
  109525. /**
  109526. * Width of the texture
  109527. */
  109528. width: number;
  109529. /**
  109530. * Width of the texture
  109531. */
  109532. height: number;
  109533. /**
  109534. * Number of Mipmaps for the texture
  109535. * @see https://en.wikipedia.org/wiki/Mipmap
  109536. */
  109537. mipmapCount: number;
  109538. /**
  109539. * If the textures format is a known fourCC format
  109540. * @see https://www.fourcc.org/
  109541. */
  109542. isFourCC: boolean;
  109543. /**
  109544. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109545. */
  109546. isRGB: boolean;
  109547. /**
  109548. * If the texture is a lumincance format
  109549. */
  109550. isLuminance: boolean;
  109551. /**
  109552. * If this is a cube texture
  109553. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109554. */
  109555. isCube: boolean;
  109556. /**
  109557. * If the texture is a compressed format eg. FOURCC_DXT1
  109558. */
  109559. isCompressed: boolean;
  109560. /**
  109561. * The dxgiFormat of the texture
  109562. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109563. */
  109564. dxgiFormat: number;
  109565. /**
  109566. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109567. */
  109568. textureType: number;
  109569. /**
  109570. * Sphericle polynomial created for the dds texture
  109571. */
  109572. sphericalPolynomial?: SphericalPolynomial;
  109573. }
  109574. /**
  109575. * Class used to provide DDS decompression tools
  109576. */
  109577. export class DDSTools {
  109578. /**
  109579. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109580. */
  109581. static StoreLODInAlphaChannel: boolean;
  109582. /**
  109583. * Gets DDS information from an array buffer
  109584. * @param arrayBuffer defines the array buffer to read data from
  109585. * @returns the DDS information
  109586. */
  109587. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109588. private static _FloatView;
  109589. private static _Int32View;
  109590. private static _ToHalfFloat;
  109591. private static _FromHalfFloat;
  109592. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109593. private static _GetHalfFloatRGBAArrayBuffer;
  109594. private static _GetFloatRGBAArrayBuffer;
  109595. private static _GetFloatAsUIntRGBAArrayBuffer;
  109596. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109597. private static _GetRGBAArrayBuffer;
  109598. private static _ExtractLongWordOrder;
  109599. private static _GetRGBArrayBuffer;
  109600. private static _GetLuminanceArrayBuffer;
  109601. /**
  109602. * Uploads DDS Levels to a Babylon Texture
  109603. * @hidden
  109604. */
  109605. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109606. }
  109607. interface Engine {
  109608. /**
  109609. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109610. * @param rootUrl defines the url where the file to load is located
  109611. * @param scene defines the current scene
  109612. * @param lodScale defines scale to apply to the mip map selection
  109613. * @param lodOffset defines offset to apply to the mip map selection
  109614. * @param onLoad defines an optional callback raised when the texture is loaded
  109615. * @param onError defines an optional callback raised if there is an issue to load the texture
  109616. * @param format defines the format of the data
  109617. * @param forcedExtension defines the extension to use to pick the right loader
  109618. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109619. * @returns the cube texture as an InternalTexture
  109620. */
  109621. 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;
  109622. }
  109623. }
  109624. declare module BABYLON {
  109625. /**
  109626. * Implementation of the DDS Texture Loader.
  109627. * @hidden
  109628. */
  109629. export class _DDSTextureLoader implements IInternalTextureLoader {
  109630. /**
  109631. * Defines wether the loader supports cascade loading the different faces.
  109632. */
  109633. readonly supportCascades: boolean;
  109634. /**
  109635. * This returns if the loader support the current file information.
  109636. * @param extension defines the file extension of the file being loaded
  109637. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109638. * @param fallback defines the fallback internal texture if any
  109639. * @param isBase64 defines whether the texture is encoded as a base64
  109640. * @param isBuffer defines whether the texture data are stored as a buffer
  109641. * @returns true if the loader can load the specified file
  109642. */
  109643. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109644. /**
  109645. * Transform the url before loading if required.
  109646. * @param rootUrl the url of the texture
  109647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109648. * @returns the transformed texture
  109649. */
  109650. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109651. /**
  109652. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109653. * @param rootUrl the url of the texture
  109654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109655. * @returns the fallback texture
  109656. */
  109657. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109658. /**
  109659. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109660. * @param data contains the texture data
  109661. * @param texture defines the BabylonJS internal texture
  109662. * @param createPolynomials will be true if polynomials have been requested
  109663. * @param onLoad defines the callback to trigger once the texture is ready
  109664. * @param onError defines the callback to trigger in case of error
  109665. */
  109666. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109667. /**
  109668. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109669. * @param data contains the texture data
  109670. * @param texture defines the BabylonJS internal texture
  109671. * @param callback defines the method to call once ready to upload
  109672. */
  109673. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109674. }
  109675. }
  109676. declare module BABYLON {
  109677. /** @hidden */
  109678. export var rgbdEncodePixelShader: {
  109679. name: string;
  109680. shader: string;
  109681. };
  109682. }
  109683. declare module BABYLON {
  109684. /**
  109685. * Raw texture data and descriptor sufficient for WebGL texture upload
  109686. */
  109687. export interface EnvironmentTextureInfo {
  109688. /**
  109689. * Version of the environment map
  109690. */
  109691. version: number;
  109692. /**
  109693. * Width of image
  109694. */
  109695. width: number;
  109696. /**
  109697. * Irradiance information stored in the file.
  109698. */
  109699. irradiance: any;
  109700. /**
  109701. * Specular information stored in the file.
  109702. */
  109703. specular: any;
  109704. }
  109705. /**
  109706. * Sets of helpers addressing the serialization and deserialization of environment texture
  109707. * stored in a BabylonJS env file.
  109708. * Those files are usually stored as .env files.
  109709. */
  109710. export class EnvironmentTextureTools {
  109711. /**
  109712. * Magic number identifying the env file.
  109713. */
  109714. private static _MagicBytes;
  109715. /**
  109716. * Gets the environment info from an env file.
  109717. * @param data The array buffer containing the .env bytes.
  109718. * @returns the environment file info (the json header) if successfully parsed.
  109719. */
  109720. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109721. /**
  109722. * Creates an environment texture from a loaded cube texture.
  109723. * @param texture defines the cube texture to convert in env file
  109724. * @return a promise containing the environment data if succesfull.
  109725. */
  109726. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109727. /**
  109728. * Creates a JSON representation of the spherical data.
  109729. * @param texture defines the texture containing the polynomials
  109730. * @return the JSON representation of the spherical info
  109731. */
  109732. private static _CreateEnvTextureIrradiance;
  109733. /**
  109734. * Uploads the texture info contained in the env file to the GPU.
  109735. * @param texture defines the internal texture to upload to
  109736. * @param arrayBuffer defines the buffer cotaining the data to load
  109737. * @param info defines the texture info retrieved through the GetEnvInfo method
  109738. * @returns a promise
  109739. */
  109740. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109741. /**
  109742. * Uploads the levels of image data to the GPU.
  109743. * @param texture defines the internal texture to upload to
  109744. * @param imageData defines the array buffer views of image data [mipmap][face]
  109745. * @returns a promise
  109746. */
  109747. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109748. /**
  109749. * Uploads spherical polynomials information to the texture.
  109750. * @param texture defines the texture we are trying to upload the information to
  109751. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109752. */
  109753. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109754. /** @hidden */
  109755. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109756. }
  109757. }
  109758. declare module BABYLON {
  109759. /**
  109760. * Implementation of the ENV Texture Loader.
  109761. * @hidden
  109762. */
  109763. export class _ENVTextureLoader implements IInternalTextureLoader {
  109764. /**
  109765. * Defines wether the loader supports cascade loading the different faces.
  109766. */
  109767. readonly supportCascades: boolean;
  109768. /**
  109769. * This returns if the loader support the current file information.
  109770. * @param extension defines the file extension of the file being loaded
  109771. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109772. * @param fallback defines the fallback internal texture if any
  109773. * @param isBase64 defines whether the texture is encoded as a base64
  109774. * @param isBuffer defines whether the texture data are stored as a buffer
  109775. * @returns true if the loader can load the specified file
  109776. */
  109777. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109778. /**
  109779. * Transform the url before loading if required.
  109780. * @param rootUrl the url of the texture
  109781. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109782. * @returns the transformed texture
  109783. */
  109784. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109785. /**
  109786. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109787. * @param rootUrl the url of the texture
  109788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109789. * @returns the fallback texture
  109790. */
  109791. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109792. /**
  109793. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109794. * @param data contains the texture data
  109795. * @param texture defines the BabylonJS internal texture
  109796. * @param createPolynomials will be true if polynomials have been requested
  109797. * @param onLoad defines the callback to trigger once the texture is ready
  109798. * @param onError defines the callback to trigger in case of error
  109799. */
  109800. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109801. /**
  109802. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109803. * @param data contains the texture data
  109804. * @param texture defines the BabylonJS internal texture
  109805. * @param callback defines the method to call once ready to upload
  109806. */
  109807. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109808. }
  109809. }
  109810. declare module BABYLON {
  109811. /**
  109812. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109813. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109814. */
  109815. export class KhronosTextureContainer {
  109816. /** contents of the KTX container file */
  109817. arrayBuffer: any;
  109818. private static HEADER_LEN;
  109819. private static COMPRESSED_2D;
  109820. private static COMPRESSED_3D;
  109821. private static TEX_2D;
  109822. private static TEX_3D;
  109823. /**
  109824. * Gets the openGL type
  109825. */
  109826. glType: number;
  109827. /**
  109828. * Gets the openGL type size
  109829. */
  109830. glTypeSize: number;
  109831. /**
  109832. * Gets the openGL format
  109833. */
  109834. glFormat: number;
  109835. /**
  109836. * Gets the openGL internal format
  109837. */
  109838. glInternalFormat: number;
  109839. /**
  109840. * Gets the base internal format
  109841. */
  109842. glBaseInternalFormat: number;
  109843. /**
  109844. * Gets image width in pixel
  109845. */
  109846. pixelWidth: number;
  109847. /**
  109848. * Gets image height in pixel
  109849. */
  109850. pixelHeight: number;
  109851. /**
  109852. * Gets image depth in pixels
  109853. */
  109854. pixelDepth: number;
  109855. /**
  109856. * Gets the number of array elements
  109857. */
  109858. numberOfArrayElements: number;
  109859. /**
  109860. * Gets the number of faces
  109861. */
  109862. numberOfFaces: number;
  109863. /**
  109864. * Gets the number of mipmap levels
  109865. */
  109866. numberOfMipmapLevels: number;
  109867. /**
  109868. * Gets the bytes of key value data
  109869. */
  109870. bytesOfKeyValueData: number;
  109871. /**
  109872. * Gets the load type
  109873. */
  109874. loadType: number;
  109875. /**
  109876. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109877. */
  109878. isInvalid: boolean;
  109879. /**
  109880. * Creates a new KhronosTextureContainer
  109881. * @param arrayBuffer contents of the KTX container file
  109882. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109883. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109884. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109885. */
  109886. constructor(
  109887. /** contents of the KTX container file */
  109888. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109889. /**
  109890. * Uploads KTX content to a Babylon Texture.
  109891. * It is assumed that the texture has already been created & is currently bound
  109892. * @hidden
  109893. */
  109894. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109895. private _upload2DCompressedLevels;
  109896. }
  109897. }
  109898. declare module BABYLON {
  109899. /**
  109900. * Implementation of the KTX Texture Loader.
  109901. * @hidden
  109902. */
  109903. export class _KTXTextureLoader implements IInternalTextureLoader {
  109904. /**
  109905. * Defines wether the loader supports cascade loading the different faces.
  109906. */
  109907. readonly supportCascades: boolean;
  109908. /**
  109909. * This returns if the loader support the current file information.
  109910. * @param extension defines the file extension of the file being loaded
  109911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109912. * @param fallback defines the fallback internal texture if any
  109913. * @param isBase64 defines whether the texture is encoded as a base64
  109914. * @param isBuffer defines whether the texture data are stored as a buffer
  109915. * @returns true if the loader can load the specified file
  109916. */
  109917. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109918. /**
  109919. * Transform the url before loading if required.
  109920. * @param rootUrl the url of the texture
  109921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109922. * @returns the transformed texture
  109923. */
  109924. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109925. /**
  109926. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109927. * @param rootUrl the url of the texture
  109928. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109929. * @returns the fallback texture
  109930. */
  109931. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109932. /**
  109933. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109934. * @param data contains the texture data
  109935. * @param texture defines the BabylonJS internal texture
  109936. * @param createPolynomials will be true if polynomials have been requested
  109937. * @param onLoad defines the callback to trigger once the texture is ready
  109938. * @param onError defines the callback to trigger in case of error
  109939. */
  109940. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109941. /**
  109942. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109943. * @param data contains the texture data
  109944. * @param texture defines the BabylonJS internal texture
  109945. * @param callback defines the method to call once ready to upload
  109946. */
  109947. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109948. }
  109949. }
  109950. declare module BABYLON {
  109951. /** @hidden */
  109952. export var _forceSceneHelpersToBundle: boolean;
  109953. interface Scene {
  109954. /**
  109955. * Creates a default light for the scene.
  109956. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109957. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109958. */
  109959. createDefaultLight(replace?: boolean): void;
  109960. /**
  109961. * Creates a default camera for the scene.
  109962. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109963. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109964. * @param replace has default false, when true replaces the active camera in the scene
  109965. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109966. */
  109967. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109968. /**
  109969. * Creates a default camera and a default light.
  109970. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109971. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109972. * @param replace has the default false, when true replaces the active camera/light in the scene
  109973. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109974. */
  109975. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109976. /**
  109977. * Creates a new sky box
  109978. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109979. * @param environmentTexture defines the texture to use as environment texture
  109980. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109981. * @param scale defines the overall scale of the skybox
  109982. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109983. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109984. * @returns a new mesh holding the sky box
  109985. */
  109986. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109987. /**
  109988. * Creates a new environment
  109989. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109990. * @param options defines the options you can use to configure the environment
  109991. * @returns the new EnvironmentHelper
  109992. */
  109993. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109994. /**
  109995. * Creates a new VREXperienceHelper
  109996. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109997. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109998. * @returns a new VREXperienceHelper
  109999. */
  110000. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  110001. /**
  110002. * Creates a new XREXperienceHelper
  110003. * @see http://doc.babylonjs.com/how_to/webxr
  110004. * @returns a promise for a new XREXperienceHelper
  110005. */
  110006. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  110007. }
  110008. }
  110009. declare module BABYLON {
  110010. /**
  110011. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  110012. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  110013. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  110014. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110015. */
  110016. export class VideoDome extends TransformNode {
  110017. /**
  110018. * Define the video source as a Monoscopic panoramic 360 video.
  110019. */
  110020. static readonly MODE_MONOSCOPIC: number;
  110021. /**
  110022. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110023. */
  110024. static readonly MODE_TOPBOTTOM: number;
  110025. /**
  110026. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110027. */
  110028. static readonly MODE_SIDEBYSIDE: number;
  110029. private _useDirectMapping;
  110030. /**
  110031. * The video texture being displayed on the sphere
  110032. */
  110033. protected _videoTexture: VideoTexture;
  110034. /**
  110035. * Gets the video texture being displayed on the sphere
  110036. */
  110037. readonly videoTexture: VideoTexture;
  110038. /**
  110039. * The skybox material
  110040. */
  110041. protected _material: BackgroundMaterial;
  110042. /**
  110043. * The surface used for the skybox
  110044. */
  110045. protected _mesh: Mesh;
  110046. /**
  110047. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110048. * Also see the options.resolution property.
  110049. */
  110050. fovMultiplier: number;
  110051. private _videoMode;
  110052. /**
  110053. * Gets or set the current video mode for the video. It can be:
  110054. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  110055. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110056. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110057. */
  110058. videoMode: number;
  110059. /**
  110060. * Oberserver used in Stereoscopic VR Mode.
  110061. */
  110062. private _onBeforeCameraRenderObserver;
  110063. /**
  110064. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  110065. * @param name Element's name, child elements will append suffixes for their own names.
  110066. * @param urlsOrVideo defines the url(s) or the video element to use
  110067. * @param options An object containing optional or exposed sub element properties
  110068. */
  110069. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  110070. resolution?: number;
  110071. clickToPlay?: boolean;
  110072. autoPlay?: boolean;
  110073. loop?: boolean;
  110074. size?: number;
  110075. poster?: string;
  110076. faceForward?: boolean;
  110077. useDirectMapping?: boolean;
  110078. }, scene: Scene);
  110079. private _changeVideoMode;
  110080. /**
  110081. * Releases resources associated with this node.
  110082. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110083. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110084. */
  110085. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110086. }
  110087. }
  110088. declare module BABYLON {
  110089. /**
  110090. * This class can be used to get instrumentation data from a Babylon engine
  110091. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110092. */
  110093. export class EngineInstrumentation implements IDisposable {
  110094. /**
  110095. * Define the instrumented engine.
  110096. */
  110097. engine: Engine;
  110098. private _captureGPUFrameTime;
  110099. private _gpuFrameTimeToken;
  110100. private _gpuFrameTime;
  110101. private _captureShaderCompilationTime;
  110102. private _shaderCompilationTime;
  110103. private _onBeginFrameObserver;
  110104. private _onEndFrameObserver;
  110105. private _onBeforeShaderCompilationObserver;
  110106. private _onAfterShaderCompilationObserver;
  110107. /**
  110108. * Gets the perf counter used for GPU frame time
  110109. */
  110110. readonly gpuFrameTimeCounter: PerfCounter;
  110111. /**
  110112. * Gets the GPU frame time capture status
  110113. */
  110114. /**
  110115. * Enable or disable the GPU frame time capture
  110116. */
  110117. captureGPUFrameTime: boolean;
  110118. /**
  110119. * Gets the perf counter used for shader compilation time
  110120. */
  110121. readonly shaderCompilationTimeCounter: PerfCounter;
  110122. /**
  110123. * Gets the shader compilation time capture status
  110124. */
  110125. /**
  110126. * Enable or disable the shader compilation time capture
  110127. */
  110128. captureShaderCompilationTime: boolean;
  110129. /**
  110130. * Instantiates a new engine instrumentation.
  110131. * This class can be used to get instrumentation data from a Babylon engine
  110132. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110133. * @param engine Defines the engine to instrument
  110134. */
  110135. constructor(
  110136. /**
  110137. * Define the instrumented engine.
  110138. */
  110139. engine: Engine);
  110140. /**
  110141. * Dispose and release associated resources.
  110142. */
  110143. dispose(): void;
  110144. }
  110145. }
  110146. declare module BABYLON {
  110147. /**
  110148. * This class can be used to get instrumentation data from a Babylon engine
  110149. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110150. */
  110151. export class SceneInstrumentation implements IDisposable {
  110152. /**
  110153. * Defines the scene to instrument
  110154. */
  110155. scene: Scene;
  110156. private _captureActiveMeshesEvaluationTime;
  110157. private _activeMeshesEvaluationTime;
  110158. private _captureRenderTargetsRenderTime;
  110159. private _renderTargetsRenderTime;
  110160. private _captureFrameTime;
  110161. private _frameTime;
  110162. private _captureRenderTime;
  110163. private _renderTime;
  110164. private _captureInterFrameTime;
  110165. private _interFrameTime;
  110166. private _captureParticlesRenderTime;
  110167. private _particlesRenderTime;
  110168. private _captureSpritesRenderTime;
  110169. private _spritesRenderTime;
  110170. private _capturePhysicsTime;
  110171. private _physicsTime;
  110172. private _captureAnimationsTime;
  110173. private _animationsTime;
  110174. private _captureCameraRenderTime;
  110175. private _cameraRenderTime;
  110176. private _onBeforeActiveMeshesEvaluationObserver;
  110177. private _onAfterActiveMeshesEvaluationObserver;
  110178. private _onBeforeRenderTargetsRenderObserver;
  110179. private _onAfterRenderTargetsRenderObserver;
  110180. private _onAfterRenderObserver;
  110181. private _onBeforeDrawPhaseObserver;
  110182. private _onAfterDrawPhaseObserver;
  110183. private _onBeforeAnimationsObserver;
  110184. private _onBeforeParticlesRenderingObserver;
  110185. private _onAfterParticlesRenderingObserver;
  110186. private _onBeforeSpritesRenderingObserver;
  110187. private _onAfterSpritesRenderingObserver;
  110188. private _onBeforePhysicsObserver;
  110189. private _onAfterPhysicsObserver;
  110190. private _onAfterAnimationsObserver;
  110191. private _onBeforeCameraRenderObserver;
  110192. private _onAfterCameraRenderObserver;
  110193. /**
  110194. * Gets the perf counter used for active meshes evaluation time
  110195. */
  110196. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  110197. /**
  110198. * Gets the active meshes evaluation time capture status
  110199. */
  110200. /**
  110201. * Enable or disable the active meshes evaluation time capture
  110202. */
  110203. captureActiveMeshesEvaluationTime: boolean;
  110204. /**
  110205. * Gets the perf counter used for render targets render time
  110206. */
  110207. readonly renderTargetsRenderTimeCounter: PerfCounter;
  110208. /**
  110209. * Gets the render targets render time capture status
  110210. */
  110211. /**
  110212. * Enable or disable the render targets render time capture
  110213. */
  110214. captureRenderTargetsRenderTime: boolean;
  110215. /**
  110216. * Gets the perf counter used for particles render time
  110217. */
  110218. readonly particlesRenderTimeCounter: PerfCounter;
  110219. /**
  110220. * Gets the particles render time capture status
  110221. */
  110222. /**
  110223. * Enable or disable the particles render time capture
  110224. */
  110225. captureParticlesRenderTime: boolean;
  110226. /**
  110227. * Gets the perf counter used for sprites render time
  110228. */
  110229. readonly spritesRenderTimeCounter: PerfCounter;
  110230. /**
  110231. * Gets the sprites render time capture status
  110232. */
  110233. /**
  110234. * Enable or disable the sprites render time capture
  110235. */
  110236. captureSpritesRenderTime: boolean;
  110237. /**
  110238. * Gets the perf counter used for physics time
  110239. */
  110240. readonly physicsTimeCounter: PerfCounter;
  110241. /**
  110242. * Gets the physics time capture status
  110243. */
  110244. /**
  110245. * Enable or disable the physics time capture
  110246. */
  110247. capturePhysicsTime: boolean;
  110248. /**
  110249. * Gets the perf counter used for animations time
  110250. */
  110251. readonly animationsTimeCounter: PerfCounter;
  110252. /**
  110253. * Gets the animations time capture status
  110254. */
  110255. /**
  110256. * Enable or disable the animations time capture
  110257. */
  110258. captureAnimationsTime: boolean;
  110259. /**
  110260. * Gets the perf counter used for frame time capture
  110261. */
  110262. readonly frameTimeCounter: PerfCounter;
  110263. /**
  110264. * Gets the frame time capture status
  110265. */
  110266. /**
  110267. * Enable or disable the frame time capture
  110268. */
  110269. captureFrameTime: boolean;
  110270. /**
  110271. * Gets the perf counter used for inter-frames time capture
  110272. */
  110273. readonly interFrameTimeCounter: PerfCounter;
  110274. /**
  110275. * Gets the inter-frames time capture status
  110276. */
  110277. /**
  110278. * Enable or disable the inter-frames time capture
  110279. */
  110280. captureInterFrameTime: boolean;
  110281. /**
  110282. * Gets the perf counter used for render time capture
  110283. */
  110284. readonly renderTimeCounter: PerfCounter;
  110285. /**
  110286. * Gets the render time capture status
  110287. */
  110288. /**
  110289. * Enable or disable the render time capture
  110290. */
  110291. captureRenderTime: boolean;
  110292. /**
  110293. * Gets the perf counter used for camera render time capture
  110294. */
  110295. readonly cameraRenderTimeCounter: PerfCounter;
  110296. /**
  110297. * Gets the camera render time capture status
  110298. */
  110299. /**
  110300. * Enable or disable the camera render time capture
  110301. */
  110302. captureCameraRenderTime: boolean;
  110303. /**
  110304. * Gets the perf counter used for draw calls
  110305. */
  110306. readonly drawCallsCounter: PerfCounter;
  110307. /**
  110308. * Instantiates a new scene instrumentation.
  110309. * This class can be used to get instrumentation data from a Babylon engine
  110310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110311. * @param scene Defines the scene to instrument
  110312. */
  110313. constructor(
  110314. /**
  110315. * Defines the scene to instrument
  110316. */
  110317. scene: Scene);
  110318. /**
  110319. * Dispose and release associated resources.
  110320. */
  110321. dispose(): void;
  110322. }
  110323. }
  110324. declare module BABYLON {
  110325. /** @hidden */
  110326. export var glowMapGenerationPixelShader: {
  110327. name: string;
  110328. shader: string;
  110329. };
  110330. }
  110331. declare module BABYLON {
  110332. /** @hidden */
  110333. export var glowMapGenerationVertexShader: {
  110334. name: string;
  110335. shader: string;
  110336. };
  110337. }
  110338. declare module BABYLON {
  110339. /**
  110340. * Effect layer options. This helps customizing the behaviour
  110341. * of the effect layer.
  110342. */
  110343. export interface IEffectLayerOptions {
  110344. /**
  110345. * Multiplication factor apply to the canvas size to compute the render target size
  110346. * used to generated the objects (the smaller the faster).
  110347. */
  110348. mainTextureRatio: number;
  110349. /**
  110350. * Enforces a fixed size texture to ensure effect stability across devices.
  110351. */
  110352. mainTextureFixedSize?: number;
  110353. /**
  110354. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110355. */
  110356. alphaBlendingMode: number;
  110357. /**
  110358. * The camera attached to the layer.
  110359. */
  110360. camera: Nullable<Camera>;
  110361. /**
  110362. * The rendering group to draw the layer in.
  110363. */
  110364. renderingGroupId: number;
  110365. }
  110366. /**
  110367. * The effect layer Helps adding post process effect blended with the main pass.
  110368. *
  110369. * This can be for instance use to generate glow or higlight effects on the scene.
  110370. *
  110371. * The effect layer class can not be used directly and is intented to inherited from to be
  110372. * customized per effects.
  110373. */
  110374. export abstract class EffectLayer {
  110375. private _vertexBuffers;
  110376. private _indexBuffer;
  110377. private _cachedDefines;
  110378. private _effectLayerMapGenerationEffect;
  110379. private _effectLayerOptions;
  110380. private _mergeEffect;
  110381. protected _scene: Scene;
  110382. protected _engine: Engine;
  110383. protected _maxSize: number;
  110384. protected _mainTextureDesiredSize: ISize;
  110385. protected _mainTexture: RenderTargetTexture;
  110386. protected _shouldRender: boolean;
  110387. protected _postProcesses: PostProcess[];
  110388. protected _textures: BaseTexture[];
  110389. protected _emissiveTextureAndColor: {
  110390. texture: Nullable<BaseTexture>;
  110391. color: Color4;
  110392. };
  110393. /**
  110394. * The name of the layer
  110395. */
  110396. name: string;
  110397. /**
  110398. * The clear color of the texture used to generate the glow map.
  110399. */
  110400. neutralColor: Color4;
  110401. /**
  110402. * Specifies wether the highlight layer is enabled or not.
  110403. */
  110404. isEnabled: boolean;
  110405. /**
  110406. * Gets the camera attached to the layer.
  110407. */
  110408. readonly camera: Nullable<Camera>;
  110409. /**
  110410. * Gets the rendering group id the layer should render in.
  110411. */
  110412. readonly renderingGroupId: number;
  110413. /**
  110414. * An event triggered when the effect layer has been disposed.
  110415. */
  110416. onDisposeObservable: Observable<EffectLayer>;
  110417. /**
  110418. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110419. */
  110420. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110421. /**
  110422. * An event triggered when the generated texture is being merged in the scene.
  110423. */
  110424. onBeforeComposeObservable: Observable<EffectLayer>;
  110425. /**
  110426. * An event triggered when the generated texture has been merged in the scene.
  110427. */
  110428. onAfterComposeObservable: Observable<EffectLayer>;
  110429. /**
  110430. * An event triggered when the efffect layer changes its size.
  110431. */
  110432. onSizeChangedObservable: Observable<EffectLayer>;
  110433. /** @hidden */
  110434. static _SceneComponentInitialization: (scene: Scene) => void;
  110435. /**
  110436. * Instantiates a new effect Layer and references it in the scene.
  110437. * @param name The name of the layer
  110438. * @param scene The scene to use the layer in
  110439. */
  110440. constructor(
  110441. /** The Friendly of the effect in the scene */
  110442. name: string, scene: Scene);
  110443. /**
  110444. * Get the effect name of the layer.
  110445. * @return The effect name
  110446. */
  110447. abstract getEffectName(): string;
  110448. /**
  110449. * Checks for the readiness of the element composing the layer.
  110450. * @param subMesh the mesh to check for
  110451. * @param useInstances specify wether or not to use instances to render the mesh
  110452. * @return true if ready otherwise, false
  110453. */
  110454. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110455. /**
  110456. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110457. * @returns true if the effect requires stencil during the main canvas render pass.
  110458. */
  110459. abstract needStencil(): boolean;
  110460. /**
  110461. * Create the merge effect. This is the shader use to blit the information back
  110462. * to the main canvas at the end of the scene rendering.
  110463. * @returns The effect containing the shader used to merge the effect on the main canvas
  110464. */
  110465. protected abstract _createMergeEffect(): Effect;
  110466. /**
  110467. * Creates the render target textures and post processes used in the effect layer.
  110468. */
  110469. protected abstract _createTextureAndPostProcesses(): void;
  110470. /**
  110471. * Implementation specific of rendering the generating effect on the main canvas.
  110472. * @param effect The effect used to render through
  110473. */
  110474. protected abstract _internalRender(effect: Effect): void;
  110475. /**
  110476. * Sets the required values for both the emissive texture and and the main color.
  110477. */
  110478. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110479. /**
  110480. * Free any resources and references associated to a mesh.
  110481. * Internal use
  110482. * @param mesh The mesh to free.
  110483. */
  110484. abstract _disposeMesh(mesh: Mesh): void;
  110485. /**
  110486. * Serializes this layer (Glow or Highlight for example)
  110487. * @returns a serialized layer object
  110488. */
  110489. abstract serialize?(): any;
  110490. /**
  110491. * Initializes the effect layer with the required options.
  110492. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110493. */
  110494. protected _init(options: Partial<IEffectLayerOptions>): void;
  110495. /**
  110496. * Generates the index buffer of the full screen quad blending to the main canvas.
  110497. */
  110498. private _generateIndexBuffer;
  110499. /**
  110500. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110501. */
  110502. private _generateVertexBuffer;
  110503. /**
  110504. * Sets the main texture desired size which is the closest power of two
  110505. * of the engine canvas size.
  110506. */
  110507. private _setMainTextureSize;
  110508. /**
  110509. * Creates the main texture for the effect layer.
  110510. */
  110511. protected _createMainTexture(): void;
  110512. /**
  110513. * Adds specific effects defines.
  110514. * @param defines The defines to add specifics to.
  110515. */
  110516. protected _addCustomEffectDefines(defines: string[]): void;
  110517. /**
  110518. * Checks for the readiness of the element composing the layer.
  110519. * @param subMesh the mesh to check for
  110520. * @param useInstances specify wether or not to use instances to render the mesh
  110521. * @param emissiveTexture the associated emissive texture used to generate the glow
  110522. * @return true if ready otherwise, false
  110523. */
  110524. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110525. /**
  110526. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110527. */
  110528. render(): void;
  110529. /**
  110530. * Determine if a given mesh will be used in the current effect.
  110531. * @param mesh mesh to test
  110532. * @returns true if the mesh will be used
  110533. */
  110534. hasMesh(mesh: AbstractMesh): boolean;
  110535. /**
  110536. * Returns true if the layer contains information to display, otherwise false.
  110537. * @returns true if the glow layer should be rendered
  110538. */
  110539. shouldRender(): boolean;
  110540. /**
  110541. * Returns true if the mesh should render, otherwise false.
  110542. * @param mesh The mesh to render
  110543. * @returns true if it should render otherwise false
  110544. */
  110545. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110546. /**
  110547. * Returns true if the mesh can be rendered, otherwise false.
  110548. * @param mesh The mesh to render
  110549. * @param material The material used on the mesh
  110550. * @returns true if it can be rendered otherwise false
  110551. */
  110552. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110553. /**
  110554. * Returns true if the mesh should render, otherwise false.
  110555. * @param mesh The mesh to render
  110556. * @returns true if it should render otherwise false
  110557. */
  110558. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110559. /**
  110560. * Renders the submesh passed in parameter to the generation map.
  110561. */
  110562. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110563. /**
  110564. * Rebuild the required buffers.
  110565. * @hidden Internal use only.
  110566. */
  110567. _rebuild(): void;
  110568. /**
  110569. * Dispose only the render target textures and post process.
  110570. */
  110571. private _disposeTextureAndPostProcesses;
  110572. /**
  110573. * Dispose the highlight layer and free resources.
  110574. */
  110575. dispose(): void;
  110576. /**
  110577. * Gets the class name of the effect layer
  110578. * @returns the string with the class name of the effect layer
  110579. */
  110580. getClassName(): string;
  110581. /**
  110582. * Creates an effect layer from parsed effect layer data
  110583. * @param parsedEffectLayer defines effect layer data
  110584. * @param scene defines the current scene
  110585. * @param rootUrl defines the root URL containing the effect layer information
  110586. * @returns a parsed effect Layer
  110587. */
  110588. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110589. }
  110590. }
  110591. declare module BABYLON {
  110592. interface AbstractScene {
  110593. /**
  110594. * The list of effect layers (highlights/glow) added to the scene
  110595. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110596. * @see http://doc.babylonjs.com/how_to/glow_layer
  110597. */
  110598. effectLayers: Array<EffectLayer>;
  110599. /**
  110600. * Removes the given effect layer from this scene.
  110601. * @param toRemove defines the effect layer to remove
  110602. * @returns the index of the removed effect layer
  110603. */
  110604. removeEffectLayer(toRemove: EffectLayer): number;
  110605. /**
  110606. * Adds the given effect layer to this scene
  110607. * @param newEffectLayer defines the effect layer to add
  110608. */
  110609. addEffectLayer(newEffectLayer: EffectLayer): void;
  110610. }
  110611. /**
  110612. * Defines the layer scene component responsible to manage any effect layers
  110613. * in a given scene.
  110614. */
  110615. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110616. /**
  110617. * The component name helpfull to identify the component in the list of scene components.
  110618. */
  110619. readonly name: string;
  110620. /**
  110621. * The scene the component belongs to.
  110622. */
  110623. scene: Scene;
  110624. private _engine;
  110625. private _renderEffects;
  110626. private _needStencil;
  110627. private _previousStencilState;
  110628. /**
  110629. * Creates a new instance of the component for the given scene
  110630. * @param scene Defines the scene to register the component in
  110631. */
  110632. constructor(scene: Scene);
  110633. /**
  110634. * Registers the component in a given scene
  110635. */
  110636. register(): void;
  110637. /**
  110638. * Rebuilds the elements related to this component in case of
  110639. * context lost for instance.
  110640. */
  110641. rebuild(): void;
  110642. /**
  110643. * Serializes the component data to the specified json object
  110644. * @param serializationObject The object to serialize to
  110645. */
  110646. serialize(serializationObject: any): void;
  110647. /**
  110648. * Adds all the elements from the container to the scene
  110649. * @param container the container holding the elements
  110650. */
  110651. addFromContainer(container: AbstractScene): void;
  110652. /**
  110653. * Removes all the elements in the container from the scene
  110654. * @param container contains the elements to remove
  110655. * @param dispose if the removed element should be disposed (default: false)
  110656. */
  110657. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110658. /**
  110659. * Disposes the component and the associated ressources.
  110660. */
  110661. dispose(): void;
  110662. private _isReadyForMesh;
  110663. private _renderMainTexture;
  110664. private _setStencil;
  110665. private _setStencilBack;
  110666. private _draw;
  110667. private _drawCamera;
  110668. private _drawRenderingGroup;
  110669. }
  110670. }
  110671. declare module BABYLON {
  110672. /** @hidden */
  110673. export var glowMapMergePixelShader: {
  110674. name: string;
  110675. shader: string;
  110676. };
  110677. }
  110678. declare module BABYLON {
  110679. /** @hidden */
  110680. export var glowMapMergeVertexShader: {
  110681. name: string;
  110682. shader: string;
  110683. };
  110684. }
  110685. declare module BABYLON {
  110686. interface AbstractScene {
  110687. /**
  110688. * Return a the first highlight layer of the scene with a given name.
  110689. * @param name The name of the highlight layer to look for.
  110690. * @return The highlight layer if found otherwise null.
  110691. */
  110692. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110693. }
  110694. /**
  110695. * Glow layer options. This helps customizing the behaviour
  110696. * of the glow layer.
  110697. */
  110698. export interface IGlowLayerOptions {
  110699. /**
  110700. * Multiplication factor apply to the canvas size to compute the render target size
  110701. * used to generated the glowing objects (the smaller the faster).
  110702. */
  110703. mainTextureRatio: number;
  110704. /**
  110705. * Enforces a fixed size texture to ensure resize independant blur.
  110706. */
  110707. mainTextureFixedSize?: number;
  110708. /**
  110709. * How big is the kernel of the blur texture.
  110710. */
  110711. blurKernelSize: number;
  110712. /**
  110713. * The camera attached to the layer.
  110714. */
  110715. camera: Nullable<Camera>;
  110716. /**
  110717. * Enable MSAA by chosing the number of samples.
  110718. */
  110719. mainTextureSamples?: number;
  110720. /**
  110721. * The rendering group to draw the layer in.
  110722. */
  110723. renderingGroupId: number;
  110724. }
  110725. /**
  110726. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110727. *
  110728. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110729. * glowy meshes to your scene.
  110730. *
  110731. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110732. */
  110733. export class GlowLayer extends EffectLayer {
  110734. /**
  110735. * Effect Name of the layer.
  110736. */
  110737. static readonly EffectName: string;
  110738. /**
  110739. * The default blur kernel size used for the glow.
  110740. */
  110741. static DefaultBlurKernelSize: number;
  110742. /**
  110743. * The default texture size ratio used for the glow.
  110744. */
  110745. static DefaultTextureRatio: number;
  110746. /**
  110747. * Sets the kernel size of the blur.
  110748. */
  110749. /**
  110750. * Gets the kernel size of the blur.
  110751. */
  110752. blurKernelSize: number;
  110753. /**
  110754. * Sets the glow intensity.
  110755. */
  110756. /**
  110757. * Gets the glow intensity.
  110758. */
  110759. intensity: number;
  110760. private _options;
  110761. private _intensity;
  110762. private _horizontalBlurPostprocess1;
  110763. private _verticalBlurPostprocess1;
  110764. private _horizontalBlurPostprocess2;
  110765. private _verticalBlurPostprocess2;
  110766. private _blurTexture1;
  110767. private _blurTexture2;
  110768. private _postProcesses1;
  110769. private _postProcesses2;
  110770. private _includedOnlyMeshes;
  110771. private _excludedMeshes;
  110772. /**
  110773. * Callback used to let the user override the color selection on a per mesh basis
  110774. */
  110775. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110776. /**
  110777. * Callback used to let the user override the texture selection on a per mesh basis
  110778. */
  110779. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110780. /**
  110781. * Instantiates a new glow Layer and references it to the scene.
  110782. * @param name The name of the layer
  110783. * @param scene The scene to use the layer in
  110784. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110785. */
  110786. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110787. /**
  110788. * Get the effect name of the layer.
  110789. * @return The effect name
  110790. */
  110791. getEffectName(): string;
  110792. /**
  110793. * Create the merge effect. This is the shader use to blit the information back
  110794. * to the main canvas at the end of the scene rendering.
  110795. */
  110796. protected _createMergeEffect(): Effect;
  110797. /**
  110798. * Creates the render target textures and post processes used in the glow layer.
  110799. */
  110800. protected _createTextureAndPostProcesses(): void;
  110801. /**
  110802. * Checks for the readiness of the element composing the layer.
  110803. * @param subMesh the mesh to check for
  110804. * @param useInstances specify wether or not to use instances to render the mesh
  110805. * @param emissiveTexture the associated emissive texture used to generate the glow
  110806. * @return true if ready otherwise, false
  110807. */
  110808. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110809. /**
  110810. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110811. */
  110812. needStencil(): boolean;
  110813. /**
  110814. * Returns true if the mesh can be rendered, otherwise false.
  110815. * @param mesh The mesh to render
  110816. * @param material The material used on the mesh
  110817. * @returns true if it can be rendered otherwise false
  110818. */
  110819. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110820. /**
  110821. * Implementation specific of rendering the generating effect on the main canvas.
  110822. * @param effect The effect used to render through
  110823. */
  110824. protected _internalRender(effect: Effect): void;
  110825. /**
  110826. * Sets the required values for both the emissive texture and and the main color.
  110827. */
  110828. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110829. /**
  110830. * Returns true if the mesh should render, otherwise false.
  110831. * @param mesh The mesh to render
  110832. * @returns true if it should render otherwise false
  110833. */
  110834. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110835. /**
  110836. * Adds specific effects defines.
  110837. * @param defines The defines to add specifics to.
  110838. */
  110839. protected _addCustomEffectDefines(defines: string[]): void;
  110840. /**
  110841. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110842. * @param mesh The mesh to exclude from the glow layer
  110843. */
  110844. addExcludedMesh(mesh: Mesh): void;
  110845. /**
  110846. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110847. * @param mesh The mesh to remove
  110848. */
  110849. removeExcludedMesh(mesh: Mesh): void;
  110850. /**
  110851. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110852. * @param mesh The mesh to include in the glow layer
  110853. */
  110854. addIncludedOnlyMesh(mesh: Mesh): void;
  110855. /**
  110856. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110857. * @param mesh The mesh to remove
  110858. */
  110859. removeIncludedOnlyMesh(mesh: Mesh): void;
  110860. /**
  110861. * Determine if a given mesh will be used in the glow layer
  110862. * @param mesh The mesh to test
  110863. * @returns true if the mesh will be highlighted by the current glow layer
  110864. */
  110865. hasMesh(mesh: AbstractMesh): boolean;
  110866. /**
  110867. * Free any resources and references associated to a mesh.
  110868. * Internal use
  110869. * @param mesh The mesh to free.
  110870. * @hidden
  110871. */
  110872. _disposeMesh(mesh: Mesh): void;
  110873. /**
  110874. * Gets the class name of the effect layer
  110875. * @returns the string with the class name of the effect layer
  110876. */
  110877. getClassName(): string;
  110878. /**
  110879. * Serializes this glow layer
  110880. * @returns a serialized glow layer object
  110881. */
  110882. serialize(): any;
  110883. /**
  110884. * Creates a Glow Layer from parsed glow layer data
  110885. * @param parsedGlowLayer defines glow layer data
  110886. * @param scene defines the current scene
  110887. * @param rootUrl defines the root URL containing the glow layer information
  110888. * @returns a parsed Glow Layer
  110889. */
  110890. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110891. }
  110892. }
  110893. declare module BABYLON {
  110894. /** @hidden */
  110895. export var glowBlurPostProcessPixelShader: {
  110896. name: string;
  110897. shader: string;
  110898. };
  110899. }
  110900. declare module BABYLON {
  110901. interface AbstractScene {
  110902. /**
  110903. * Return a the first highlight layer of the scene with a given name.
  110904. * @param name The name of the highlight layer to look for.
  110905. * @return The highlight layer if found otherwise null.
  110906. */
  110907. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110908. }
  110909. /**
  110910. * Highlight layer options. This helps customizing the behaviour
  110911. * of the highlight layer.
  110912. */
  110913. export interface IHighlightLayerOptions {
  110914. /**
  110915. * Multiplication factor apply to the canvas size to compute the render target size
  110916. * used to generated the glowing objects (the smaller the faster).
  110917. */
  110918. mainTextureRatio: number;
  110919. /**
  110920. * Enforces a fixed size texture to ensure resize independant blur.
  110921. */
  110922. mainTextureFixedSize?: number;
  110923. /**
  110924. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110925. * of the picture to blur (the smaller the faster).
  110926. */
  110927. blurTextureSizeRatio: number;
  110928. /**
  110929. * How big in texel of the blur texture is the vertical blur.
  110930. */
  110931. blurVerticalSize: number;
  110932. /**
  110933. * How big in texel of the blur texture is the horizontal blur.
  110934. */
  110935. blurHorizontalSize: number;
  110936. /**
  110937. * Alpha blending mode used to apply the blur. Default is combine.
  110938. */
  110939. alphaBlendingMode: number;
  110940. /**
  110941. * The camera attached to the layer.
  110942. */
  110943. camera: Nullable<Camera>;
  110944. /**
  110945. * Should we display highlight as a solid stroke?
  110946. */
  110947. isStroke?: boolean;
  110948. /**
  110949. * The rendering group to draw the layer in.
  110950. */
  110951. renderingGroupId: number;
  110952. }
  110953. /**
  110954. * The highlight layer Helps adding a glow effect around a mesh.
  110955. *
  110956. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110957. * glowy meshes to your scene.
  110958. *
  110959. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110960. */
  110961. export class HighlightLayer extends EffectLayer {
  110962. name: string;
  110963. /**
  110964. * Effect Name of the highlight layer.
  110965. */
  110966. static readonly EffectName: string;
  110967. /**
  110968. * The neutral color used during the preparation of the glow effect.
  110969. * This is black by default as the blend operation is a blend operation.
  110970. */
  110971. static NeutralColor: Color4;
  110972. /**
  110973. * Stencil value used for glowing meshes.
  110974. */
  110975. static GlowingMeshStencilReference: number;
  110976. /**
  110977. * Stencil value used for the other meshes in the scene.
  110978. */
  110979. static NormalMeshStencilReference: number;
  110980. /**
  110981. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110982. */
  110983. innerGlow: boolean;
  110984. /**
  110985. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110986. */
  110987. outerGlow: boolean;
  110988. /**
  110989. * Specifies the horizontal size of the blur.
  110990. */
  110991. /**
  110992. * Gets the horizontal size of the blur.
  110993. */
  110994. blurHorizontalSize: number;
  110995. /**
  110996. * Specifies the vertical size of the blur.
  110997. */
  110998. /**
  110999. * Gets the vertical size of the blur.
  111000. */
  111001. blurVerticalSize: number;
  111002. /**
  111003. * An event triggered when the highlight layer is being blurred.
  111004. */
  111005. onBeforeBlurObservable: Observable<HighlightLayer>;
  111006. /**
  111007. * An event triggered when the highlight layer has been blurred.
  111008. */
  111009. onAfterBlurObservable: Observable<HighlightLayer>;
  111010. private _instanceGlowingMeshStencilReference;
  111011. private _options;
  111012. private _downSamplePostprocess;
  111013. private _horizontalBlurPostprocess;
  111014. private _verticalBlurPostprocess;
  111015. private _blurTexture;
  111016. private _meshes;
  111017. private _excludedMeshes;
  111018. /**
  111019. * Instantiates a new highlight Layer and references it to the scene..
  111020. * @param name The name of the layer
  111021. * @param scene The scene to use the layer in
  111022. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  111023. */
  111024. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  111025. /**
  111026. * Get the effect name of the layer.
  111027. * @return The effect name
  111028. */
  111029. getEffectName(): string;
  111030. /**
  111031. * Create the merge effect. This is the shader use to blit the information back
  111032. * to the main canvas at the end of the scene rendering.
  111033. */
  111034. protected _createMergeEffect(): Effect;
  111035. /**
  111036. * Creates the render target textures and post processes used in the highlight layer.
  111037. */
  111038. protected _createTextureAndPostProcesses(): void;
  111039. /**
  111040. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111041. */
  111042. needStencil(): boolean;
  111043. /**
  111044. * Checks for the readiness of the element composing the layer.
  111045. * @param subMesh the mesh to check for
  111046. * @param useInstances specify wether or not to use instances to render the mesh
  111047. * @param emissiveTexture the associated emissive texture used to generate the glow
  111048. * @return true if ready otherwise, false
  111049. */
  111050. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111051. /**
  111052. * Implementation specific of rendering the generating effect on the main canvas.
  111053. * @param effect The effect used to render through
  111054. */
  111055. protected _internalRender(effect: Effect): void;
  111056. /**
  111057. * Returns true if the layer contains information to display, otherwise false.
  111058. */
  111059. shouldRender(): boolean;
  111060. /**
  111061. * Returns true if the mesh should render, otherwise false.
  111062. * @param mesh The mesh to render
  111063. * @returns true if it should render otherwise false
  111064. */
  111065. protected _shouldRenderMesh(mesh: Mesh): boolean;
  111066. /**
  111067. * Sets the required values for both the emissive texture and and the main color.
  111068. */
  111069. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111070. /**
  111071. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  111072. * @param mesh The mesh to exclude from the highlight layer
  111073. */
  111074. addExcludedMesh(mesh: Mesh): void;
  111075. /**
  111076. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  111077. * @param mesh The mesh to highlight
  111078. */
  111079. removeExcludedMesh(mesh: Mesh): void;
  111080. /**
  111081. * Determine if a given mesh will be highlighted by the current HighlightLayer
  111082. * @param mesh mesh to test
  111083. * @returns true if the mesh will be highlighted by the current HighlightLayer
  111084. */
  111085. hasMesh(mesh: AbstractMesh): boolean;
  111086. /**
  111087. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  111088. * @param mesh The mesh to highlight
  111089. * @param color The color of the highlight
  111090. * @param glowEmissiveOnly Extract the glow from the emissive texture
  111091. */
  111092. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  111093. /**
  111094. * Remove a mesh from the highlight layer in order to make it stop glowing.
  111095. * @param mesh The mesh to highlight
  111096. */
  111097. removeMesh(mesh: Mesh): void;
  111098. /**
  111099. * Force the stencil to the normal expected value for none glowing parts
  111100. */
  111101. private _defaultStencilReference;
  111102. /**
  111103. * Free any resources and references associated to a mesh.
  111104. * Internal use
  111105. * @param mesh The mesh to free.
  111106. * @hidden
  111107. */
  111108. _disposeMesh(mesh: Mesh): void;
  111109. /**
  111110. * Dispose the highlight layer and free resources.
  111111. */
  111112. dispose(): void;
  111113. /**
  111114. * Gets the class name of the effect layer
  111115. * @returns the string with the class name of the effect layer
  111116. */
  111117. getClassName(): string;
  111118. /**
  111119. * Serializes this Highlight layer
  111120. * @returns a serialized Highlight layer object
  111121. */
  111122. serialize(): any;
  111123. /**
  111124. * Creates a Highlight layer from parsed Highlight layer data
  111125. * @param parsedHightlightLayer defines the Highlight layer data
  111126. * @param scene defines the current scene
  111127. * @param rootUrl defines the root URL containing the Highlight layer information
  111128. * @returns a parsed Highlight layer
  111129. */
  111130. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  111131. }
  111132. }
  111133. declare module BABYLON {
  111134. interface AbstractScene {
  111135. /**
  111136. * The list of layers (background and foreground) of the scene
  111137. */
  111138. layers: Array<Layer>;
  111139. }
  111140. /**
  111141. * Defines the layer scene component responsible to manage any layers
  111142. * in a given scene.
  111143. */
  111144. export class LayerSceneComponent implements ISceneComponent {
  111145. /**
  111146. * The component name helpfull to identify the component in the list of scene components.
  111147. */
  111148. readonly name: string;
  111149. /**
  111150. * The scene the component belongs to.
  111151. */
  111152. scene: Scene;
  111153. private _engine;
  111154. /**
  111155. * Creates a new instance of the component for the given scene
  111156. * @param scene Defines the scene to register the component in
  111157. */
  111158. constructor(scene: Scene);
  111159. /**
  111160. * Registers the component in a given scene
  111161. */
  111162. register(): void;
  111163. /**
  111164. * Rebuilds the elements related to this component in case of
  111165. * context lost for instance.
  111166. */
  111167. rebuild(): void;
  111168. /**
  111169. * Disposes the component and the associated ressources.
  111170. */
  111171. dispose(): void;
  111172. private _draw;
  111173. private _drawCameraPredicate;
  111174. private _drawCameraBackground;
  111175. private _drawCameraForeground;
  111176. private _drawRenderTargetPredicate;
  111177. private _drawRenderTargetBackground;
  111178. private _drawRenderTargetForeground;
  111179. /**
  111180. * Adds all the elements from the container to the scene
  111181. * @param container the container holding the elements
  111182. */
  111183. addFromContainer(container: AbstractScene): void;
  111184. /**
  111185. * Removes all the elements in the container from the scene
  111186. * @param container contains the elements to remove
  111187. * @param dispose if the removed element should be disposed (default: false)
  111188. */
  111189. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111190. }
  111191. }
  111192. declare module BABYLON {
  111193. /** @hidden */
  111194. export var layerPixelShader: {
  111195. name: string;
  111196. shader: string;
  111197. };
  111198. }
  111199. declare module BABYLON {
  111200. /** @hidden */
  111201. export var layerVertexShader: {
  111202. name: string;
  111203. shader: string;
  111204. };
  111205. }
  111206. declare module BABYLON {
  111207. /**
  111208. * This represents a full screen 2d layer.
  111209. * This can be useful to display a picture in the background of your scene for instance.
  111210. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111211. */
  111212. export class Layer {
  111213. /**
  111214. * Define the name of the layer.
  111215. */
  111216. name: string;
  111217. /**
  111218. * Define the texture the layer should display.
  111219. */
  111220. texture: Nullable<Texture>;
  111221. /**
  111222. * Is the layer in background or foreground.
  111223. */
  111224. isBackground: boolean;
  111225. /**
  111226. * Define the color of the layer (instead of texture).
  111227. */
  111228. color: Color4;
  111229. /**
  111230. * Define the scale of the layer in order to zoom in out of the texture.
  111231. */
  111232. scale: Vector2;
  111233. /**
  111234. * Define an offset for the layer in order to shift the texture.
  111235. */
  111236. offset: Vector2;
  111237. /**
  111238. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  111239. */
  111240. alphaBlendingMode: number;
  111241. /**
  111242. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  111243. * Alpha test will not mix with the background color in case of transparency.
  111244. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  111245. */
  111246. alphaTest: boolean;
  111247. /**
  111248. * Define a mask to restrict the layer to only some of the scene cameras.
  111249. */
  111250. layerMask: number;
  111251. /**
  111252. * Define the list of render target the layer is visible into.
  111253. */
  111254. renderTargetTextures: RenderTargetTexture[];
  111255. /**
  111256. * Define if the layer is only used in renderTarget or if it also
  111257. * renders in the main frame buffer of the canvas.
  111258. */
  111259. renderOnlyInRenderTargetTextures: boolean;
  111260. private _scene;
  111261. private _vertexBuffers;
  111262. private _indexBuffer;
  111263. private _effect;
  111264. private _alphaTestEffect;
  111265. /**
  111266. * An event triggered when the layer is disposed.
  111267. */
  111268. onDisposeObservable: Observable<Layer>;
  111269. private _onDisposeObserver;
  111270. /**
  111271. * Back compatibility with callback before the onDisposeObservable existed.
  111272. * The set callback will be triggered when the layer has been disposed.
  111273. */
  111274. onDispose: () => void;
  111275. /**
  111276. * An event triggered before rendering the scene
  111277. */
  111278. onBeforeRenderObservable: Observable<Layer>;
  111279. private _onBeforeRenderObserver;
  111280. /**
  111281. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111282. * The set callback will be triggered just before rendering the layer.
  111283. */
  111284. onBeforeRender: () => void;
  111285. /**
  111286. * An event triggered after rendering the scene
  111287. */
  111288. onAfterRenderObservable: Observable<Layer>;
  111289. private _onAfterRenderObserver;
  111290. /**
  111291. * Back compatibility with callback before the onAfterRenderObservable existed.
  111292. * The set callback will be triggered just after rendering the layer.
  111293. */
  111294. onAfterRender: () => void;
  111295. /**
  111296. * Instantiates a new layer.
  111297. * This represents a full screen 2d layer.
  111298. * This can be useful to display a picture in the background of your scene for instance.
  111299. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111300. * @param name Define the name of the layer in the scene
  111301. * @param imgUrl Define the url of the texture to display in the layer
  111302. * @param scene Define the scene the layer belongs to
  111303. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111304. * @param color Defines a color for the layer
  111305. */
  111306. constructor(
  111307. /**
  111308. * Define the name of the layer.
  111309. */
  111310. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111311. private _createIndexBuffer;
  111312. /** @hidden */
  111313. _rebuild(): void;
  111314. /**
  111315. * Renders the layer in the scene.
  111316. */
  111317. render(): void;
  111318. /**
  111319. * Disposes and releases the associated ressources.
  111320. */
  111321. dispose(): void;
  111322. }
  111323. }
  111324. declare module BABYLON {
  111325. /** @hidden */
  111326. export var lensFlarePixelShader: {
  111327. name: string;
  111328. shader: string;
  111329. };
  111330. }
  111331. declare module BABYLON {
  111332. /** @hidden */
  111333. export var lensFlareVertexShader: {
  111334. name: string;
  111335. shader: string;
  111336. };
  111337. }
  111338. declare module BABYLON {
  111339. /**
  111340. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111341. * It is usually composed of several `lensFlare`.
  111342. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111343. */
  111344. export class LensFlareSystem {
  111345. /**
  111346. * Define the name of the lens flare system
  111347. */
  111348. name: string;
  111349. /**
  111350. * List of lens flares used in this system.
  111351. */
  111352. lensFlares: LensFlare[];
  111353. /**
  111354. * Define a limit from the border the lens flare can be visible.
  111355. */
  111356. borderLimit: number;
  111357. /**
  111358. * Define a viewport border we do not want to see the lens flare in.
  111359. */
  111360. viewportBorder: number;
  111361. /**
  111362. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111363. */
  111364. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111365. /**
  111366. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111367. */
  111368. layerMask: number;
  111369. /**
  111370. * Define the id of the lens flare system in the scene.
  111371. * (equal to name by default)
  111372. */
  111373. id: string;
  111374. private _scene;
  111375. private _emitter;
  111376. private _vertexBuffers;
  111377. private _indexBuffer;
  111378. private _effect;
  111379. private _positionX;
  111380. private _positionY;
  111381. private _isEnabled;
  111382. /** @hidden */
  111383. static _SceneComponentInitialization: (scene: Scene) => void;
  111384. /**
  111385. * Instantiates a lens flare system.
  111386. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111387. * It is usually composed of several `lensFlare`.
  111388. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111389. * @param name Define the name of the lens flare system in the scene
  111390. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111391. * @param scene Define the scene the lens flare system belongs to
  111392. */
  111393. constructor(
  111394. /**
  111395. * Define the name of the lens flare system
  111396. */
  111397. name: string, emitter: any, scene: Scene);
  111398. /**
  111399. * Define if the lens flare system is enabled.
  111400. */
  111401. isEnabled: boolean;
  111402. /**
  111403. * Get the scene the effects belongs to.
  111404. * @returns the scene holding the lens flare system
  111405. */
  111406. getScene(): Scene;
  111407. /**
  111408. * Get the emitter of the lens flare system.
  111409. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111410. * @returns the emitter of the lens flare system
  111411. */
  111412. getEmitter(): any;
  111413. /**
  111414. * Set the emitter of the lens flare system.
  111415. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111416. * @param newEmitter Define the new emitter of the system
  111417. */
  111418. setEmitter(newEmitter: any): void;
  111419. /**
  111420. * Get the lens flare system emitter position.
  111421. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111422. * @returns the position
  111423. */
  111424. getEmitterPosition(): Vector3;
  111425. /**
  111426. * @hidden
  111427. */
  111428. computeEffectivePosition(globalViewport: Viewport): boolean;
  111429. /** @hidden */
  111430. _isVisible(): boolean;
  111431. /**
  111432. * @hidden
  111433. */
  111434. render(): boolean;
  111435. /**
  111436. * Dispose and release the lens flare with its associated resources.
  111437. */
  111438. dispose(): void;
  111439. /**
  111440. * Parse a lens flare system from a JSON repressentation
  111441. * @param parsedLensFlareSystem Define the JSON to parse
  111442. * @param scene Define the scene the parsed system should be instantiated in
  111443. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111444. * @returns the parsed system
  111445. */
  111446. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111447. /**
  111448. * Serialize the current Lens Flare System into a JSON representation.
  111449. * @returns the serialized JSON
  111450. */
  111451. serialize(): any;
  111452. }
  111453. }
  111454. declare module BABYLON {
  111455. /**
  111456. * This represents one of the lens effect in a `lensFlareSystem`.
  111457. * It controls one of the indiviual texture used in the effect.
  111458. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111459. */
  111460. export class LensFlare {
  111461. /**
  111462. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111463. */
  111464. size: number;
  111465. /**
  111466. * 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.
  111467. */
  111468. position: number;
  111469. /**
  111470. * Define the lens color.
  111471. */
  111472. color: Color3;
  111473. /**
  111474. * Define the lens texture.
  111475. */
  111476. texture: Nullable<Texture>;
  111477. /**
  111478. * Define the alpha mode to render this particular lens.
  111479. */
  111480. alphaMode: number;
  111481. private _system;
  111482. /**
  111483. * Creates a new Lens Flare.
  111484. * This represents one of the lens effect in a `lensFlareSystem`.
  111485. * It controls one of the indiviual texture used in the effect.
  111486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111487. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111488. * @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.
  111489. * @param color Define the lens color
  111490. * @param imgUrl Define the lens texture url
  111491. * @param system Define the `lensFlareSystem` this flare is part of
  111492. * @returns The newly created Lens Flare
  111493. */
  111494. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111495. /**
  111496. * Instantiates a new Lens Flare.
  111497. * This represents one of the lens effect in a `lensFlareSystem`.
  111498. * It controls one of the indiviual texture used in the effect.
  111499. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111500. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111501. * @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.
  111502. * @param color Define the lens color
  111503. * @param imgUrl Define the lens texture url
  111504. * @param system Define the `lensFlareSystem` this flare is part of
  111505. */
  111506. constructor(
  111507. /**
  111508. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111509. */
  111510. size: number,
  111511. /**
  111512. * 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.
  111513. */
  111514. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111515. /**
  111516. * Dispose and release the lens flare with its associated resources.
  111517. */
  111518. dispose(): void;
  111519. }
  111520. }
  111521. declare module BABYLON {
  111522. interface AbstractScene {
  111523. /**
  111524. * The list of lens flare system added to the scene
  111525. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111526. */
  111527. lensFlareSystems: Array<LensFlareSystem>;
  111528. /**
  111529. * Removes the given lens flare system from this scene.
  111530. * @param toRemove The lens flare system to remove
  111531. * @returns The index of the removed lens flare system
  111532. */
  111533. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111534. /**
  111535. * Adds the given lens flare system to this scene
  111536. * @param newLensFlareSystem The lens flare system to add
  111537. */
  111538. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111539. /**
  111540. * Gets a lens flare system using its name
  111541. * @param name defines the name to look for
  111542. * @returns the lens flare system or null if not found
  111543. */
  111544. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111545. /**
  111546. * Gets a lens flare system using its id
  111547. * @param id defines the id to look for
  111548. * @returns the lens flare system or null if not found
  111549. */
  111550. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111551. }
  111552. /**
  111553. * Defines the lens flare scene component responsible to manage any lens flares
  111554. * in a given scene.
  111555. */
  111556. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111557. /**
  111558. * The component name helpfull to identify the component in the list of scene components.
  111559. */
  111560. readonly name: string;
  111561. /**
  111562. * The scene the component belongs to.
  111563. */
  111564. scene: Scene;
  111565. /**
  111566. * Creates a new instance of the component for the given scene
  111567. * @param scene Defines the scene to register the component in
  111568. */
  111569. constructor(scene: Scene);
  111570. /**
  111571. * Registers the component in a given scene
  111572. */
  111573. register(): void;
  111574. /**
  111575. * Rebuilds the elements related to this component in case of
  111576. * context lost for instance.
  111577. */
  111578. rebuild(): void;
  111579. /**
  111580. * Adds all the elements from the container to the scene
  111581. * @param container the container holding the elements
  111582. */
  111583. addFromContainer(container: AbstractScene): void;
  111584. /**
  111585. * Removes all the elements in the container from the scene
  111586. * @param container contains the elements to remove
  111587. * @param dispose if the removed element should be disposed (default: false)
  111588. */
  111589. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111590. /**
  111591. * Serializes the component data to the specified json object
  111592. * @param serializationObject The object to serialize to
  111593. */
  111594. serialize(serializationObject: any): void;
  111595. /**
  111596. * Disposes the component and the associated ressources.
  111597. */
  111598. dispose(): void;
  111599. private _draw;
  111600. }
  111601. }
  111602. declare module BABYLON {
  111603. /**
  111604. * Defines the shadow generator component responsible to manage any shadow generators
  111605. * in a given scene.
  111606. */
  111607. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111608. /**
  111609. * The component name helpfull to identify the component in the list of scene components.
  111610. */
  111611. readonly name: string;
  111612. /**
  111613. * The scene the component belongs to.
  111614. */
  111615. scene: Scene;
  111616. /**
  111617. * Creates a new instance of the component for the given scene
  111618. * @param scene Defines the scene to register the component in
  111619. */
  111620. constructor(scene: Scene);
  111621. /**
  111622. * Registers the component in a given scene
  111623. */
  111624. register(): void;
  111625. /**
  111626. * Rebuilds the elements related to this component in case of
  111627. * context lost for instance.
  111628. */
  111629. rebuild(): void;
  111630. /**
  111631. * Serializes the component data to the specified json object
  111632. * @param serializationObject The object to serialize to
  111633. */
  111634. serialize(serializationObject: any): void;
  111635. /**
  111636. * Adds all the elements from the container to the scene
  111637. * @param container the container holding the elements
  111638. */
  111639. addFromContainer(container: AbstractScene): void;
  111640. /**
  111641. * Removes all the elements in the container from the scene
  111642. * @param container contains the elements to remove
  111643. * @param dispose if the removed element should be disposed (default: false)
  111644. */
  111645. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111646. /**
  111647. * Rebuilds the elements related to this component in case of
  111648. * context lost for instance.
  111649. */
  111650. dispose(): void;
  111651. private _gatherRenderTargets;
  111652. }
  111653. }
  111654. declare module BABYLON {
  111655. /**
  111656. * A point light is a light defined by an unique point in world space.
  111657. * The light is emitted in every direction from this point.
  111658. * A good example of a point light is a standard light bulb.
  111659. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111660. */
  111661. export class PointLight extends ShadowLight {
  111662. private _shadowAngle;
  111663. /**
  111664. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111665. * This specifies what angle the shadow will use to be created.
  111666. *
  111667. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111668. */
  111669. /**
  111670. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111671. * This specifies what angle the shadow will use to be created.
  111672. *
  111673. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111674. */
  111675. shadowAngle: number;
  111676. /**
  111677. * Gets the direction if it has been set.
  111678. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111679. */
  111680. /**
  111681. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111682. */
  111683. direction: Vector3;
  111684. /**
  111685. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111686. * A PointLight emits the light in every direction.
  111687. * It can cast shadows.
  111688. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111689. * ```javascript
  111690. * var pointLight = new PointLight("pl", camera.position, scene);
  111691. * ```
  111692. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111693. * @param name The light friendly name
  111694. * @param position The position of the point light in the scene
  111695. * @param scene The scene the lights belongs to
  111696. */
  111697. constructor(name: string, position: Vector3, scene: Scene);
  111698. /**
  111699. * Returns the string "PointLight"
  111700. * @returns the class name
  111701. */
  111702. getClassName(): string;
  111703. /**
  111704. * Returns the integer 0.
  111705. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111706. */
  111707. getTypeID(): number;
  111708. /**
  111709. * Specifies wether or not the shadowmap should be a cube texture.
  111710. * @returns true if the shadowmap needs to be a cube texture.
  111711. */
  111712. needCube(): boolean;
  111713. /**
  111714. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111715. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111716. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111717. */
  111718. getShadowDirection(faceIndex?: number): Vector3;
  111719. /**
  111720. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111721. * - fov = PI / 2
  111722. * - aspect ratio : 1.0
  111723. * - z-near and far equal to the active camera minZ and maxZ.
  111724. * Returns the PointLight.
  111725. */
  111726. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111727. protected _buildUniformLayout(): void;
  111728. /**
  111729. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111730. * @param effect The effect to update
  111731. * @param lightIndex The index of the light in the effect to update
  111732. * @returns The point light
  111733. */
  111734. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111735. /**
  111736. * Prepares the list of defines specific to the light type.
  111737. * @param defines the list of defines
  111738. * @param lightIndex defines the index of the light for the effect
  111739. */
  111740. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111741. }
  111742. }
  111743. declare module BABYLON {
  111744. /**
  111745. * Header information of HDR texture files.
  111746. */
  111747. export interface HDRInfo {
  111748. /**
  111749. * The height of the texture in pixels.
  111750. */
  111751. height: number;
  111752. /**
  111753. * The width of the texture in pixels.
  111754. */
  111755. width: number;
  111756. /**
  111757. * The index of the beginning of the data in the binary file.
  111758. */
  111759. dataPosition: number;
  111760. }
  111761. /**
  111762. * This groups tools to convert HDR texture to native colors array.
  111763. */
  111764. export class HDRTools {
  111765. private static Ldexp;
  111766. private static Rgbe2float;
  111767. private static readStringLine;
  111768. /**
  111769. * Reads header information from an RGBE texture stored in a native array.
  111770. * More information on this format are available here:
  111771. * https://en.wikipedia.org/wiki/RGBE_image_format
  111772. *
  111773. * @param uint8array The binary file stored in native array.
  111774. * @return The header information.
  111775. */
  111776. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111777. /**
  111778. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111779. * This RGBE texture needs to store the information as a panorama.
  111780. *
  111781. * More information on this format are available here:
  111782. * https://en.wikipedia.org/wiki/RGBE_image_format
  111783. *
  111784. * @param buffer The binary file stored in an array buffer.
  111785. * @param size The expected size of the extracted cubemap.
  111786. * @return The Cube Map information.
  111787. */
  111788. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111789. /**
  111790. * Returns the pixels data extracted from an RGBE texture.
  111791. * This pixels will be stored left to right up to down in the R G B order in one array.
  111792. *
  111793. * More information on this format are available here:
  111794. * https://en.wikipedia.org/wiki/RGBE_image_format
  111795. *
  111796. * @param uint8array The binary file stored in an array buffer.
  111797. * @param hdrInfo The header information of the file.
  111798. * @return The pixels data in RGB right to left up to down order.
  111799. */
  111800. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111801. private static RGBE_ReadPixels_RLE;
  111802. }
  111803. }
  111804. declare module BABYLON {
  111805. /**
  111806. * This represents a texture coming from an HDR input.
  111807. *
  111808. * The only supported format is currently panorama picture stored in RGBE format.
  111809. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111810. */
  111811. export class HDRCubeTexture extends BaseTexture {
  111812. private static _facesMapping;
  111813. private _generateHarmonics;
  111814. private _noMipmap;
  111815. private _textureMatrix;
  111816. private _size;
  111817. private _onLoad;
  111818. private _onError;
  111819. /**
  111820. * The texture URL.
  111821. */
  111822. url: string;
  111823. /**
  111824. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111825. */
  111826. coordinatesMode: number;
  111827. protected _isBlocking: boolean;
  111828. /**
  111829. * Sets wether or not the texture is blocking during loading.
  111830. */
  111831. /**
  111832. * Gets wether or not the texture is blocking during loading.
  111833. */
  111834. isBlocking: boolean;
  111835. protected _rotationY: number;
  111836. /**
  111837. * Sets texture matrix rotation angle around Y axis in radians.
  111838. */
  111839. /**
  111840. * Gets texture matrix rotation angle around Y axis radians.
  111841. */
  111842. rotationY: number;
  111843. /**
  111844. * Gets or sets the center of the bounding box associated with the cube texture
  111845. * It must define where the camera used to render the texture was set
  111846. */
  111847. boundingBoxPosition: Vector3;
  111848. private _boundingBoxSize;
  111849. /**
  111850. * Gets or sets the size of the bounding box associated with the cube texture
  111851. * When defined, the cubemap will switch to local mode
  111852. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111853. * @example https://www.babylonjs-playground.com/#RNASML
  111854. */
  111855. boundingBoxSize: Vector3;
  111856. /**
  111857. * Instantiates an HDRTexture from the following parameters.
  111858. *
  111859. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111860. * @param scene The scene the texture will be used in
  111861. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111862. * @param noMipmap Forces to not generate the mipmap if true
  111863. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111864. * @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)
  111865. * @param reserved Reserved flag for internal use.
  111866. */
  111867. 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>);
  111868. /**
  111869. * Get the current class name of the texture useful for serialization or dynamic coding.
  111870. * @returns "HDRCubeTexture"
  111871. */
  111872. getClassName(): string;
  111873. /**
  111874. * Occurs when the file is raw .hdr file.
  111875. */
  111876. private loadTexture;
  111877. clone(): HDRCubeTexture;
  111878. delayLoad(): void;
  111879. /**
  111880. * Get the texture reflection matrix used to rotate/transform the reflection.
  111881. * @returns the reflection matrix
  111882. */
  111883. getReflectionTextureMatrix(): Matrix;
  111884. /**
  111885. * Set the texture reflection matrix used to rotate/transform the reflection.
  111886. * @param value Define the reflection matrix to set
  111887. */
  111888. setReflectionTextureMatrix(value: Matrix): void;
  111889. /**
  111890. * Parses a JSON representation of an HDR Texture in order to create the texture
  111891. * @param parsedTexture Define the JSON representation
  111892. * @param scene Define the scene the texture should be created in
  111893. * @param rootUrl Define the root url in case we need to load relative dependencies
  111894. * @returns the newly created texture after parsing
  111895. */
  111896. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111897. serialize(): any;
  111898. }
  111899. }
  111900. declare module BABYLON {
  111901. /**
  111902. * Class used to control physics engine
  111903. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111904. */
  111905. export class PhysicsEngine implements IPhysicsEngine {
  111906. private _physicsPlugin;
  111907. /**
  111908. * Global value used to control the smallest number supported by the simulation
  111909. */
  111910. static Epsilon: number;
  111911. private _impostors;
  111912. private _joints;
  111913. /**
  111914. * Gets the gravity vector used by the simulation
  111915. */
  111916. gravity: Vector3;
  111917. /**
  111918. * Factory used to create the default physics plugin.
  111919. * @returns The default physics plugin
  111920. */
  111921. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111922. /**
  111923. * Creates a new Physics Engine
  111924. * @param gravity defines the gravity vector used by the simulation
  111925. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111926. */
  111927. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111928. /**
  111929. * Sets the gravity vector used by the simulation
  111930. * @param gravity defines the gravity vector to use
  111931. */
  111932. setGravity(gravity: Vector3): void;
  111933. /**
  111934. * Set the time step of the physics engine.
  111935. * Default is 1/60.
  111936. * To slow it down, enter 1/600 for example.
  111937. * To speed it up, 1/30
  111938. * @param newTimeStep defines the new timestep to apply to this world.
  111939. */
  111940. setTimeStep(newTimeStep?: number): void;
  111941. /**
  111942. * Get the time step of the physics engine.
  111943. * @returns the current time step
  111944. */
  111945. getTimeStep(): number;
  111946. /**
  111947. * Release all resources
  111948. */
  111949. dispose(): void;
  111950. /**
  111951. * Gets the name of the current physics plugin
  111952. * @returns the name of the plugin
  111953. */
  111954. getPhysicsPluginName(): string;
  111955. /**
  111956. * Adding a new impostor for the impostor tracking.
  111957. * This will be done by the impostor itself.
  111958. * @param impostor the impostor to add
  111959. */
  111960. addImpostor(impostor: PhysicsImpostor): void;
  111961. /**
  111962. * Remove an impostor from the engine.
  111963. * This impostor and its mesh will not longer be updated by the physics engine.
  111964. * @param impostor the impostor to remove
  111965. */
  111966. removeImpostor(impostor: PhysicsImpostor): void;
  111967. /**
  111968. * Add a joint to the physics engine
  111969. * @param mainImpostor defines the main impostor to which the joint is added.
  111970. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111971. * @param joint defines the joint that will connect both impostors.
  111972. */
  111973. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111974. /**
  111975. * Removes a joint from the simulation
  111976. * @param mainImpostor defines the impostor used with the joint
  111977. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111978. * @param joint defines the joint to remove
  111979. */
  111980. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111981. /**
  111982. * Called by the scene. No need to call it.
  111983. * @param delta defines the timespam between frames
  111984. */
  111985. _step(delta: number): void;
  111986. /**
  111987. * Gets the current plugin used to run the simulation
  111988. * @returns current plugin
  111989. */
  111990. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111991. /**
  111992. * Gets the list of physic impostors
  111993. * @returns an array of PhysicsImpostor
  111994. */
  111995. getImpostors(): Array<PhysicsImpostor>;
  111996. /**
  111997. * Gets the impostor for a physics enabled object
  111998. * @param object defines the object impersonated by the impostor
  111999. * @returns the PhysicsImpostor or null if not found
  112000. */
  112001. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112002. /**
  112003. * Gets the impostor for a physics body object
  112004. * @param body defines physics body used by the impostor
  112005. * @returns the PhysicsImpostor or null if not found
  112006. */
  112007. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112008. /**
  112009. * Does a raycast in the physics world
  112010. * @param from when should the ray start?
  112011. * @param to when should the ray end?
  112012. * @returns PhysicsRaycastResult
  112013. */
  112014. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112015. }
  112016. }
  112017. declare module BABYLON {
  112018. /** @hidden */
  112019. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  112020. private _useDeltaForWorldStep;
  112021. world: any;
  112022. name: string;
  112023. private _physicsMaterials;
  112024. private _fixedTimeStep;
  112025. private _cannonRaycastResult;
  112026. private _raycastResult;
  112027. private _removeAfterStep;
  112028. BJSCANNON: any;
  112029. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  112030. setGravity(gravity: Vector3): void;
  112031. setTimeStep(timeStep: number): void;
  112032. getTimeStep(): number;
  112033. executeStep(delta: number): void;
  112034. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112035. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112036. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112037. private _processChildMeshes;
  112038. removePhysicsBody(impostor: PhysicsImpostor): void;
  112039. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112040. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112041. private _addMaterial;
  112042. private _checkWithEpsilon;
  112043. private _createShape;
  112044. private _createHeightmap;
  112045. private _minus90X;
  112046. private _plus90X;
  112047. private _tmpPosition;
  112048. private _tmpDeltaPosition;
  112049. private _tmpUnityRotation;
  112050. private _updatePhysicsBodyTransformation;
  112051. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112052. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112053. isSupported(): boolean;
  112054. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112055. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112056. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112057. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112058. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112059. getBodyMass(impostor: PhysicsImpostor): number;
  112060. getBodyFriction(impostor: PhysicsImpostor): number;
  112061. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112062. getBodyRestitution(impostor: PhysicsImpostor): number;
  112063. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112064. sleepBody(impostor: PhysicsImpostor): void;
  112065. wakeUpBody(impostor: PhysicsImpostor): void;
  112066. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  112067. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112068. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112069. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112070. getRadius(impostor: PhysicsImpostor): number;
  112071. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112072. dispose(): void;
  112073. private _extendNamespace;
  112074. /**
  112075. * Does a raycast in the physics world
  112076. * @param from when should the ray start?
  112077. * @param to when should the ray end?
  112078. * @returns PhysicsRaycastResult
  112079. */
  112080. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112081. }
  112082. }
  112083. declare module BABYLON {
  112084. /** @hidden */
  112085. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  112086. world: any;
  112087. name: string;
  112088. BJSOIMO: any;
  112089. private _raycastResult;
  112090. constructor(iterations?: number, oimoInjection?: any);
  112091. setGravity(gravity: Vector3): void;
  112092. setTimeStep(timeStep: number): void;
  112093. getTimeStep(): number;
  112094. private _tmpImpostorsArray;
  112095. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112096. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112097. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112098. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112099. private _tmpPositionVector;
  112100. removePhysicsBody(impostor: PhysicsImpostor): void;
  112101. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112102. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112103. isSupported(): boolean;
  112104. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112105. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112106. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112107. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112108. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112109. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112110. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112111. getBodyMass(impostor: PhysicsImpostor): number;
  112112. getBodyFriction(impostor: PhysicsImpostor): number;
  112113. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112114. getBodyRestitution(impostor: PhysicsImpostor): number;
  112115. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112116. sleepBody(impostor: PhysicsImpostor): void;
  112117. wakeUpBody(impostor: PhysicsImpostor): void;
  112118. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112119. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  112120. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112121. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112122. getRadius(impostor: PhysicsImpostor): number;
  112123. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112124. dispose(): void;
  112125. /**
  112126. * Does a raycast in the physics world
  112127. * @param from when should the ray start?
  112128. * @param to when should the ray end?
  112129. * @returns PhysicsRaycastResult
  112130. */
  112131. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112132. }
  112133. }
  112134. declare module BABYLON {
  112135. /**
  112136. * Class containing static functions to help procedurally build meshes
  112137. */
  112138. export class RibbonBuilder {
  112139. /**
  112140. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  112141. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  112142. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  112143. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  112144. * * 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
  112145. * * 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
  112146. * * 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
  112147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112149. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112150. * * 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
  112151. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  112152. * * 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
  112153. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  112154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112155. * @param name defines the name of the mesh
  112156. * @param options defines the options used to create the mesh
  112157. * @param scene defines the hosting scene
  112158. * @returns the ribbon mesh
  112159. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  112160. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112161. */
  112162. static CreateRibbon(name: string, options: {
  112163. pathArray: Vector3[][];
  112164. closeArray?: boolean;
  112165. closePath?: boolean;
  112166. offset?: number;
  112167. updatable?: boolean;
  112168. sideOrientation?: number;
  112169. frontUVs?: Vector4;
  112170. backUVs?: Vector4;
  112171. instance?: Mesh;
  112172. invertUV?: boolean;
  112173. uvs?: Vector2[];
  112174. colors?: Color4[];
  112175. }, scene?: Nullable<Scene>): Mesh;
  112176. }
  112177. }
  112178. declare module BABYLON {
  112179. /**
  112180. * Class containing static functions to help procedurally build meshes
  112181. */
  112182. export class ShapeBuilder {
  112183. /**
  112184. * 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.
  112185. * * 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.
  112186. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112187. * * 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.
  112188. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  112189. * * 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
  112190. * * 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
  112191. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  112192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112194. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  112195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112196. * @param name defines the name of the mesh
  112197. * @param options defines the options used to create the mesh
  112198. * @param scene defines the hosting scene
  112199. * @returns the extruded shape mesh
  112200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112202. */
  112203. static ExtrudeShape(name: string, options: {
  112204. shape: Vector3[];
  112205. path: Vector3[];
  112206. scale?: number;
  112207. rotation?: number;
  112208. cap?: number;
  112209. updatable?: boolean;
  112210. sideOrientation?: number;
  112211. frontUVs?: Vector4;
  112212. backUVs?: Vector4;
  112213. instance?: Mesh;
  112214. invertUV?: boolean;
  112215. }, scene?: Nullable<Scene>): Mesh;
  112216. /**
  112217. * Creates an custom extruded shape mesh.
  112218. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  112219. * * 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.
  112220. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112221. * * 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
  112222. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  112223. * * 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
  112224. * * It must returns a float value that will be the scale value applied to the shape on each path point
  112225. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  112226. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  112227. * * 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
  112228. * * 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
  112229. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  112230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112232. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112234. * @param name defines the name of the mesh
  112235. * @param options defines the options used to create the mesh
  112236. * @param scene defines the hosting scene
  112237. * @returns the custom extruded shape mesh
  112238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  112239. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112240. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112241. */
  112242. static ExtrudeShapeCustom(name: string, options: {
  112243. shape: Vector3[];
  112244. path: Vector3[];
  112245. scaleFunction?: any;
  112246. rotationFunction?: any;
  112247. ribbonCloseArray?: boolean;
  112248. ribbonClosePath?: boolean;
  112249. cap?: number;
  112250. updatable?: boolean;
  112251. sideOrientation?: number;
  112252. frontUVs?: Vector4;
  112253. backUVs?: Vector4;
  112254. instance?: Mesh;
  112255. invertUV?: boolean;
  112256. }, scene?: Nullable<Scene>): Mesh;
  112257. private static _ExtrudeShapeGeneric;
  112258. }
  112259. }
  112260. declare module BABYLON {
  112261. /**
  112262. * AmmoJS Physics plugin
  112263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112264. * @see https://github.com/kripken/ammo.js/
  112265. */
  112266. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112267. private _useDeltaForWorldStep;
  112268. /**
  112269. * Reference to the Ammo library
  112270. */
  112271. bjsAMMO: any;
  112272. /**
  112273. * Created ammoJS world which physics bodies are added to
  112274. */
  112275. world: any;
  112276. /**
  112277. * Name of the plugin
  112278. */
  112279. name: string;
  112280. private _timeStep;
  112281. private _fixedTimeStep;
  112282. private _maxSteps;
  112283. private _tmpQuaternion;
  112284. private _tmpAmmoTransform;
  112285. private _tmpAmmoQuaternion;
  112286. private _tmpAmmoConcreteContactResultCallback;
  112287. private _collisionConfiguration;
  112288. private _dispatcher;
  112289. private _overlappingPairCache;
  112290. private _solver;
  112291. private _softBodySolver;
  112292. private _tmpAmmoVectorA;
  112293. private _tmpAmmoVectorB;
  112294. private _tmpAmmoVectorC;
  112295. private _tmpAmmoVectorD;
  112296. private _tmpContactCallbackResult;
  112297. private _tmpAmmoVectorRCA;
  112298. private _tmpAmmoVectorRCB;
  112299. private _raycastResult;
  112300. private static readonly DISABLE_COLLISION_FLAG;
  112301. private static readonly KINEMATIC_FLAG;
  112302. private static readonly DISABLE_DEACTIVATION_FLAG;
  112303. /**
  112304. * Initializes the ammoJS plugin
  112305. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112306. * @param ammoInjection can be used to inject your own ammo reference
  112307. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112308. */
  112309. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112310. /**
  112311. * Sets the gravity of the physics world (m/(s^2))
  112312. * @param gravity Gravity to set
  112313. */
  112314. setGravity(gravity: Vector3): void;
  112315. /**
  112316. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112317. * @param timeStep timestep to use in seconds
  112318. */
  112319. setTimeStep(timeStep: number): void;
  112320. /**
  112321. * 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)
  112322. * @param fixedTimeStep fixedTimeStep to use in seconds
  112323. */
  112324. setFixedTimeStep(fixedTimeStep: number): void;
  112325. /**
  112326. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112327. * @param maxSteps the maximum number of steps by the physics engine per frame
  112328. */
  112329. setMaxSteps(maxSteps: number): void;
  112330. /**
  112331. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112332. * @returns the current timestep in seconds
  112333. */
  112334. getTimeStep(): number;
  112335. private _isImpostorInContact;
  112336. private _isImpostorPairInContact;
  112337. private _stepSimulation;
  112338. /**
  112339. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112340. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112341. * After the step the babylon meshes are set to the position of the physics imposters
  112342. * @param delta amount of time to step forward
  112343. * @param impostors array of imposters to update before/after the step
  112344. */
  112345. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112346. /**
  112347. * Update babylon mesh to match physics world object
  112348. * @param impostor imposter to match
  112349. */
  112350. private _afterSoftStep;
  112351. /**
  112352. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112353. * @param impostor imposter to match
  112354. */
  112355. private _ropeStep;
  112356. /**
  112357. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112358. * @param impostor imposter to match
  112359. */
  112360. private _softbodyOrClothStep;
  112361. private _tmpVector;
  112362. private _tmpMatrix;
  112363. /**
  112364. * Applies an impulse on the imposter
  112365. * @param impostor imposter to apply impulse to
  112366. * @param force amount of force to be applied to the imposter
  112367. * @param contactPoint the location to apply the impulse on the imposter
  112368. */
  112369. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112370. /**
  112371. * Applies a force on the imposter
  112372. * @param impostor imposter to apply force
  112373. * @param force amount of force to be applied to the imposter
  112374. * @param contactPoint the location to apply the force on the imposter
  112375. */
  112376. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112377. /**
  112378. * Creates a physics body using the plugin
  112379. * @param impostor the imposter to create the physics body on
  112380. */
  112381. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112382. /**
  112383. * Removes the physics body from the imposter and disposes of the body's memory
  112384. * @param impostor imposter to remove the physics body from
  112385. */
  112386. removePhysicsBody(impostor: PhysicsImpostor): void;
  112387. /**
  112388. * Generates a joint
  112389. * @param impostorJoint the imposter joint to create the joint with
  112390. */
  112391. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112392. /**
  112393. * Removes a joint
  112394. * @param impostorJoint the imposter joint to remove the joint from
  112395. */
  112396. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112397. private _addMeshVerts;
  112398. /**
  112399. * Initialise the soft body vertices to match its object's (mesh) vertices
  112400. * Softbody vertices (nodes) are in world space and to match this
  112401. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112402. * @param impostor to create the softbody for
  112403. */
  112404. private _softVertexData;
  112405. /**
  112406. * Create an impostor's soft body
  112407. * @param impostor to create the softbody for
  112408. */
  112409. private _createSoftbody;
  112410. /**
  112411. * Create cloth for an impostor
  112412. * @param impostor to create the softbody for
  112413. */
  112414. private _createCloth;
  112415. /**
  112416. * Create rope for an impostor
  112417. * @param impostor to create the softbody for
  112418. */
  112419. private _createRope;
  112420. private _addHullVerts;
  112421. private _createShape;
  112422. /**
  112423. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112424. * @param impostor imposter containing the physics body and babylon object
  112425. */
  112426. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112427. /**
  112428. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112429. * @param impostor imposter containing the physics body and babylon object
  112430. * @param newPosition new position
  112431. * @param newRotation new rotation
  112432. */
  112433. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112434. /**
  112435. * If this plugin is supported
  112436. * @returns true if its supported
  112437. */
  112438. isSupported(): boolean;
  112439. /**
  112440. * Sets the linear velocity of the physics body
  112441. * @param impostor imposter to set the velocity on
  112442. * @param velocity velocity to set
  112443. */
  112444. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112445. /**
  112446. * Sets the angular velocity of the physics body
  112447. * @param impostor imposter to set the velocity on
  112448. * @param velocity velocity to set
  112449. */
  112450. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112451. /**
  112452. * gets the linear velocity
  112453. * @param impostor imposter to get linear velocity from
  112454. * @returns linear velocity
  112455. */
  112456. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112457. /**
  112458. * gets the angular velocity
  112459. * @param impostor imposter to get angular velocity from
  112460. * @returns angular velocity
  112461. */
  112462. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112463. /**
  112464. * Sets the mass of physics body
  112465. * @param impostor imposter to set the mass on
  112466. * @param mass mass to set
  112467. */
  112468. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112469. /**
  112470. * Gets the mass of the physics body
  112471. * @param impostor imposter to get the mass from
  112472. * @returns mass
  112473. */
  112474. getBodyMass(impostor: PhysicsImpostor): number;
  112475. /**
  112476. * Gets friction of the impostor
  112477. * @param impostor impostor to get friction from
  112478. * @returns friction value
  112479. */
  112480. getBodyFriction(impostor: PhysicsImpostor): number;
  112481. /**
  112482. * Sets friction of the impostor
  112483. * @param impostor impostor to set friction on
  112484. * @param friction friction value
  112485. */
  112486. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112487. /**
  112488. * Gets restitution of the impostor
  112489. * @param impostor impostor to get restitution from
  112490. * @returns restitution value
  112491. */
  112492. getBodyRestitution(impostor: PhysicsImpostor): number;
  112493. /**
  112494. * Sets resitution of the impostor
  112495. * @param impostor impostor to set resitution on
  112496. * @param restitution resitution value
  112497. */
  112498. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112499. /**
  112500. * Gets pressure inside the impostor
  112501. * @param impostor impostor to get pressure from
  112502. * @returns pressure value
  112503. */
  112504. getBodyPressure(impostor: PhysicsImpostor): number;
  112505. /**
  112506. * Sets pressure inside a soft body impostor
  112507. * Cloth and rope must remain 0 pressure
  112508. * @param impostor impostor to set pressure on
  112509. * @param pressure pressure value
  112510. */
  112511. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112512. /**
  112513. * Gets stiffness of the impostor
  112514. * @param impostor impostor to get stiffness from
  112515. * @returns pressure value
  112516. */
  112517. getBodyStiffness(impostor: PhysicsImpostor): number;
  112518. /**
  112519. * Sets stiffness of the impostor
  112520. * @param impostor impostor to set stiffness on
  112521. * @param stiffness stiffness value from 0 to 1
  112522. */
  112523. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112524. /**
  112525. * Gets velocityIterations of the impostor
  112526. * @param impostor impostor to get velocity iterations from
  112527. * @returns velocityIterations value
  112528. */
  112529. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112530. /**
  112531. * Sets velocityIterations of the impostor
  112532. * @param impostor impostor to set velocity iterations on
  112533. * @param velocityIterations velocityIterations value
  112534. */
  112535. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112536. /**
  112537. * Gets positionIterations of the impostor
  112538. * @param impostor impostor to get position iterations from
  112539. * @returns positionIterations value
  112540. */
  112541. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112542. /**
  112543. * Sets positionIterations of the impostor
  112544. * @param impostor impostor to set position on
  112545. * @param positionIterations positionIterations value
  112546. */
  112547. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112548. /**
  112549. * Append an anchor to a cloth object
  112550. * @param impostor is the cloth impostor to add anchor to
  112551. * @param otherImpostor is the rigid impostor to anchor to
  112552. * @param width ratio across width from 0 to 1
  112553. * @param height ratio up height from 0 to 1
  112554. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112555. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112556. */
  112557. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112558. /**
  112559. * Append an hook to a rope object
  112560. * @param impostor is the rope impostor to add hook to
  112561. * @param otherImpostor is the rigid impostor to hook to
  112562. * @param length ratio along the rope from 0 to 1
  112563. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112564. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112565. */
  112566. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112567. /**
  112568. * Sleeps the physics body and stops it from being active
  112569. * @param impostor impostor to sleep
  112570. */
  112571. sleepBody(impostor: PhysicsImpostor): void;
  112572. /**
  112573. * Activates the physics body
  112574. * @param impostor impostor to activate
  112575. */
  112576. wakeUpBody(impostor: PhysicsImpostor): void;
  112577. /**
  112578. * Updates the distance parameters of the joint
  112579. * @param joint joint to update
  112580. * @param maxDistance maximum distance of the joint
  112581. * @param minDistance minimum distance of the joint
  112582. */
  112583. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112584. /**
  112585. * Sets a motor on the joint
  112586. * @param joint joint to set motor on
  112587. * @param speed speed of the motor
  112588. * @param maxForce maximum force of the motor
  112589. * @param motorIndex index of the motor
  112590. */
  112591. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112592. /**
  112593. * Sets the motors limit
  112594. * @param joint joint to set limit on
  112595. * @param upperLimit upper limit
  112596. * @param lowerLimit lower limit
  112597. */
  112598. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112599. /**
  112600. * Syncs the position and rotation of a mesh with the impostor
  112601. * @param mesh mesh to sync
  112602. * @param impostor impostor to update the mesh with
  112603. */
  112604. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112605. /**
  112606. * Gets the radius of the impostor
  112607. * @param impostor impostor to get radius from
  112608. * @returns the radius
  112609. */
  112610. getRadius(impostor: PhysicsImpostor): number;
  112611. /**
  112612. * Gets the box size of the impostor
  112613. * @param impostor impostor to get box size from
  112614. * @param result the resulting box size
  112615. */
  112616. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112617. /**
  112618. * Disposes of the impostor
  112619. */
  112620. dispose(): void;
  112621. /**
  112622. * Does a raycast in the physics world
  112623. * @param from when should the ray start?
  112624. * @param to when should the ray end?
  112625. * @returns PhysicsRaycastResult
  112626. */
  112627. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112628. }
  112629. }
  112630. declare module BABYLON {
  112631. interface AbstractScene {
  112632. /**
  112633. * The list of reflection probes added to the scene
  112634. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112635. */
  112636. reflectionProbes: Array<ReflectionProbe>;
  112637. /**
  112638. * Removes the given reflection probe from this scene.
  112639. * @param toRemove The reflection probe to remove
  112640. * @returns The index of the removed reflection probe
  112641. */
  112642. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112643. /**
  112644. * Adds the given reflection probe to this scene.
  112645. * @param newReflectionProbe The reflection probe to add
  112646. */
  112647. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112648. }
  112649. /**
  112650. * Class used to generate realtime reflection / refraction cube textures
  112651. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112652. */
  112653. export class ReflectionProbe {
  112654. /** defines the name of the probe */
  112655. name: string;
  112656. private _scene;
  112657. private _renderTargetTexture;
  112658. private _projectionMatrix;
  112659. private _viewMatrix;
  112660. private _target;
  112661. private _add;
  112662. private _attachedMesh;
  112663. private _invertYAxis;
  112664. /** Gets or sets probe position (center of the cube map) */
  112665. position: Vector3;
  112666. /**
  112667. * Creates a new reflection probe
  112668. * @param name defines the name of the probe
  112669. * @param size defines the texture resolution (for each face)
  112670. * @param scene defines the hosting scene
  112671. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112672. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112673. */
  112674. constructor(
  112675. /** defines the name of the probe */
  112676. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112677. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112678. samples: number;
  112679. /** Gets or sets the refresh rate to use (on every frame by default) */
  112680. refreshRate: number;
  112681. /**
  112682. * Gets the hosting scene
  112683. * @returns a Scene
  112684. */
  112685. getScene(): Scene;
  112686. /** Gets the internal CubeTexture used to render to */
  112687. readonly cubeTexture: RenderTargetTexture;
  112688. /** Gets the list of meshes to render */
  112689. readonly renderList: Nullable<AbstractMesh[]>;
  112690. /**
  112691. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112692. * @param mesh defines the mesh to attach to
  112693. */
  112694. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112695. /**
  112696. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112697. * @param renderingGroupId The rendering group id corresponding to its index
  112698. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112699. */
  112700. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112701. /**
  112702. * Clean all associated resources
  112703. */
  112704. dispose(): void;
  112705. /**
  112706. * Converts the reflection probe information to a readable string for debug purpose.
  112707. * @param fullDetails Supports for multiple levels of logging within scene loading
  112708. * @returns the human readable reflection probe info
  112709. */
  112710. toString(fullDetails?: boolean): string;
  112711. /**
  112712. * Get the class name of the relfection probe.
  112713. * @returns "ReflectionProbe"
  112714. */
  112715. getClassName(): string;
  112716. /**
  112717. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112718. * @returns The JSON representation of the texture
  112719. */
  112720. serialize(): any;
  112721. /**
  112722. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112723. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112724. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112725. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112726. * @returns The parsed reflection probe if successful
  112727. */
  112728. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112729. }
  112730. }
  112731. declare module BABYLON {
  112732. /** @hidden */
  112733. export var _BabylonLoaderRegistered: boolean;
  112734. }
  112735. declare module BABYLON {
  112736. /**
  112737. * The Physically based simple base material of BJS.
  112738. *
  112739. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112740. * It is used as the base class for both the specGloss and metalRough conventions.
  112741. */
  112742. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112743. /**
  112744. * Number of Simultaneous lights allowed on the material.
  112745. */
  112746. maxSimultaneousLights: number;
  112747. /**
  112748. * If sets to true, disables all the lights affecting the material.
  112749. */
  112750. disableLighting: boolean;
  112751. /**
  112752. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112753. */
  112754. environmentTexture: BaseTexture;
  112755. /**
  112756. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112757. */
  112758. invertNormalMapX: boolean;
  112759. /**
  112760. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112761. */
  112762. invertNormalMapY: boolean;
  112763. /**
  112764. * Normal map used in the model.
  112765. */
  112766. normalTexture: BaseTexture;
  112767. /**
  112768. * Emissivie color used to self-illuminate the model.
  112769. */
  112770. emissiveColor: Color3;
  112771. /**
  112772. * Emissivie texture used to self-illuminate the model.
  112773. */
  112774. emissiveTexture: BaseTexture;
  112775. /**
  112776. * Occlusion Channel Strenght.
  112777. */
  112778. occlusionStrength: number;
  112779. /**
  112780. * Occlusion Texture of the material (adding extra occlusion effects).
  112781. */
  112782. occlusionTexture: BaseTexture;
  112783. /**
  112784. * Defines the alpha limits in alpha test mode.
  112785. */
  112786. alphaCutOff: number;
  112787. /**
  112788. * Gets the current double sided mode.
  112789. */
  112790. /**
  112791. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112792. */
  112793. doubleSided: boolean;
  112794. /**
  112795. * Stores the pre-calculated light information of a mesh in a texture.
  112796. */
  112797. lightmapTexture: BaseTexture;
  112798. /**
  112799. * If true, the light map contains occlusion information instead of lighting info.
  112800. */
  112801. useLightmapAsShadowmap: boolean;
  112802. /**
  112803. * Instantiates a new PBRMaterial instance.
  112804. *
  112805. * @param name The material name
  112806. * @param scene The scene the material will be use in.
  112807. */
  112808. constructor(name: string, scene: Scene);
  112809. getClassName(): string;
  112810. }
  112811. }
  112812. declare module BABYLON {
  112813. /**
  112814. * The PBR material of BJS following the metal roughness convention.
  112815. *
  112816. * This fits to the PBR convention in the GLTF definition:
  112817. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112818. */
  112819. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112820. /**
  112821. * The base color has two different interpretations depending on the value of metalness.
  112822. * When the material is a metal, the base color is the specific measured reflectance value
  112823. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112824. * of the material.
  112825. */
  112826. baseColor: Color3;
  112827. /**
  112828. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112829. * well as opacity information in the alpha channel.
  112830. */
  112831. baseTexture: BaseTexture;
  112832. /**
  112833. * Specifies the metallic scalar value of the material.
  112834. * Can also be used to scale the metalness values of the metallic texture.
  112835. */
  112836. metallic: number;
  112837. /**
  112838. * Specifies the roughness scalar value of the material.
  112839. * Can also be used to scale the roughness values of the metallic texture.
  112840. */
  112841. roughness: number;
  112842. /**
  112843. * Texture containing both the metallic value in the B channel and the
  112844. * roughness value in the G channel to keep better precision.
  112845. */
  112846. metallicRoughnessTexture: BaseTexture;
  112847. /**
  112848. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112849. *
  112850. * @param name The material name
  112851. * @param scene The scene the material will be use in.
  112852. */
  112853. constructor(name: string, scene: Scene);
  112854. /**
  112855. * Return the currrent class name of the material.
  112856. */
  112857. getClassName(): string;
  112858. /**
  112859. * Makes a duplicate of the current material.
  112860. * @param name - name to use for the new material.
  112861. */
  112862. clone(name: string): PBRMetallicRoughnessMaterial;
  112863. /**
  112864. * Serialize the material to a parsable JSON object.
  112865. */
  112866. serialize(): any;
  112867. /**
  112868. * Parses a JSON object correponding to the serialize function.
  112869. */
  112870. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112871. }
  112872. }
  112873. declare module BABYLON {
  112874. /**
  112875. * The PBR material of BJS following the specular glossiness convention.
  112876. *
  112877. * This fits to the PBR convention in the GLTF definition:
  112878. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112879. */
  112880. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112881. /**
  112882. * Specifies the diffuse color of the material.
  112883. */
  112884. diffuseColor: Color3;
  112885. /**
  112886. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112887. * channel.
  112888. */
  112889. diffuseTexture: BaseTexture;
  112890. /**
  112891. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112892. */
  112893. specularColor: Color3;
  112894. /**
  112895. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112896. */
  112897. glossiness: number;
  112898. /**
  112899. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112900. */
  112901. specularGlossinessTexture: BaseTexture;
  112902. /**
  112903. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112904. *
  112905. * @param name The material name
  112906. * @param scene The scene the material will be use in.
  112907. */
  112908. constructor(name: string, scene: Scene);
  112909. /**
  112910. * Return the currrent class name of the material.
  112911. */
  112912. getClassName(): string;
  112913. /**
  112914. * Makes a duplicate of the current material.
  112915. * @param name - name to use for the new material.
  112916. */
  112917. clone(name: string): PBRSpecularGlossinessMaterial;
  112918. /**
  112919. * Serialize the material to a parsable JSON object.
  112920. */
  112921. serialize(): any;
  112922. /**
  112923. * Parses a JSON object correponding to the serialize function.
  112924. */
  112925. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112926. }
  112927. }
  112928. declare module BABYLON {
  112929. /**
  112930. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112931. * It can help converting any input color in a desired output one. This can then be used to create effects
  112932. * from sepia, black and white to sixties or futuristic rendering...
  112933. *
  112934. * The only supported format is currently 3dl.
  112935. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112936. */
  112937. export class ColorGradingTexture extends BaseTexture {
  112938. /**
  112939. * The current texture matrix. (will always be identity in color grading texture)
  112940. */
  112941. private _textureMatrix;
  112942. /**
  112943. * The texture URL.
  112944. */
  112945. url: string;
  112946. /**
  112947. * Empty line regex stored for GC.
  112948. */
  112949. private static _noneEmptyLineRegex;
  112950. private _engine;
  112951. /**
  112952. * Instantiates a ColorGradingTexture from the following parameters.
  112953. *
  112954. * @param url The location of the color gradind data (currently only supporting 3dl)
  112955. * @param scene The scene the texture will be used in
  112956. */
  112957. constructor(url: string, scene: Scene);
  112958. /**
  112959. * Returns the texture matrix used in most of the material.
  112960. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112961. */
  112962. getTextureMatrix(): Matrix;
  112963. /**
  112964. * Occurs when the file being loaded is a .3dl LUT file.
  112965. */
  112966. private load3dlTexture;
  112967. /**
  112968. * Starts the loading process of the texture.
  112969. */
  112970. private loadTexture;
  112971. /**
  112972. * Clones the color gradind texture.
  112973. */
  112974. clone(): ColorGradingTexture;
  112975. /**
  112976. * Called during delayed load for textures.
  112977. */
  112978. delayLoad(): void;
  112979. /**
  112980. * Parses a color grading texture serialized by Babylon.
  112981. * @param parsedTexture The texture information being parsedTexture
  112982. * @param scene The scene to load the texture in
  112983. * @param rootUrl The root url of the data assets to load
  112984. * @return A color gradind texture
  112985. */
  112986. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112987. /**
  112988. * Serializes the LUT texture to json format.
  112989. */
  112990. serialize(): any;
  112991. }
  112992. }
  112993. declare module BABYLON {
  112994. /**
  112995. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112996. */
  112997. export class EquiRectangularCubeTexture extends BaseTexture {
  112998. /** The six faces of the cube. */
  112999. private static _FacesMapping;
  113000. private _noMipmap;
  113001. private _onLoad;
  113002. private _onError;
  113003. /** The size of the cubemap. */
  113004. private _size;
  113005. /** The buffer of the image. */
  113006. private _buffer;
  113007. /** The width of the input image. */
  113008. private _width;
  113009. /** The height of the input image. */
  113010. private _height;
  113011. /** The URL to the image. */
  113012. url: string;
  113013. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  113014. coordinatesMode: number;
  113015. /**
  113016. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  113017. * @param url The location of the image
  113018. * @param scene The scene the texture will be used in
  113019. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113020. * @param noMipmap Forces to not generate the mipmap if true
  113021. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  113022. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  113023. * @param onLoad — defines a callback called when texture is loaded
  113024. * @param onError — defines a callback called if there is an error
  113025. */
  113026. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  113027. /**
  113028. * Load the image data, by putting the image on a canvas and extracting its buffer.
  113029. */
  113030. private loadImage;
  113031. /**
  113032. * Convert the image buffer into a cubemap and create a CubeTexture.
  113033. */
  113034. private loadTexture;
  113035. /**
  113036. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  113037. * @param buffer The ArrayBuffer that should be converted.
  113038. * @returns The buffer as Float32Array.
  113039. */
  113040. private getFloat32ArrayFromArrayBuffer;
  113041. /**
  113042. * Get the current class name of the texture useful for serialization or dynamic coding.
  113043. * @returns "EquiRectangularCubeTexture"
  113044. */
  113045. getClassName(): string;
  113046. /**
  113047. * Create a clone of the current EquiRectangularCubeTexture and return it.
  113048. * @returns A clone of the current EquiRectangularCubeTexture.
  113049. */
  113050. clone(): EquiRectangularCubeTexture;
  113051. }
  113052. }
  113053. declare module BABYLON {
  113054. /**
  113055. * Based on jsTGALoader - Javascript loader for TGA file
  113056. * By Vincent Thibault
  113057. * @see http://blog.robrowser.com/javascript-tga-loader.html
  113058. */
  113059. export class TGATools {
  113060. private static _TYPE_INDEXED;
  113061. private static _TYPE_RGB;
  113062. private static _TYPE_GREY;
  113063. private static _TYPE_RLE_INDEXED;
  113064. private static _TYPE_RLE_RGB;
  113065. private static _TYPE_RLE_GREY;
  113066. private static _ORIGIN_MASK;
  113067. private static _ORIGIN_SHIFT;
  113068. private static _ORIGIN_BL;
  113069. private static _ORIGIN_BR;
  113070. private static _ORIGIN_UL;
  113071. private static _ORIGIN_UR;
  113072. /**
  113073. * Gets the header of a TGA file
  113074. * @param data defines the TGA data
  113075. * @returns the header
  113076. */
  113077. static GetTGAHeader(data: Uint8Array): any;
  113078. /**
  113079. * Uploads TGA content to a Babylon Texture
  113080. * @hidden
  113081. */
  113082. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  113083. /** @hidden */
  113084. 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;
  113085. /** @hidden */
  113086. 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;
  113087. /** @hidden */
  113088. 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;
  113089. /** @hidden */
  113090. 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;
  113091. /** @hidden */
  113092. 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;
  113093. /** @hidden */
  113094. 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;
  113095. }
  113096. }
  113097. declare module BABYLON {
  113098. /**
  113099. * Implementation of the TGA Texture Loader.
  113100. * @hidden
  113101. */
  113102. export class _TGATextureLoader implements IInternalTextureLoader {
  113103. /**
  113104. * Defines wether the loader supports cascade loading the different faces.
  113105. */
  113106. readonly supportCascades: boolean;
  113107. /**
  113108. * This returns if the loader support the current file information.
  113109. * @param extension defines the file extension of the file being loaded
  113110. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113111. * @param fallback defines the fallback internal texture if any
  113112. * @param isBase64 defines whether the texture is encoded as a base64
  113113. * @param isBuffer defines whether the texture data are stored as a buffer
  113114. * @returns true if the loader can load the specified file
  113115. */
  113116. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113117. /**
  113118. * Transform the url before loading if required.
  113119. * @param rootUrl the url of the texture
  113120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113121. * @returns the transformed texture
  113122. */
  113123. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113124. /**
  113125. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113126. * @param rootUrl the url of the texture
  113127. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113128. * @returns the fallback texture
  113129. */
  113130. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113131. /**
  113132. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113133. * @param data contains the texture data
  113134. * @param texture defines the BabylonJS internal texture
  113135. * @param createPolynomials will be true if polynomials have been requested
  113136. * @param onLoad defines the callback to trigger once the texture is ready
  113137. * @param onError defines the callback to trigger in case of error
  113138. */
  113139. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113140. /**
  113141. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113142. * @param data contains the texture data
  113143. * @param texture defines the BabylonJS internal texture
  113144. * @param callback defines the method to call once ready to upload
  113145. */
  113146. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113147. }
  113148. }
  113149. declare module BABYLON {
  113150. /**
  113151. * Info about the .basis files
  113152. */
  113153. class BasisFileInfo {
  113154. /**
  113155. * If the file has alpha
  113156. */
  113157. hasAlpha: boolean;
  113158. /**
  113159. * Info about each image of the basis file
  113160. */
  113161. images: Array<{
  113162. levels: Array<{
  113163. width: number;
  113164. height: number;
  113165. transcodedPixels: ArrayBufferView;
  113166. }>;
  113167. }>;
  113168. }
  113169. /**
  113170. * Result of transcoding a basis file
  113171. */
  113172. class TranscodeResult {
  113173. /**
  113174. * Info about the .basis file
  113175. */
  113176. fileInfo: BasisFileInfo;
  113177. /**
  113178. * Format to use when loading the file
  113179. */
  113180. format: number;
  113181. }
  113182. /**
  113183. * Configuration options for the Basis transcoder
  113184. */
  113185. export class BasisTranscodeConfiguration {
  113186. /**
  113187. * Supported compression formats used to determine the supported output format of the transcoder
  113188. */
  113189. supportedCompressionFormats?: {
  113190. /**
  113191. * etc1 compression format
  113192. */
  113193. etc1?: boolean;
  113194. /**
  113195. * s3tc compression format
  113196. */
  113197. s3tc?: boolean;
  113198. /**
  113199. * pvrtc compression format
  113200. */
  113201. pvrtc?: boolean;
  113202. /**
  113203. * etc2 compression format
  113204. */
  113205. etc2?: boolean;
  113206. };
  113207. /**
  113208. * If mipmap levels should be loaded for transcoded images (Default: true)
  113209. */
  113210. loadMipmapLevels?: boolean;
  113211. /**
  113212. * Index of a single image to load (Default: all images)
  113213. */
  113214. loadSingleImage?: number;
  113215. }
  113216. /**
  113217. * Used to load .Basis files
  113218. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  113219. */
  113220. export class BasisTools {
  113221. private static _IgnoreSupportedFormats;
  113222. /**
  113223. * URL to use when loading the basis transcoder
  113224. */
  113225. static JSModuleURL: string;
  113226. /**
  113227. * URL to use when loading the wasm module for the transcoder
  113228. */
  113229. static WasmModuleURL: string;
  113230. /**
  113231. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  113232. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  113233. * @returns internal format corresponding to the Basis format
  113234. */
  113235. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  113236. private static _WorkerPromise;
  113237. private static _Worker;
  113238. private static _actionId;
  113239. private static _CreateWorkerAsync;
  113240. /**
  113241. * Transcodes a loaded image file to compressed pixel data
  113242. * @param imageData image data to transcode
  113243. * @param config configuration options for the transcoding
  113244. * @returns a promise resulting in the transcoded image
  113245. */
  113246. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113247. /**
  113248. * Loads a texture from the transcode result
  113249. * @param texture texture load to
  113250. * @param transcodeResult the result of transcoding the basis file to load from
  113251. */
  113252. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113253. }
  113254. }
  113255. declare module BABYLON {
  113256. /**
  113257. * Loader for .basis file format
  113258. */
  113259. export class _BasisTextureLoader implements IInternalTextureLoader {
  113260. /**
  113261. * Defines whether the loader supports cascade loading the different faces.
  113262. */
  113263. readonly supportCascades: boolean;
  113264. /**
  113265. * This returns if the loader support the current file information.
  113266. * @param extension defines the file extension of the file being loaded
  113267. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113268. * @param fallback defines the fallback internal texture if any
  113269. * @param isBase64 defines whether the texture is encoded as a base64
  113270. * @param isBuffer defines whether the texture data are stored as a buffer
  113271. * @returns true if the loader can load the specified file
  113272. */
  113273. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113274. /**
  113275. * Transform the url before loading if required.
  113276. * @param rootUrl the url of the texture
  113277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113278. * @returns the transformed texture
  113279. */
  113280. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113281. /**
  113282. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113283. * @param rootUrl the url of the texture
  113284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113285. * @returns the fallback texture
  113286. */
  113287. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113288. /**
  113289. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113290. * @param data contains the texture data
  113291. * @param texture defines the BabylonJS internal texture
  113292. * @param createPolynomials will be true if polynomials have been requested
  113293. * @param onLoad defines the callback to trigger once the texture is ready
  113294. * @param onError defines the callback to trigger in case of error
  113295. */
  113296. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113297. /**
  113298. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113299. * @param data contains the texture data
  113300. * @param texture defines the BabylonJS internal texture
  113301. * @param callback defines the method to call once ready to upload
  113302. */
  113303. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113304. }
  113305. }
  113306. declare module BABYLON {
  113307. /**
  113308. * 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.
  113309. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113310. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113311. */
  113312. export class CustomProceduralTexture extends ProceduralTexture {
  113313. private _animate;
  113314. private _time;
  113315. private _config;
  113316. private _texturePath;
  113317. /**
  113318. * Instantiates a new Custom Procedural Texture.
  113319. * 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.
  113320. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113321. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113322. * @param name Define the name of the texture
  113323. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  113324. * @param size Define the size of the texture to create
  113325. * @param scene Define the scene the texture belongs to
  113326. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  113327. * @param generateMipMaps Define if the texture should creates mip maps or not
  113328. */
  113329. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113330. private _loadJson;
  113331. /**
  113332. * Is the texture ready to be used ? (rendered at least once)
  113333. * @returns true if ready, otherwise, false.
  113334. */
  113335. isReady(): boolean;
  113336. /**
  113337. * Render the texture to its associated render target.
  113338. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113339. */
  113340. render(useCameraPostProcess?: boolean): void;
  113341. /**
  113342. * Update the list of dependant textures samplers in the shader.
  113343. */
  113344. updateTextures(): void;
  113345. /**
  113346. * Update the uniform values of the procedural texture in the shader.
  113347. */
  113348. updateShaderUniforms(): void;
  113349. /**
  113350. * Define if the texture animates or not.
  113351. */
  113352. animate: boolean;
  113353. }
  113354. }
  113355. declare module BABYLON {
  113356. /** @hidden */
  113357. export var noisePixelShader: {
  113358. name: string;
  113359. shader: string;
  113360. };
  113361. }
  113362. declare module BABYLON {
  113363. /**
  113364. * Class used to generate noise procedural textures
  113365. */
  113366. export class NoiseProceduralTexture extends ProceduralTexture {
  113367. private _time;
  113368. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113369. brightness: number;
  113370. /** Defines the number of octaves to process */
  113371. octaves: number;
  113372. /** Defines the level of persistence (0.8 by default) */
  113373. persistence: number;
  113374. /** Gets or sets animation speed factor (default is 1) */
  113375. animationSpeedFactor: number;
  113376. /**
  113377. * Creates a new NoiseProceduralTexture
  113378. * @param name defines the name fo the texture
  113379. * @param size defines the size of the texture (default is 256)
  113380. * @param scene defines the hosting scene
  113381. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113382. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113383. */
  113384. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113385. private _updateShaderUniforms;
  113386. protected _getDefines(): string;
  113387. /** Generate the current state of the procedural texture */
  113388. render(useCameraPostProcess?: boolean): void;
  113389. /**
  113390. * Serializes this noise procedural texture
  113391. * @returns a serialized noise procedural texture object
  113392. */
  113393. serialize(): any;
  113394. /**
  113395. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113396. * @param parsedTexture defines parsed texture data
  113397. * @param scene defines the current scene
  113398. * @param rootUrl defines the root URL containing noise procedural texture information
  113399. * @returns a parsed NoiseProceduralTexture
  113400. */
  113401. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113402. }
  113403. }
  113404. declare module BABYLON {
  113405. /**
  113406. * Raw cube texture where the raw buffers are passed in
  113407. */
  113408. export class RawCubeTexture extends CubeTexture {
  113409. /**
  113410. * Creates a cube texture where the raw buffers are passed in.
  113411. * @param scene defines the scene the texture is attached to
  113412. * @param data defines the array of data to use to create each face
  113413. * @param size defines the size of the textures
  113414. * @param format defines the format of the data
  113415. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113416. * @param generateMipMaps defines if the engine should generate the mip levels
  113417. * @param invertY defines if data must be stored with Y axis inverted
  113418. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113419. * @param compression defines the compression used (null by default)
  113420. */
  113421. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113422. /**
  113423. * Updates the raw cube texture.
  113424. * @param data defines the data to store
  113425. * @param format defines the data format
  113426. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113427. * @param invertY defines if data must be stored with Y axis inverted
  113428. * @param compression defines the compression used (null by default)
  113429. * @param level defines which level of the texture to update
  113430. */
  113431. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113432. /**
  113433. * Updates a raw cube texture with RGBD encoded data.
  113434. * @param data defines the array of data [mipmap][face] to use to create each face
  113435. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113436. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113437. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113438. * @returns a promsie that resolves when the operation is complete
  113439. */
  113440. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113441. /**
  113442. * Clones the raw cube texture.
  113443. * @return a new cube texture
  113444. */
  113445. clone(): CubeTexture;
  113446. /** @hidden */
  113447. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113448. }
  113449. }
  113450. declare module BABYLON {
  113451. /**
  113452. * Class used to store 3D textures containing user data
  113453. */
  113454. export class RawTexture3D extends Texture {
  113455. /** Gets or sets the texture format to use */
  113456. format: number;
  113457. private _engine;
  113458. /**
  113459. * Create a new RawTexture3D
  113460. * @param data defines the data of the texture
  113461. * @param width defines the width of the texture
  113462. * @param height defines the height of the texture
  113463. * @param depth defines the depth of the texture
  113464. * @param format defines the texture format to use
  113465. * @param scene defines the hosting scene
  113466. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113467. * @param invertY defines if texture must be stored with Y axis inverted
  113468. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113469. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113470. */
  113471. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113472. /** Gets or sets the texture format to use */
  113473. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113474. /**
  113475. * Update the texture with new data
  113476. * @param data defines the data to store in the texture
  113477. */
  113478. update(data: ArrayBufferView): void;
  113479. }
  113480. }
  113481. declare module BABYLON {
  113482. /**
  113483. * Creates a refraction texture used by refraction channel of the standard material.
  113484. * It is like a mirror but to see through a material.
  113485. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113486. */
  113487. export class RefractionTexture extends RenderTargetTexture {
  113488. /**
  113489. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113490. * 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.
  113491. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113492. */
  113493. refractionPlane: Plane;
  113494. /**
  113495. * Define how deep under the surface we should see.
  113496. */
  113497. depth: number;
  113498. /**
  113499. * Creates a refraction texture used by refraction channel of the standard material.
  113500. * It is like a mirror but to see through a material.
  113501. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113502. * @param name Define the texture name
  113503. * @param size Define the size of the underlying texture
  113504. * @param scene Define the scene the refraction belongs to
  113505. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113506. */
  113507. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113508. /**
  113509. * Clone the refraction texture.
  113510. * @returns the cloned texture
  113511. */
  113512. clone(): RefractionTexture;
  113513. /**
  113514. * Serialize the texture to a JSON representation you could use in Parse later on
  113515. * @returns the serialized JSON representation
  113516. */
  113517. serialize(): any;
  113518. }
  113519. }
  113520. declare module BABYLON {
  113521. /**
  113522. * Defines the options related to the creation of an HtmlElementTexture
  113523. */
  113524. export interface IHtmlElementTextureOptions {
  113525. /**
  113526. * Defines wether mip maps should be created or not.
  113527. */
  113528. generateMipMaps?: boolean;
  113529. /**
  113530. * Defines the sampling mode of the texture.
  113531. */
  113532. samplingMode?: number;
  113533. /**
  113534. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113535. */
  113536. engine: Nullable<Engine>;
  113537. /**
  113538. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113539. */
  113540. scene: Nullable<Scene>;
  113541. }
  113542. /**
  113543. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113544. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113545. * is automatically managed.
  113546. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113547. * in your application.
  113548. *
  113549. * As the update is not automatic, you need to call them manually.
  113550. */
  113551. export class HtmlElementTexture extends BaseTexture {
  113552. /**
  113553. * The texture URL.
  113554. */
  113555. element: HTMLVideoElement | HTMLCanvasElement;
  113556. private static readonly DefaultOptions;
  113557. private _textureMatrix;
  113558. private _engine;
  113559. private _isVideo;
  113560. private _generateMipMaps;
  113561. private _samplingMode;
  113562. /**
  113563. * Instantiates a HtmlElementTexture from the following parameters.
  113564. *
  113565. * @param name Defines the name of the texture
  113566. * @param element Defines the video or canvas the texture is filled with
  113567. * @param options Defines the other none mandatory texture creation options
  113568. */
  113569. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113570. private _createInternalTexture;
  113571. /**
  113572. * Returns the texture matrix used in most of the material.
  113573. */
  113574. getTextureMatrix(): Matrix;
  113575. /**
  113576. * Updates the content of the texture.
  113577. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113578. */
  113579. update(invertY?: Nullable<boolean>): void;
  113580. }
  113581. }
  113582. declare module BABYLON {
  113583. /**
  113584. * Enum used to define the target of a block
  113585. */
  113586. export enum NodeMaterialBlockTargets {
  113587. /** Vertex shader */
  113588. Vertex = 1,
  113589. /** Fragment shader */
  113590. Fragment = 2,
  113591. /** Vertex and Fragment */
  113592. VertexAndFragment = 3
  113593. }
  113594. }
  113595. declare module BABYLON {
  113596. /**
  113597. * Defines the kind of connection point for node based material
  113598. */
  113599. export enum NodeMaterialBlockConnectionPointTypes {
  113600. /** Float */
  113601. Float = 1,
  113602. /** Int */
  113603. Int = 2,
  113604. /** Vector2 */
  113605. Vector2 = 4,
  113606. /** Vector3 */
  113607. Vector3 = 8,
  113608. /** Vector4 */
  113609. Vector4 = 16,
  113610. /** Color3 */
  113611. Color3 = 32,
  113612. /** Color4 */
  113613. Color4 = 64,
  113614. /** Matrix */
  113615. Matrix = 128,
  113616. /** Texture */
  113617. Texture = 256,
  113618. /** Texture3D */
  113619. Texture3D = 512,
  113620. /** Vector3 or Color3 */
  113621. Vector3OrColor3 = 40,
  113622. /** Vector3 or Vector4 */
  113623. Vector3OrVector4 = 24,
  113624. /** Vector4 or Color4 */
  113625. Vector4OrColor4 = 80,
  113626. /** Color3 or Color4 */
  113627. Color3OrColor4 = 96,
  113628. /** Vector3 or Color3 */
  113629. Vector3OrColor3OrVector4OrColor4 = 120,
  113630. /** Detect type based on connection */
  113631. AutoDetect = 1024,
  113632. /** Output type that will be defined by input type */
  113633. BasedOnInput = 2048,
  113634. /** Light */
  113635. Light = 4096
  113636. }
  113637. }
  113638. declare module BABYLON {
  113639. /**
  113640. * Enum used to define well known values e.g. values automatically provided by the system
  113641. */
  113642. export enum NodeMaterialWellKnownValues {
  113643. /** World */
  113644. World = 1,
  113645. /** View */
  113646. View = 2,
  113647. /** Projection */
  113648. Projection = 3,
  113649. /** ViewProjection */
  113650. ViewProjection = 4,
  113651. /** WorldView */
  113652. WorldView = 5,
  113653. /** WorldViewProjection */
  113654. WorldViewProjection = 6,
  113655. /** CameraPosition */
  113656. CameraPosition = 7,
  113657. /** Will be filled by the block itself */
  113658. Automatic = 8
  113659. }
  113660. }
  113661. declare module BABYLON {
  113662. /**
  113663. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113664. */
  113665. export enum NodeMaterialBlockConnectionPointMode {
  113666. /** Value is an uniform */
  113667. Uniform = 0,
  113668. /** Value is a mesh attribute */
  113669. Attribute = 1,
  113670. /** Value is a varying between vertex and fragment shaders */
  113671. Varying = 2,
  113672. /** Mode is undefined */
  113673. Undefined = 3
  113674. }
  113675. }
  113676. declare module BABYLON {
  113677. /**
  113678. * Class used to store shared data between 2 NodeMaterialBuildState
  113679. */
  113680. export class NodeMaterialBuildStateSharedData {
  113681. /**
  113682. * Gets the list of emitted varyings
  113683. */
  113684. varyings: string[];
  113685. /**
  113686. * Gets the varying declaration string
  113687. */
  113688. varyingDeclaration: string;
  113689. /**
  113690. * Uniform connection points
  113691. */
  113692. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113693. /**
  113694. * Bindable blocks (Blocks that need to set data to the effect)
  113695. */
  113696. bindableBlocks: NodeMaterialBlock[];
  113697. /**
  113698. * List of blocks that can provide a compilation fallback
  113699. */
  113700. blocksWithFallbacks: NodeMaterialBlock[];
  113701. /**
  113702. * List of blocks that can provide a define update
  113703. */
  113704. blocksWithDefines: NodeMaterialBlock[];
  113705. /**
  113706. * List of blocks that can provide a repeatable content
  113707. */
  113708. repeatableContentBlocks: NodeMaterialBlock[];
  113709. /**
  113710. * List of blocks that can block the isReady function for the material
  113711. */
  113712. blockingBlocks: NodeMaterialBlock[];
  113713. /**
  113714. * Build Id used to avoid multiple recompilations
  113715. */
  113716. buildId: number;
  113717. /** List of emitted variables */
  113718. variableNames: {
  113719. [key: string]: number;
  113720. };
  113721. /** List of emitted defines */
  113722. defineNames: {
  113723. [key: string]: number;
  113724. };
  113725. /** Should emit comments? */
  113726. emitComments: boolean;
  113727. /** Emit build activity */
  113728. verbose: boolean;
  113729. /**
  113730. * Gets the compilation hints emitted at compilation time
  113731. */
  113732. hints: {
  113733. needWorldViewMatrix: boolean;
  113734. needWorldViewProjectionMatrix: boolean;
  113735. needAlphaBlending: boolean;
  113736. needAlphaTesting: boolean;
  113737. };
  113738. /**
  113739. * List of compilation checks
  113740. */
  113741. checks: {
  113742. emitVertex: boolean;
  113743. emitFragment: boolean;
  113744. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113745. };
  113746. /** Creates a new shared data */
  113747. constructor();
  113748. /**
  113749. * Emits console errors and exceptions if there is a failing check
  113750. */
  113751. emitErrors(): void;
  113752. }
  113753. }
  113754. declare module BABYLON {
  113755. /**
  113756. * Class used to store node based material build state
  113757. */
  113758. export class NodeMaterialBuildState {
  113759. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  113760. supportUniformBuffers: boolean;
  113761. /**
  113762. * Gets the list of emitted attributes
  113763. */
  113764. attributes: string[];
  113765. /**
  113766. * Gets the list of emitted uniforms
  113767. */
  113768. uniforms: string[];
  113769. /**
  113770. * Gets the list of emitted uniform buffers
  113771. */
  113772. uniformBuffers: string[];
  113773. /**
  113774. * Gets the list of emitted samplers
  113775. */
  113776. samplers: string[];
  113777. /**
  113778. * Gets the list of emitted functions
  113779. */
  113780. functions: {
  113781. [key: string]: string;
  113782. };
  113783. /**
  113784. * Gets the target of the compilation state
  113785. */
  113786. target: NodeMaterialBlockTargets;
  113787. /**
  113788. * Gets the list of emitted counters
  113789. */
  113790. counters: {
  113791. [key: string]: number;
  113792. };
  113793. /**
  113794. * Shared data between multiple NodeMaterialBuildState instances
  113795. */
  113796. sharedData: NodeMaterialBuildStateSharedData;
  113797. /** @hidden */
  113798. _vertexState: NodeMaterialBuildState;
  113799. private _attributeDeclaration;
  113800. private _uniformDeclaration;
  113801. private _samplerDeclaration;
  113802. private _varyingTransfer;
  113803. private _repeatableContentAnchorIndex;
  113804. /** @hidden */
  113805. _builtCompilationString: string;
  113806. /**
  113807. * Gets the emitted compilation strings
  113808. */
  113809. compilationString: string;
  113810. /**
  113811. * Finalize the compilation strings
  113812. * @param state defines the current compilation state
  113813. */
  113814. finalize(state: NodeMaterialBuildState): void;
  113815. /** @hidden */
  113816. readonly _repeatableContentAnchor: string;
  113817. /** @hidden */
  113818. _getFreeVariableName(prefix: string): string;
  113819. /** @hidden */
  113820. _getFreeDefineName(prefix: string): string;
  113821. /** @hidden */
  113822. _excludeVariableName(name: string): void;
  113823. /** @hidden */
  113824. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113825. /** @hidden */
  113826. _emitFunction(name: string, code: string, comments: string): void;
  113827. /** @hidden */
  113828. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113829. replaceStrings?: {
  113830. search: RegExp;
  113831. replace: string;
  113832. }[];
  113833. }): string;
  113834. /** @hidden */
  113835. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113836. repeatKey?: string;
  113837. removeAttributes?: boolean;
  113838. removeUniforms?: boolean;
  113839. removeVaryings?: boolean;
  113840. removeIfDef?: boolean;
  113841. replaceStrings?: {
  113842. search: RegExp;
  113843. replace: string;
  113844. }[];
  113845. }, storeKey?: string): void;
  113846. /** @hidden */
  113847. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  113848. private _emitDefine;
  113849. /** @hidden */
  113850. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113851. }
  113852. }
  113853. declare module BABYLON {
  113854. /**
  113855. * Root class for all node material optimizers
  113856. */
  113857. export class NodeMaterialOptimizer {
  113858. /**
  113859. * Function used to optimize a NodeMaterial graph
  113860. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113861. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113862. */
  113863. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113864. }
  113865. }
  113866. declare module BABYLON {
  113867. /**
  113868. * Block used to transform a vector4 with a matrix
  113869. */
  113870. export class Vector4TransformBlock extends NodeMaterialBlock {
  113871. /**
  113872. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113873. */
  113874. complementW: number;
  113875. /**
  113876. * Creates a new Vector4TransformBlock
  113877. * @param name defines the block name
  113878. */
  113879. constructor(name: string);
  113880. /**
  113881. * Gets the current class name
  113882. * @returns the class name
  113883. */
  113884. getClassName(): string;
  113885. /**
  113886. * Gets the vector input
  113887. */
  113888. readonly vector: NodeMaterialConnectionPoint;
  113889. /**
  113890. * Gets the output component
  113891. */
  113892. readonly output: NodeMaterialConnectionPoint;
  113893. /**
  113894. * Gets the matrix transform input
  113895. */
  113896. readonly transform: NodeMaterialConnectionPoint;
  113897. protected _buildBlock(state: NodeMaterialBuildState): this;
  113898. }
  113899. }
  113900. declare module BABYLON {
  113901. /**
  113902. * Block used to output the vertex position
  113903. */
  113904. export class VertexOutputBlock extends NodeMaterialBlock {
  113905. /**
  113906. * Creates a new VertexOutputBlock
  113907. * @param name defines the block name
  113908. */
  113909. constructor(name: string);
  113910. /**
  113911. * Gets the current class name
  113912. * @returns the class name
  113913. */
  113914. getClassName(): string;
  113915. /**
  113916. * Gets the vector input component
  113917. */
  113918. readonly vector: NodeMaterialConnectionPoint;
  113919. protected _buildBlock(state: NodeMaterialBuildState): this;
  113920. }
  113921. }
  113922. declare module BABYLON {
  113923. /**
  113924. * Block used to output the final color
  113925. */
  113926. export class FragmentOutputBlock extends NodeMaterialBlock {
  113927. /**
  113928. * Gets or sets a boolean indicating if this block will output an alpha value
  113929. */
  113930. alphaBlendingEnabled: boolean;
  113931. /**
  113932. * Create a new FragmentOutputBlock
  113933. * @param name defines the block name
  113934. */
  113935. constructor(name: string);
  113936. /**
  113937. * Gets the current class name
  113938. * @returns the class name
  113939. */
  113940. getClassName(): string;
  113941. /**
  113942. * Gets the color input component
  113943. */
  113944. readonly color: NodeMaterialConnectionPoint;
  113945. protected _buildBlock(state: NodeMaterialBuildState): this;
  113946. }
  113947. }
  113948. declare module BABYLON {
  113949. /**
  113950. * Interface used to configure the node material editor
  113951. */
  113952. export interface INodeMaterialEditorOptions {
  113953. /** Define the URl to load node editor script */
  113954. editorURL?: string;
  113955. }
  113956. /** @hidden */
  113957. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113958. /** BONES */
  113959. NUM_BONE_INFLUENCERS: number;
  113960. BonesPerMesh: number;
  113961. BONETEXTURE: boolean;
  113962. /** MORPH TARGETS */
  113963. MORPHTARGETS: boolean;
  113964. MORPHTARGETS_NORMAL: boolean;
  113965. MORPHTARGETS_TANGENT: boolean;
  113966. MORPHTARGETS_UV: boolean;
  113967. NUM_MORPH_INFLUENCERS: number;
  113968. /** IMAGE PROCESSING */
  113969. IMAGEPROCESSING: boolean;
  113970. VIGNETTE: boolean;
  113971. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113972. VIGNETTEBLENDMODEOPAQUE: boolean;
  113973. TONEMAPPING: boolean;
  113974. TONEMAPPING_ACES: boolean;
  113975. CONTRAST: boolean;
  113976. EXPOSURE: boolean;
  113977. COLORCURVES: boolean;
  113978. COLORGRADING: boolean;
  113979. COLORGRADING3D: boolean;
  113980. SAMPLER3DGREENDEPTH: boolean;
  113981. SAMPLER3DBGRMAP: boolean;
  113982. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113983. constructor();
  113984. setValue(name: string, value: boolean): void;
  113985. }
  113986. /**
  113987. * Class used to configure NodeMaterial
  113988. */
  113989. export interface INodeMaterialOptions {
  113990. /**
  113991. * Defines if blocks should emit comments
  113992. */
  113993. emitComments: boolean;
  113994. }
  113995. /**
  113996. * Class used to create a node based material built by assembling shader blocks
  113997. */
  113998. export class NodeMaterial extends PushMaterial {
  113999. private _options;
  114000. private _vertexCompilationState;
  114001. private _fragmentCompilationState;
  114002. private _sharedData;
  114003. private _buildId;
  114004. private _buildWasSuccessful;
  114005. private _cachedWorldViewMatrix;
  114006. private _cachedWorldViewProjectionMatrix;
  114007. private _textureConnectionPoints;
  114008. private _optimizers;
  114009. /** Define the URl to load node editor script */
  114010. static EditorURL: string;
  114011. private BJSNODEMATERIALEDITOR;
  114012. /** Get the inspector from bundle or global */
  114013. private _getGlobalNodeMaterialEditor;
  114014. /**
  114015. * Defines the maximum number of lights that can be used in the material
  114016. */
  114017. maxSimultaneousLights: number;
  114018. /**
  114019. * Observable raised when the material is built
  114020. */
  114021. onBuildObservable: Observable<NodeMaterial>;
  114022. /**
  114023. * Gets or sets the root nodes of the material vertex shader
  114024. */
  114025. _vertexOutputNodes: NodeMaterialBlock[];
  114026. /**
  114027. * Gets or sets the root nodes of the material fragment (pixel) shader
  114028. */
  114029. _fragmentOutputNodes: NodeMaterialBlock[];
  114030. /** Gets or sets options to control the node material overall behavior */
  114031. options: INodeMaterialOptions;
  114032. /**
  114033. * Default configuration related to image processing available in the standard Material.
  114034. */
  114035. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114036. /**
  114037. * Gets the image processing configuration used either in this material.
  114038. */
  114039. /**
  114040. * Sets the Default image processing configuration used either in the this material.
  114041. *
  114042. * If sets to null, the scene one is in use.
  114043. */
  114044. imageProcessingConfiguration: ImageProcessingConfiguration;
  114045. /**
  114046. * Create a new node based material
  114047. * @param name defines the material name
  114048. * @param scene defines the hosting scene
  114049. * @param options defines creation option
  114050. */
  114051. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  114052. /**
  114053. * Gets the current class name of the material e.g. "NodeMaterial"
  114054. * @returns the class name
  114055. */
  114056. getClassName(): string;
  114057. /**
  114058. * Keep track of the image processing observer to allow dispose and replace.
  114059. */
  114060. private _imageProcessingObserver;
  114061. /**
  114062. * Attaches a new image processing configuration to the Standard Material.
  114063. * @param configuration
  114064. */
  114065. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114066. /**
  114067. * Adds a new optimizer to the list of optimizers
  114068. * @param optimizer defines the optimizers to add
  114069. * @returns the current material
  114070. */
  114071. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114072. /**
  114073. * Remove an optimizer from the list of optimizers
  114074. * @param optimizer defines the optimizers to remove
  114075. * @returns the current material
  114076. */
  114077. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114078. /**
  114079. * Add a new block to the list of output nodes
  114080. * @param node defines the node to add
  114081. * @returns the current material
  114082. */
  114083. addOutputNode(node: NodeMaterialBlock): this;
  114084. /**
  114085. * Remove a block from the list of root nodes
  114086. * @param node defines the node to remove
  114087. * @returns the current material
  114088. */
  114089. removeOutputNode(node: NodeMaterialBlock): this;
  114090. private _addVertexOutputNode;
  114091. private _removeVertexOutputNode;
  114092. private _addFragmentOutputNode;
  114093. private _removeFragmentOutputNode;
  114094. /**
  114095. * Specifies if the material will require alpha blending
  114096. * @returns a boolean specifying if alpha blending is needed
  114097. */
  114098. needAlphaBlending(): boolean;
  114099. /**
  114100. * Specifies if this material should be rendered in alpha test mode
  114101. * @returns a boolean specifying if an alpha test is needed.
  114102. */
  114103. needAlphaTesting(): boolean;
  114104. private _initializeBlock;
  114105. private _resetDualBlocks;
  114106. /**
  114107. * Build the material and generates the inner effect
  114108. * @param verbose defines if the build should log activity
  114109. */
  114110. build(verbose?: boolean): void;
  114111. /**
  114112. * Runs an otpimization phase to try to improve the shader code
  114113. */
  114114. optimize(): void;
  114115. private _prepareDefinesForAttributes;
  114116. /**
  114117. * Get if the submesh is ready to be used and all its information available.
  114118. * Child classes can use it to update shaders
  114119. * @param mesh defines the mesh to check
  114120. * @param subMesh defines which submesh to check
  114121. * @param useInstances specifies that instances should be used
  114122. * @returns a boolean indicating that the submesh is ready or not
  114123. */
  114124. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114125. /**
  114126. * Binds the world matrix to the material
  114127. * @param world defines the world transformation matrix
  114128. */
  114129. bindOnlyWorldMatrix(world: Matrix): void;
  114130. /**
  114131. * Binds the submesh to this material by preparing the effect and shader to draw
  114132. * @param world defines the world transformation matrix
  114133. * @param mesh defines the mesh containing the submesh
  114134. * @param subMesh defines the submesh to bind the material to
  114135. */
  114136. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114137. /**
  114138. * Gets the active textures from the material
  114139. * @returns an array of textures
  114140. */
  114141. getActiveTextures(): BaseTexture[];
  114142. /**
  114143. * Specifies if the material uses a texture
  114144. * @param texture defines the texture to check against the material
  114145. * @returns a boolean specifying if the material uses the texture
  114146. */
  114147. hasTexture(texture: BaseTexture): boolean;
  114148. /**
  114149. * Disposes the material
  114150. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  114151. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  114152. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  114153. */
  114154. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  114155. /** Creates the node editor window. */
  114156. private _createNodeEditor;
  114157. /**
  114158. * Launch the node material editor
  114159. * @param config Define the configuration of the editor
  114160. * @return a promise fulfilled when the node editor is visible
  114161. */
  114162. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  114163. /**
  114164. * Clear the current material
  114165. */
  114166. clear(): void;
  114167. /**
  114168. * Clear the current material and set it to a default state
  114169. */
  114170. setToDefault(): void;
  114171. }
  114172. }
  114173. declare module BABYLON {
  114174. /**
  114175. * Defines a block that can be used inside a node based material
  114176. */
  114177. export class NodeMaterialBlock {
  114178. private _buildId;
  114179. private _target;
  114180. private _isFinalMerger;
  114181. /** @hidden */
  114182. _inputs: NodeMaterialConnectionPoint[];
  114183. /** @hidden */
  114184. _outputs: NodeMaterialConnectionPoint[];
  114185. /**
  114186. * Gets or sets the name of the block
  114187. */
  114188. name: string;
  114189. /**
  114190. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  114191. */
  114192. readonly isFinalMerger: boolean;
  114193. /**
  114194. * Gets or sets the build Id
  114195. */
  114196. buildId: number;
  114197. /**
  114198. * Gets or sets the target of the block
  114199. */
  114200. target: NodeMaterialBlockTargets;
  114201. /**
  114202. * Gets the list of input points
  114203. */
  114204. readonly inputs: NodeMaterialConnectionPoint[];
  114205. /** Gets the list of output points */
  114206. readonly outputs: NodeMaterialConnectionPoint[];
  114207. /**
  114208. * Find an input by its name
  114209. * @param name defines the name of the input to look for
  114210. * @returns the input or null if not found
  114211. */
  114212. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114213. /**
  114214. * Find an output by its name
  114215. * @param name defines the name of the outputto look for
  114216. * @returns the output or null if not found
  114217. */
  114218. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114219. /**
  114220. * Creates a new NodeMaterialBlock
  114221. * @param name defines the block name
  114222. * @param target defines the target of that block (Vertex by default)
  114223. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  114224. */
  114225. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  114226. /**
  114227. * Initialize the block and prepare the context for build
  114228. * @param state defines the state that will be used for the build
  114229. */
  114230. initialize(state: NodeMaterialBuildState): void;
  114231. /**
  114232. * Bind data to effect. Will only be called for blocks with isBindable === true
  114233. * @param effect defines the effect to bind data to
  114234. * @param nodeMaterial defines the hosting NodeMaterial
  114235. * @param mesh defines the mesh that will be rendered
  114236. */
  114237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114238. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  114239. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114240. protected _writeFloat(value: number): string;
  114241. /**
  114242. * Gets the current class name e.g. "NodeMaterialBlock"
  114243. * @returns the class name
  114244. */
  114245. getClassName(): string;
  114246. /**
  114247. * Register a new input. Must be called inside a block constructor
  114248. * @param name defines the connection point name
  114249. * @param type defines the connection point type
  114250. * @param isOptional defines a boolean indicating that this input can be omitted
  114251. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114252. * @returns the current block
  114253. */
  114254. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114255. /**
  114256. * Register a new output. Must be called inside a block constructor
  114257. * @param name defines the connection point name
  114258. * @param type defines the connection point type
  114259. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114260. * @returns the current block
  114261. */
  114262. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114263. /**
  114264. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114265. * @param forOutput defines an optional connection point to check compatibility with
  114266. * @returns the first available input or null
  114267. */
  114268. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114269. /**
  114270. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114271. * @param forBlock defines an optional block to check compatibility with
  114272. * @returns the first available input or null
  114273. */
  114274. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114275. /**
  114276. * Connect current block with another block
  114277. * @param other defines the block to connect with
  114278. * @param options define the various options to help pick the right connections
  114279. * @returns the current block
  114280. */
  114281. connectTo(other: NodeMaterialBlock, options?: {
  114282. input?: string;
  114283. output?: string;
  114284. outputSwizzle?: string;
  114285. }): this | undefined;
  114286. protected _buildBlock(state: NodeMaterialBuildState): void;
  114287. /**
  114288. * Add potential fallbacks if shader compilation fails
  114289. * @param mesh defines the mesh to be rendered
  114290. * @param fallbacks defines the current prioritized list of fallbacks
  114291. */
  114292. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114293. /**
  114294. * Update defines for shader compilation
  114295. * @param mesh defines the mesh to be rendered
  114296. * @param nodeMaterial defines the node material requesting the update
  114297. * @param defines defines the material defines to update
  114298. * @param useInstances specifies that instances should be used
  114299. */
  114300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114301. /**
  114302. * Lets the block try to connect some inputs automatically
  114303. */
  114304. autoConfigure(): void;
  114305. /**
  114306. * Function called when a block is declared as repeatable content generator
  114307. * @param vertexShaderState defines the current compilation state for the vertex shader
  114308. * @param fragmentShaderState defines the current compilation state for the fragment shader
  114309. * @param mesh defines the mesh to be rendered
  114310. * @param defines defines the material defines to update
  114311. */
  114312. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114313. /**
  114314. * Checks if the block is ready
  114315. * @param mesh defines the mesh to be rendered
  114316. * @param nodeMaterial defines the node material requesting the update
  114317. * @param defines defines the material defines to update
  114318. * @param useInstances specifies that instances should be used
  114319. * @returns true if the block is ready
  114320. */
  114321. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114322. /**
  114323. * Compile the current node and generate the shader code
  114324. * @param state defines the current compilation state (uniforms, samplers, current string)
  114325. * @returns the current block
  114326. */
  114327. build(state: NodeMaterialBuildState): this | undefined;
  114328. }
  114329. }
  114330. declare module BABYLON {
  114331. /**
  114332. * Defines a connection point for a block
  114333. */
  114334. export class NodeMaterialConnectionPoint {
  114335. /** @hidden */
  114336. _ownerBlock: NodeMaterialBlock;
  114337. /** @hidden */
  114338. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114339. private _associatedVariableName;
  114340. private _endpoints;
  114341. private _storedValue;
  114342. private _valueCallback;
  114343. private _mode;
  114344. /** @hidden */
  114345. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114346. /** @hidden */
  114347. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114348. /** @hidden */
  114349. _needToEmitVarying: boolean;
  114350. /** @hidden */
  114351. _forceUniformInVertexShaderOnly: boolean;
  114352. private _type;
  114353. /**
  114354. * Gets or sets the connection point type (default is float)
  114355. */
  114356. type: NodeMaterialBlockConnectionPointTypes;
  114357. /**
  114358. * Gets or sets the connection point name
  114359. */
  114360. name: string;
  114361. /**
  114362. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114363. */
  114364. swizzle: string;
  114365. /**
  114366. * Gets or sets a boolean indicating that this connection point can be omitted
  114367. */
  114368. isOptional: boolean;
  114369. /**
  114370. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114371. */
  114372. define: string;
  114373. /** Gets or sets the target of that connection point */
  114374. target: NodeMaterialBlockTargets;
  114375. /**
  114376. * Gets or sets the value of that point.
  114377. * Please note that this value will be ignored if valueCallback is defined
  114378. */
  114379. value: any;
  114380. /**
  114381. * Gets or sets a callback used to get the value of that point.
  114382. * Please note that setting this value will force the connection point to ignore the value property
  114383. */
  114384. valueCallback: () => any;
  114385. /**
  114386. * Gets or sets the associated variable name in the shader
  114387. */
  114388. associatedVariableName: string;
  114389. /**
  114390. * Gets a boolean indicating that this connection point not defined yet
  114391. */
  114392. readonly isUndefined: boolean;
  114393. /**
  114394. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114395. * In this case the connection point name must be the name of the uniform to use.
  114396. * Can only be set on inputs
  114397. */
  114398. isUniform: boolean;
  114399. /**
  114400. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114401. * In this case the connection point name must be the name of the attribute to use
  114402. * Can only be set on inputs
  114403. */
  114404. isAttribute: boolean;
  114405. /**
  114406. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114407. * Can only be set on exit points
  114408. */
  114409. isVarying: boolean;
  114410. /** Get the other side of the connection (if any) */
  114411. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114412. /** Get the block that owns this connection point */
  114413. readonly ownerBlock: NodeMaterialBlock;
  114414. /** Get the block connected on the other side of this connection (if any) */
  114415. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114416. /** Get the block connected on the endpoints of this connection (if any) */
  114417. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114418. /**
  114419. * Creates a new connection point
  114420. * @param name defines the connection point name
  114421. * @param ownerBlock defines the block hosting this connection point
  114422. */
  114423. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114424. /**
  114425. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114426. * @returns the class name
  114427. */
  114428. getClassName(): string;
  114429. /**
  114430. * Set the source of this connection point to a vertex attribute
  114431. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114432. * @returns the current connection point
  114433. */
  114434. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  114435. /**
  114436. * Set the source of this connection point to a well known value
  114437. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114438. * @returns the current connection point
  114439. */
  114440. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  114441. /**
  114442. * Gets a boolean indicating that the current connection point is a well known value
  114443. */
  114444. readonly isWellKnownValue: boolean;
  114445. /**
  114446. * Gets or sets the current well known value or null if not defined as well know value
  114447. */
  114448. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114449. private _getTypeLength;
  114450. /**
  114451. * Connect this point to another connection point
  114452. * @param connectionPoint defines the other connection point
  114453. * @returns the current connection point
  114454. */
  114455. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114456. /**
  114457. * Disconnect this point from one of his endpoint
  114458. * @param endpoint defines the other connection point
  114459. * @returns the current connection point
  114460. */
  114461. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114462. /**
  114463. * When connection point is an uniform, this function will send its value to the effect
  114464. * @param effect defines the effect to transmit value to
  114465. * @param world defines the world matrix
  114466. * @param worldView defines the worldxview matrix
  114467. * @param worldViewProjection defines the worldxviewxprojection matrix
  114468. */
  114469. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114470. /**
  114471. * When connection point is an uniform, this function will send its value to the effect
  114472. * @param effect defines the effect to transmit value to
  114473. * @param scene defines the hosting scene
  114474. */
  114475. transmit(effect: Effect, scene: Scene): void;
  114476. }
  114477. }
  114478. declare module BABYLON {
  114479. /**
  114480. * Block used to add support for vertex skinning (bones)
  114481. */
  114482. export class BonesBlock extends NodeMaterialBlock {
  114483. /**
  114484. * Creates a new BonesBlock
  114485. * @param name defines the block name
  114486. */
  114487. constructor(name: string);
  114488. /**
  114489. * Initialize the block and prepare the context for build
  114490. * @param state defines the state that will be used for the build
  114491. */
  114492. initialize(state: NodeMaterialBuildState): void;
  114493. /**
  114494. * Gets the current class name
  114495. * @returns the class name
  114496. */
  114497. getClassName(): string;
  114498. /**
  114499. * Gets the matrix indices input component
  114500. */
  114501. readonly matricesIndices: NodeMaterialConnectionPoint;
  114502. /**
  114503. * Gets the matrix weights input component
  114504. */
  114505. readonly matricesWeights: NodeMaterialConnectionPoint;
  114506. /**
  114507. * Gets the extra matrix indices input component
  114508. */
  114509. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114510. /**
  114511. * Gets the extra matrix weights input component
  114512. */
  114513. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114514. /**
  114515. * Gets the world input component
  114516. */
  114517. readonly world: NodeMaterialConnectionPoint;
  114518. /**
  114519. * Gets the output component
  114520. */
  114521. readonly output: NodeMaterialConnectionPoint;
  114522. autoConfigure(): void;
  114523. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114524. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114526. protected _buildBlock(state: NodeMaterialBuildState): this;
  114527. }
  114528. }
  114529. declare module BABYLON {
  114530. /**
  114531. * Block used to add support for instances
  114532. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114533. */
  114534. export class InstancesBlock extends NodeMaterialBlock {
  114535. /**
  114536. * Creates a new InstancesBlock
  114537. * @param name defines the block name
  114538. */
  114539. constructor(name: string);
  114540. /**
  114541. * Gets the current class name
  114542. * @returns the class name
  114543. */
  114544. getClassName(): string;
  114545. /**
  114546. * Gets the first world row input component
  114547. */
  114548. readonly world0: NodeMaterialConnectionPoint;
  114549. /**
  114550. * Gets the second world row input component
  114551. */
  114552. readonly world1: NodeMaterialConnectionPoint;
  114553. /**
  114554. * Gets the third world row input component
  114555. */
  114556. readonly world2: NodeMaterialConnectionPoint;
  114557. /**
  114558. * Gets the forth world row input component
  114559. */
  114560. readonly world3: NodeMaterialConnectionPoint;
  114561. /**
  114562. * Gets the world input component
  114563. */
  114564. readonly world: NodeMaterialConnectionPoint;
  114565. /**
  114566. * Gets the output component
  114567. */
  114568. readonly output: NodeMaterialConnectionPoint;
  114569. autoConfigure(): void;
  114570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114571. protected _buildBlock(state: NodeMaterialBuildState): this;
  114572. }
  114573. }
  114574. declare module BABYLON {
  114575. /**
  114576. * Block used to add morph targets support to vertex shader
  114577. */
  114578. export class MorphTargetsBlock extends NodeMaterialBlock {
  114579. private _repeatableContentAnchor;
  114580. private _repeatebleContentGenerated;
  114581. /**
  114582. * Create a new MorphTargetsBlock
  114583. * @param name defines the block name
  114584. */
  114585. constructor(name: string);
  114586. /**
  114587. * Gets the current class name
  114588. * @returns the class name
  114589. */
  114590. getClassName(): string;
  114591. /**
  114592. * Gets the position input component
  114593. */
  114594. readonly position: NodeMaterialConnectionPoint;
  114595. /**
  114596. * Gets the normal input component
  114597. */
  114598. readonly normal: NodeMaterialConnectionPoint;
  114599. /**
  114600. * Gets the tangent input component
  114601. */
  114602. readonly tangent: NodeMaterialConnectionPoint;
  114603. /**
  114604. * Gets the tangent input component
  114605. */
  114606. readonly uv: NodeMaterialConnectionPoint;
  114607. /**
  114608. * Gets the position output component
  114609. */
  114610. readonly positionOutput: NodeMaterialConnectionPoint;
  114611. /**
  114612. * Gets the normal output component
  114613. */
  114614. readonly normalOutput: NodeMaterialConnectionPoint;
  114615. /**
  114616. * Gets the tangent output component
  114617. */
  114618. readonly tangentOutput: NodeMaterialConnectionPoint;
  114619. /**
  114620. * Gets the tangent output component
  114621. */
  114622. readonly uvOutput: NodeMaterialConnectionPoint;
  114623. initialize(state: NodeMaterialBuildState): void;
  114624. autoConfigure(): void;
  114625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114627. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114628. protected _buildBlock(state: NodeMaterialBuildState): this;
  114629. }
  114630. }
  114631. declare module BABYLON {
  114632. /**
  114633. * Block used to add an alpha test in the fragment shader
  114634. */
  114635. export class AlphaTestBlock extends NodeMaterialBlock {
  114636. /**
  114637. * Gets or sets the alpha value where alpha testing happens
  114638. */
  114639. alphaCutOff: number;
  114640. /**
  114641. * Create a new AlphaTestBlock
  114642. * @param name defines the block name
  114643. */
  114644. constructor(name: string);
  114645. /**
  114646. * Gets the current class name
  114647. * @returns the class name
  114648. */
  114649. getClassName(): string;
  114650. /**
  114651. * Gets the color input component
  114652. */
  114653. readonly color: NodeMaterialConnectionPoint;
  114654. protected _buildBlock(state: NodeMaterialBuildState): this;
  114655. }
  114656. }
  114657. declare module BABYLON {
  114658. /**
  114659. * Block used to create a Color4 out of 4 inputs (one for each component)
  114660. */
  114661. export class RGBAMergerBlock extends NodeMaterialBlock {
  114662. /**
  114663. * Create a new RGBAMergerBlock
  114664. * @param name defines the block name
  114665. */
  114666. constructor(name: string);
  114667. /**
  114668. * Gets the current class name
  114669. * @returns the class name
  114670. */
  114671. getClassName(): string;
  114672. /**
  114673. * Gets the R input component
  114674. */
  114675. readonly r: NodeMaterialConnectionPoint;
  114676. /**
  114677. * Gets the G input component
  114678. */
  114679. readonly g: NodeMaterialConnectionPoint;
  114680. /**
  114681. * Gets the B input component
  114682. */
  114683. readonly b: NodeMaterialConnectionPoint;
  114684. /**
  114685. * Gets the RGB input component
  114686. */
  114687. readonly rgb: NodeMaterialConnectionPoint;
  114688. /**
  114689. * Gets the R input component
  114690. */
  114691. readonly a: NodeMaterialConnectionPoint;
  114692. /**
  114693. * Gets the output component
  114694. */
  114695. readonly output: NodeMaterialConnectionPoint;
  114696. protected _buildBlock(state: NodeMaterialBuildState): this;
  114697. }
  114698. }
  114699. declare module BABYLON {
  114700. /**
  114701. * Block used to create a Color3 out of 3 inputs (one for each component)
  114702. */
  114703. export class RGBMergerBlock extends NodeMaterialBlock {
  114704. /**
  114705. * Create a new RGBMergerBlock
  114706. * @param name defines the block name
  114707. */
  114708. constructor(name: string);
  114709. /**
  114710. * Gets the current class name
  114711. * @returns the class name
  114712. */
  114713. getClassName(): string;
  114714. /**
  114715. * Gets the R component input
  114716. */
  114717. readonly r: NodeMaterialConnectionPoint;
  114718. /**
  114719. * Gets the G component input
  114720. */
  114721. readonly g: NodeMaterialConnectionPoint;
  114722. /**
  114723. * Gets the B component input
  114724. */
  114725. readonly b: NodeMaterialConnectionPoint;
  114726. /**
  114727. * Gets the output component
  114728. */
  114729. readonly output: NodeMaterialConnectionPoint;
  114730. protected _buildBlock(state: NodeMaterialBuildState): this;
  114731. }
  114732. }
  114733. declare module BABYLON {
  114734. /**
  114735. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114736. */
  114737. export class RGBASplitterBlock extends NodeMaterialBlock {
  114738. /**
  114739. * Create a new RGBASplitterBlock
  114740. * @param name defines the block name
  114741. */
  114742. constructor(name: string);
  114743. /**
  114744. * Gets the current class name
  114745. * @returns the class name
  114746. */
  114747. getClassName(): string;
  114748. /**
  114749. * Gets the input component
  114750. */
  114751. readonly input: NodeMaterialConnectionPoint;
  114752. protected _buildBlock(state: NodeMaterialBuildState): this;
  114753. }
  114754. }
  114755. declare module BABYLON {
  114756. /**
  114757. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114758. */
  114759. export class RGBSplitterBlock extends NodeMaterialBlock {
  114760. /**
  114761. * Create a new RGBSplitterBlock
  114762. * @param name defines the block name
  114763. */
  114764. constructor(name: string);
  114765. /**
  114766. * Gets the current class name
  114767. * @returns the class name
  114768. */
  114769. getClassName(): string;
  114770. /**
  114771. * Gets the input component
  114772. */
  114773. readonly input: NodeMaterialConnectionPoint;
  114774. protected _buildBlock(state: NodeMaterialBuildState): this;
  114775. }
  114776. }
  114777. declare module BABYLON {
  114778. /**
  114779. * Block used to read a texture from a sampler
  114780. */
  114781. export class TextureBlock extends NodeMaterialBlock {
  114782. private _defineName;
  114783. /**
  114784. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114785. */
  114786. autoConnectTextureMatrix: boolean;
  114787. /**
  114788. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114789. */
  114790. autoSelectUV: boolean;
  114791. /**
  114792. * Create a new TextureBlock
  114793. * @param name defines the block name
  114794. */
  114795. constructor(name: string);
  114796. /**
  114797. * Gets the current class name
  114798. * @returns the class name
  114799. */
  114800. getClassName(): string;
  114801. /**
  114802. * Gets the uv input component
  114803. */
  114804. readonly uv: NodeMaterialConnectionPoint;
  114805. /**
  114806. * Gets the texture information input component
  114807. */
  114808. readonly textureInfo: NodeMaterialConnectionPoint;
  114809. /**
  114810. * Gets the transformed uv input component
  114811. */
  114812. readonly transformedUV: NodeMaterialConnectionPoint;
  114813. /**
  114814. * Gets the texture input component
  114815. */
  114816. readonly texture: NodeMaterialConnectionPoint;
  114817. /**
  114818. * Gets the texture transform input component
  114819. */
  114820. readonly textureTransform: NodeMaterialConnectionPoint;
  114821. /**
  114822. * Gets the output component
  114823. */
  114824. readonly output: NodeMaterialConnectionPoint;
  114825. autoConfigure(): void;
  114826. initialize(state: NodeMaterialBuildState): void;
  114827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114828. isReady(): boolean;
  114829. private _injectVertexCode;
  114830. protected _buildBlock(state: NodeMaterialBuildState): this;
  114831. }
  114832. }
  114833. declare module BABYLON {
  114834. /**
  114835. * Block used to add image processing support to fragment shader
  114836. */
  114837. export class ImageProcessingBlock extends NodeMaterialBlock {
  114838. /**
  114839. * Create a new ImageProcessingBlock
  114840. * @param name defines the block name
  114841. */
  114842. constructor(name: string);
  114843. /**
  114844. * Gets the current class name
  114845. * @returns the class name
  114846. */
  114847. getClassName(): string;
  114848. /**
  114849. * Gets the color input component
  114850. */
  114851. readonly color: NodeMaterialConnectionPoint;
  114852. /**
  114853. * Gets the output component
  114854. */
  114855. readonly output: NodeMaterialConnectionPoint;
  114856. /**
  114857. * Initialize the block and prepare the context for build
  114858. * @param state defines the state that will be used for the build
  114859. */
  114860. initialize(state: NodeMaterialBuildState): void;
  114861. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114862. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114863. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114864. protected _buildBlock(state: NodeMaterialBuildState): this;
  114865. }
  114866. }
  114867. declare module BABYLON {
  114868. /**
  114869. * Block used to add support for scene fog
  114870. */
  114871. export class FogBlock extends NodeMaterialBlock {
  114872. /**
  114873. * Create a new FogBlock
  114874. * @param name defines the block name
  114875. */
  114876. constructor(name: string);
  114877. /**
  114878. * Gets the current class name
  114879. * @returns the class name
  114880. */
  114881. getClassName(): string;
  114882. /**
  114883. * Gets the world position input component
  114884. */
  114885. readonly worldPosition: NodeMaterialConnectionPoint;
  114886. /**
  114887. * Gets the view input component
  114888. */
  114889. readonly view: NodeMaterialConnectionPoint;
  114890. /**
  114891. * Gets the color input component
  114892. */
  114893. readonly color: NodeMaterialConnectionPoint;
  114894. /**
  114895. * Gets the fog color input component
  114896. */
  114897. readonly fogColor: NodeMaterialConnectionPoint;
  114898. /**
  114899. * Gets the for parameter input component
  114900. */
  114901. readonly fogParameters: NodeMaterialConnectionPoint;
  114902. /**
  114903. * Gets the output component
  114904. */
  114905. readonly output: NodeMaterialConnectionPoint;
  114906. autoConfigure(): void;
  114907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114909. protected _buildBlock(state: NodeMaterialBuildState): this;
  114910. }
  114911. }
  114912. declare module BABYLON {
  114913. /**
  114914. * Block used to add light in the fragment shader
  114915. */
  114916. export class LightBlock extends NodeMaterialBlock {
  114917. private _lightId;
  114918. /**
  114919. * Create a new LightBlock
  114920. * @param name defines the block name
  114921. */
  114922. constructor(name: string);
  114923. /**
  114924. * Gets the current class name
  114925. * @returns the class name
  114926. */
  114927. getClassName(): string;
  114928. /**
  114929. * Gets the world position input component
  114930. */
  114931. readonly worldPosition: NodeMaterialConnectionPoint;
  114932. /**
  114933. * Gets the world normal input component
  114934. */
  114935. readonly worldNormal: NodeMaterialConnectionPoint;
  114936. /**
  114937. * Gets the light input component
  114938. */
  114939. readonly light: NodeMaterialConnectionPoint;
  114940. /**
  114941. * Gets the camera (or eye) position component
  114942. */
  114943. readonly cameraPosition: NodeMaterialConnectionPoint;
  114944. /**
  114945. * Gets the diffuse output component
  114946. */
  114947. readonly diffuseOutput: NodeMaterialConnectionPoint;
  114948. /**
  114949. * Gets the specular output component
  114950. */
  114951. readonly specularOutput: NodeMaterialConnectionPoint;
  114952. autoConfigure(): void;
  114953. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114955. private _injectVertexCode;
  114956. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  114957. }
  114958. }
  114959. declare module BABYLON {
  114960. /**
  114961. * Block used to multiply 2 vector4
  114962. */
  114963. export class MultiplyBlock extends NodeMaterialBlock {
  114964. /**
  114965. * Creates a new MultiplyBlock
  114966. * @param name defines the block name
  114967. */
  114968. constructor(name: string);
  114969. /**
  114970. * Gets the current class name
  114971. * @returns the class name
  114972. */
  114973. getClassName(): string;
  114974. /**
  114975. * Gets the left operand input component
  114976. */
  114977. readonly left: NodeMaterialConnectionPoint;
  114978. /**
  114979. * Gets the right operand input component
  114980. */
  114981. readonly right: NodeMaterialConnectionPoint;
  114982. /**
  114983. * Gets the output component
  114984. */
  114985. readonly output: NodeMaterialConnectionPoint;
  114986. protected _buildBlock(state: NodeMaterialBuildState): this;
  114987. }
  114988. }
  114989. declare module BABYLON {
  114990. /**
  114991. * Block used to add 2 vector4
  114992. */
  114993. export class AddBlock extends NodeMaterialBlock {
  114994. /**
  114995. * Creates a new AddBlock
  114996. * @param name defines the block name
  114997. */
  114998. constructor(name: string);
  114999. /**
  115000. * Gets the current class name
  115001. * @returns the class name
  115002. */
  115003. getClassName(): string;
  115004. /**
  115005. * Gets the left operand input component
  115006. */
  115007. readonly left: NodeMaterialConnectionPoint;
  115008. /**
  115009. * Gets the right operand input component
  115010. */
  115011. readonly right: NodeMaterialConnectionPoint;
  115012. /**
  115013. * Gets the output component
  115014. */
  115015. readonly output: NodeMaterialConnectionPoint;
  115016. protected _buildBlock(state: NodeMaterialBuildState): this;
  115017. }
  115018. }
  115019. declare module BABYLON {
  115020. /**
  115021. * Block used to clamp a float
  115022. */
  115023. export class ClampBlock extends NodeMaterialBlock {
  115024. /** Gets or sets the minimum range */
  115025. minimum: number;
  115026. /** Gets or sets the maximum range */
  115027. maximum: number;
  115028. /**
  115029. * Creates a new ClampBlock
  115030. * @param name defines the block name
  115031. */
  115032. constructor(name: string);
  115033. /**
  115034. * Gets the current class name
  115035. * @returns the class name
  115036. */
  115037. getClassName(): string;
  115038. /**
  115039. * Gets the value input component
  115040. */
  115041. readonly value: NodeMaterialConnectionPoint;
  115042. /**
  115043. * Gets the output component
  115044. */
  115045. readonly output: NodeMaterialConnectionPoint;
  115046. protected _buildBlock(state: NodeMaterialBuildState): this;
  115047. }
  115048. }
  115049. declare module BABYLON {
  115050. /**
  115051. * Block used to scale a value
  115052. */
  115053. export class ScaleBlock extends NodeMaterialBlock {
  115054. /**
  115055. * Creates a new ScaleBlock
  115056. * @param name defines the block name
  115057. */
  115058. constructor(name: string);
  115059. /**
  115060. * Gets the current class name
  115061. * @returns the class name
  115062. */
  115063. getClassName(): string;
  115064. /**
  115065. * Gets the value operand input component
  115066. */
  115067. readonly value: NodeMaterialConnectionPoint;
  115068. /**
  115069. * Gets the scale operand input component
  115070. */
  115071. readonly scale: NodeMaterialConnectionPoint;
  115072. /**
  115073. * Gets the output component
  115074. */
  115075. readonly output: NodeMaterialConnectionPoint;
  115076. protected _buildBlock(state: NodeMaterialBuildState): this;
  115077. }
  115078. }
  115079. declare module BABYLON {
  115080. /**
  115081. * Block used to transform a vector2 with a matrix
  115082. */
  115083. export class Vector2TransformBlock extends NodeMaterialBlock {
  115084. /**
  115085. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115086. */
  115087. complementZ: number;
  115088. /**
  115089. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115090. */
  115091. complementW: number;
  115092. /**
  115093. * Creates a new Vector2TransformBlock
  115094. * @param name defines the block name
  115095. */
  115096. constructor(name: string);
  115097. /**
  115098. * Gets the vector input
  115099. */
  115100. readonly vector: NodeMaterialConnectionPoint;
  115101. /**
  115102. * Gets the matrix transform input
  115103. */
  115104. readonly transform: NodeMaterialConnectionPoint;
  115105. /**
  115106. * Gets the output component
  115107. */
  115108. readonly output: NodeMaterialConnectionPoint;
  115109. /**
  115110. * Gets the current class name
  115111. * @returns the class name
  115112. */
  115113. getClassName(): string;
  115114. protected _buildBlock(state: NodeMaterialBuildState): this;
  115115. }
  115116. }
  115117. declare module BABYLON {
  115118. /**
  115119. * Block used to transform a vector3 with a matrix
  115120. */
  115121. export class Vector3TransformBlock extends NodeMaterialBlock {
  115122. /**
  115123. * Defines the value to use to complement Vector3 to transform it to a Vector4
  115124. */
  115125. complement: number;
  115126. /**
  115127. * Creates a new Vector3TransformBlock
  115128. * @param name defines the block name
  115129. */
  115130. constructor(name: string);
  115131. /**
  115132. * Gets the vector input
  115133. */
  115134. readonly vector: NodeMaterialConnectionPoint;
  115135. /**
  115136. * Gets the matrix transform input
  115137. */
  115138. readonly transform: NodeMaterialConnectionPoint;
  115139. /**
  115140. * Gets the output component
  115141. */
  115142. readonly output: NodeMaterialConnectionPoint;
  115143. /**
  115144. * Gets the current class name
  115145. * @returns the class name
  115146. */
  115147. getClassName(): string;
  115148. protected _buildBlock(state: NodeMaterialBuildState): this;
  115149. }
  115150. }
  115151. declare module BABYLON {
  115152. /**
  115153. * Block used to multiply two matrices
  115154. */
  115155. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  115156. /**
  115157. * Creates a new MatrixMultiplicationBlock
  115158. * @param name defines the block name
  115159. */
  115160. constructor(name: string);
  115161. /**
  115162. * Gets the left operand
  115163. */
  115164. readonly left: NodeMaterialConnectionPoint;
  115165. /**
  115166. * Gets the right operand
  115167. */
  115168. readonly right: NodeMaterialConnectionPoint;
  115169. /**
  115170. * Gets the output component
  115171. */
  115172. readonly output: NodeMaterialConnectionPoint;
  115173. /**
  115174. * Gets the current class name
  115175. * @returns the class name
  115176. */
  115177. getClassName(): string;
  115178. protected _buildBlock(state: NodeMaterialBuildState): this;
  115179. }
  115180. }
  115181. declare module BABYLON {
  115182. /**
  115183. * Helper class to push actions to a pool of workers.
  115184. */
  115185. export class WorkerPool implements IDisposable {
  115186. private _workerInfos;
  115187. private _pendingActions;
  115188. /**
  115189. * Constructor
  115190. * @param workers Array of workers to use for actions
  115191. */
  115192. constructor(workers: Array<Worker>);
  115193. /**
  115194. * Terminates all workers and clears any pending actions.
  115195. */
  115196. dispose(): void;
  115197. /**
  115198. * Pushes an action to the worker pool. If all the workers are active, the action will be
  115199. * pended until a worker has completed its action.
  115200. * @param action The action to perform. Call onComplete when the action is complete.
  115201. */
  115202. push(action: (worker: Worker, onComplete: () => void) => void): void;
  115203. private _execute;
  115204. }
  115205. }
  115206. declare module BABYLON {
  115207. /**
  115208. * Configuration for Draco compression
  115209. */
  115210. export interface IDracoCompressionConfiguration {
  115211. /**
  115212. * Configuration for the decoder.
  115213. */
  115214. decoder: {
  115215. /**
  115216. * The url to the WebAssembly module.
  115217. */
  115218. wasmUrl?: string;
  115219. /**
  115220. * The url to the WebAssembly binary.
  115221. */
  115222. wasmBinaryUrl?: string;
  115223. /**
  115224. * The url to the fallback JavaScript module.
  115225. */
  115226. fallbackUrl?: string;
  115227. };
  115228. }
  115229. /**
  115230. * Draco compression (https://google.github.io/draco/)
  115231. *
  115232. * This class wraps the Draco module.
  115233. *
  115234. * **Encoder**
  115235. *
  115236. * The encoder is not currently implemented.
  115237. *
  115238. * **Decoder**
  115239. *
  115240. * 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.
  115241. *
  115242. * To update the configuration, use the following code:
  115243. * ```javascript
  115244. * DracoCompression.Configuration = {
  115245. * decoder: {
  115246. * wasmUrl: "<url to the WebAssembly library>",
  115247. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  115248. * fallbackUrl: "<url to the fallback JavaScript library>",
  115249. * }
  115250. * };
  115251. * ```
  115252. *
  115253. * 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.
  115254. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  115255. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  115256. *
  115257. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  115258. * ```javascript
  115259. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  115260. * ```
  115261. *
  115262. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  115263. */
  115264. export class DracoCompression implements IDisposable {
  115265. private _workerPoolPromise?;
  115266. private _decoderModulePromise?;
  115267. /**
  115268. * The configuration. Defaults to the following urls:
  115269. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  115270. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  115271. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  115272. */
  115273. static Configuration: IDracoCompressionConfiguration;
  115274. /**
  115275. * Returns true if the decoder configuration is available.
  115276. */
  115277. static readonly DecoderAvailable: boolean;
  115278. /**
  115279. * Default number of workers to create when creating the draco compression object.
  115280. */
  115281. static DefaultNumWorkers: number;
  115282. private static GetDefaultNumWorkers;
  115283. private static _Default;
  115284. /**
  115285. * Default instance for the draco compression object.
  115286. */
  115287. static readonly Default: DracoCompression;
  115288. /**
  115289. * Constructor
  115290. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  115291. */
  115292. constructor(numWorkers?: number);
  115293. /**
  115294. * Stop all async operations and release resources.
  115295. */
  115296. dispose(): void;
  115297. /**
  115298. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115299. * @returns a promise that resolves when ready
  115300. */
  115301. whenReadyAsync(): Promise<void>;
  115302. /**
  115303. * Decode Draco compressed mesh data to vertex data.
  115304. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115305. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115306. * @returns A promise that resolves with the decoded vertex data
  115307. */
  115308. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115309. [kind: string]: number;
  115310. }): Promise<VertexData>;
  115311. }
  115312. }
  115313. declare module BABYLON {
  115314. /**
  115315. * Class for building Constructive Solid Geometry
  115316. */
  115317. export class CSG {
  115318. private polygons;
  115319. /**
  115320. * The world matrix
  115321. */
  115322. matrix: Matrix;
  115323. /**
  115324. * Stores the position
  115325. */
  115326. position: Vector3;
  115327. /**
  115328. * Stores the rotation
  115329. */
  115330. rotation: Vector3;
  115331. /**
  115332. * Stores the rotation quaternion
  115333. */
  115334. rotationQuaternion: Nullable<Quaternion>;
  115335. /**
  115336. * Stores the scaling vector
  115337. */
  115338. scaling: Vector3;
  115339. /**
  115340. * Convert the Mesh to CSG
  115341. * @param mesh The Mesh to convert to CSG
  115342. * @returns A new CSG from the Mesh
  115343. */
  115344. static FromMesh(mesh: Mesh): CSG;
  115345. /**
  115346. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115347. * @param polygons Polygons used to construct a CSG solid
  115348. */
  115349. private static FromPolygons;
  115350. /**
  115351. * Clones, or makes a deep copy, of the CSG
  115352. * @returns A new CSG
  115353. */
  115354. clone(): CSG;
  115355. /**
  115356. * Unions this CSG with another CSG
  115357. * @param csg The CSG to union against this CSG
  115358. * @returns The unioned CSG
  115359. */
  115360. union(csg: CSG): CSG;
  115361. /**
  115362. * Unions this CSG with another CSG in place
  115363. * @param csg The CSG to union against this CSG
  115364. */
  115365. unionInPlace(csg: CSG): void;
  115366. /**
  115367. * Subtracts this CSG with another CSG
  115368. * @param csg The CSG to subtract against this CSG
  115369. * @returns A new CSG
  115370. */
  115371. subtract(csg: CSG): CSG;
  115372. /**
  115373. * Subtracts this CSG with another CSG in place
  115374. * @param csg The CSG to subtact against this CSG
  115375. */
  115376. subtractInPlace(csg: CSG): void;
  115377. /**
  115378. * Intersect this CSG with another CSG
  115379. * @param csg The CSG to intersect against this CSG
  115380. * @returns A new CSG
  115381. */
  115382. intersect(csg: CSG): CSG;
  115383. /**
  115384. * Intersects this CSG with another CSG in place
  115385. * @param csg The CSG to intersect against this CSG
  115386. */
  115387. intersectInPlace(csg: CSG): void;
  115388. /**
  115389. * Return a new CSG solid with solid and empty space switched. This solid is
  115390. * not modified.
  115391. * @returns A new CSG solid with solid and empty space switched
  115392. */
  115393. inverse(): CSG;
  115394. /**
  115395. * Inverses the CSG in place
  115396. */
  115397. inverseInPlace(): void;
  115398. /**
  115399. * This is used to keep meshes transformations so they can be restored
  115400. * when we build back a Babylon Mesh
  115401. * NB : All CSG operations are performed in world coordinates
  115402. * @param csg The CSG to copy the transform attributes from
  115403. * @returns This CSG
  115404. */
  115405. copyTransformAttributes(csg: CSG): CSG;
  115406. /**
  115407. * Build Raw mesh from CSG
  115408. * Coordinates here are in world space
  115409. * @param name The name of the mesh geometry
  115410. * @param scene The Scene
  115411. * @param keepSubMeshes Specifies if the submeshes should be kept
  115412. * @returns A new Mesh
  115413. */
  115414. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115415. /**
  115416. * Build Mesh from CSG taking material and transforms into account
  115417. * @param name The name of the Mesh
  115418. * @param material The material of the Mesh
  115419. * @param scene The Scene
  115420. * @param keepSubMeshes Specifies if submeshes should be kept
  115421. * @returns The new Mesh
  115422. */
  115423. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115424. }
  115425. }
  115426. declare module BABYLON {
  115427. /**
  115428. * Class used to create a trail following a mesh
  115429. */
  115430. export class TrailMesh extends Mesh {
  115431. private _generator;
  115432. private _autoStart;
  115433. private _running;
  115434. private _diameter;
  115435. private _length;
  115436. private _sectionPolygonPointsCount;
  115437. private _sectionVectors;
  115438. private _sectionNormalVectors;
  115439. private _beforeRenderObserver;
  115440. /**
  115441. * @constructor
  115442. * @param name The value used by scene.getMeshByName() to do a lookup.
  115443. * @param generator The mesh to generate a trail.
  115444. * @param scene The scene to add this mesh to.
  115445. * @param diameter Diameter of trailing mesh. Default is 1.
  115446. * @param length Length of trailing mesh. Default is 60.
  115447. * @param autoStart Automatically start trailing mesh. Default true.
  115448. */
  115449. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115450. /**
  115451. * "TrailMesh"
  115452. * @returns "TrailMesh"
  115453. */
  115454. getClassName(): string;
  115455. private _createMesh;
  115456. /**
  115457. * Start trailing mesh.
  115458. */
  115459. start(): void;
  115460. /**
  115461. * Stop trailing mesh.
  115462. */
  115463. stop(): void;
  115464. /**
  115465. * Update trailing mesh geometry.
  115466. */
  115467. update(): void;
  115468. /**
  115469. * Returns a new TrailMesh object.
  115470. * @param name is a string, the name given to the new mesh
  115471. * @param newGenerator use new generator object for cloned trail mesh
  115472. * @returns a new mesh
  115473. */
  115474. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115475. /**
  115476. * Serializes this trail mesh
  115477. * @param serializationObject object to write serialization to
  115478. */
  115479. serialize(serializationObject: any): void;
  115480. /**
  115481. * Parses a serialized trail mesh
  115482. * @param parsedMesh the serialized mesh
  115483. * @param scene the scene to create the trail mesh in
  115484. * @returns the created trail mesh
  115485. */
  115486. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115487. }
  115488. }
  115489. declare module BABYLON {
  115490. /**
  115491. * Class containing static functions to help procedurally build meshes
  115492. */
  115493. export class TiledBoxBuilder {
  115494. /**
  115495. * Creates a box mesh
  115496. * 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)
  115497. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115501. * @param name defines the name of the mesh
  115502. * @param options defines the options used to create the mesh
  115503. * @param scene defines the hosting scene
  115504. * @returns the box mesh
  115505. */
  115506. static CreateTiledBox(name: string, options: {
  115507. pattern?: number;
  115508. width?: number;
  115509. height?: number;
  115510. depth?: number;
  115511. tileSize?: number;
  115512. tileWidth?: number;
  115513. tileHeight?: number;
  115514. alignHorizontal?: number;
  115515. alignVertical?: number;
  115516. faceUV?: Vector4[];
  115517. faceColors?: Color4[];
  115518. sideOrientation?: number;
  115519. updatable?: boolean;
  115520. }, scene?: Nullable<Scene>): Mesh;
  115521. }
  115522. }
  115523. declare module BABYLON {
  115524. /**
  115525. * Class containing static functions to help procedurally build meshes
  115526. */
  115527. export class TorusKnotBuilder {
  115528. /**
  115529. * Creates a torus knot mesh
  115530. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115531. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115532. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115533. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115537. * @param name defines the name of the mesh
  115538. * @param options defines the options used to create the mesh
  115539. * @param scene defines the hosting scene
  115540. * @returns the torus knot mesh
  115541. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115542. */
  115543. static CreateTorusKnot(name: string, options: {
  115544. radius?: number;
  115545. tube?: number;
  115546. radialSegments?: number;
  115547. tubularSegments?: number;
  115548. p?: number;
  115549. q?: number;
  115550. updatable?: boolean;
  115551. sideOrientation?: number;
  115552. frontUVs?: Vector4;
  115553. backUVs?: Vector4;
  115554. }, scene: any): Mesh;
  115555. }
  115556. }
  115557. declare module BABYLON {
  115558. /**
  115559. * Polygon
  115560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115561. */
  115562. export class Polygon {
  115563. /**
  115564. * Creates a rectangle
  115565. * @param xmin bottom X coord
  115566. * @param ymin bottom Y coord
  115567. * @param xmax top X coord
  115568. * @param ymax top Y coord
  115569. * @returns points that make the resulting rectation
  115570. */
  115571. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115572. /**
  115573. * Creates a circle
  115574. * @param radius radius of circle
  115575. * @param cx scale in x
  115576. * @param cy scale in y
  115577. * @param numberOfSides number of sides that make up the circle
  115578. * @returns points that make the resulting circle
  115579. */
  115580. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115581. /**
  115582. * Creates a polygon from input string
  115583. * @param input Input polygon data
  115584. * @returns the parsed points
  115585. */
  115586. static Parse(input: string): Vector2[];
  115587. /**
  115588. * Starts building a polygon from x and y coordinates
  115589. * @param x x coordinate
  115590. * @param y y coordinate
  115591. * @returns the started path2
  115592. */
  115593. static StartingAt(x: number, y: number): Path2;
  115594. }
  115595. /**
  115596. * Builds a polygon
  115597. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115598. */
  115599. export class PolygonMeshBuilder {
  115600. private _points;
  115601. private _outlinepoints;
  115602. private _holes;
  115603. private _name;
  115604. private _scene;
  115605. private _epoints;
  115606. private _eholes;
  115607. private _addToepoint;
  115608. /**
  115609. * Babylon reference to the earcut plugin.
  115610. */
  115611. bjsEarcut: any;
  115612. /**
  115613. * Creates a PolygonMeshBuilder
  115614. * @param name name of the builder
  115615. * @param contours Path of the polygon
  115616. * @param scene scene to add to when creating the mesh
  115617. * @param earcutInjection can be used to inject your own earcut reference
  115618. */
  115619. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115620. /**
  115621. * Adds a whole within the polygon
  115622. * @param hole Array of points defining the hole
  115623. * @returns this
  115624. */
  115625. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115626. /**
  115627. * Creates the polygon
  115628. * @param updatable If the mesh should be updatable
  115629. * @param depth The depth of the mesh created
  115630. * @returns the created mesh
  115631. */
  115632. build(updatable?: boolean, depth?: number): Mesh;
  115633. /**
  115634. * Creates the polygon
  115635. * @param depth The depth of the mesh created
  115636. * @returns the created VertexData
  115637. */
  115638. buildVertexData(depth?: number): VertexData;
  115639. /**
  115640. * Adds a side to the polygon
  115641. * @param positions points that make the polygon
  115642. * @param normals normals of the polygon
  115643. * @param uvs uvs of the polygon
  115644. * @param indices indices of the polygon
  115645. * @param bounds bounds of the polygon
  115646. * @param points points of the polygon
  115647. * @param depth depth of the polygon
  115648. * @param flip flip of the polygon
  115649. */
  115650. private addSide;
  115651. }
  115652. }
  115653. declare module BABYLON {
  115654. /**
  115655. * Class containing static functions to help procedurally build meshes
  115656. */
  115657. export class PolygonBuilder {
  115658. /**
  115659. * Creates a polygon mesh
  115660. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115661. * * 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
  115662. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115665. * * Remember you can only change the shape positions, not their number when updating a polygon
  115666. * @param name defines the name of the mesh
  115667. * @param options defines the options used to create the mesh
  115668. * @param scene defines the hosting scene
  115669. * @param earcutInjection can be used to inject your own earcut reference
  115670. * @returns the polygon mesh
  115671. */
  115672. static CreatePolygon(name: string, options: {
  115673. shape: Vector3[];
  115674. holes?: Vector3[][];
  115675. depth?: number;
  115676. faceUV?: Vector4[];
  115677. faceColors?: Color4[];
  115678. updatable?: boolean;
  115679. sideOrientation?: number;
  115680. frontUVs?: Vector4;
  115681. backUVs?: Vector4;
  115682. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115683. /**
  115684. * Creates an extruded polygon mesh, with depth in the Y direction.
  115685. * * 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)
  115686. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115687. * @param name defines the name of the mesh
  115688. * @param options defines the options used to create the mesh
  115689. * @param scene defines the hosting scene
  115690. * @param earcutInjection can be used to inject your own earcut reference
  115691. * @returns the polygon mesh
  115692. */
  115693. static ExtrudePolygon(name: string, options: {
  115694. shape: Vector3[];
  115695. holes?: Vector3[][];
  115696. depth?: number;
  115697. faceUV?: Vector4[];
  115698. faceColors?: Color4[];
  115699. updatable?: boolean;
  115700. sideOrientation?: number;
  115701. frontUVs?: Vector4;
  115702. backUVs?: Vector4;
  115703. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115704. }
  115705. }
  115706. declare module BABYLON {
  115707. /**
  115708. * Class containing static functions to help procedurally build meshes
  115709. */
  115710. export class LatheBuilder {
  115711. /**
  115712. * Creates lathe mesh.
  115713. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115714. * * 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
  115715. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115716. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115717. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115718. * * 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
  115719. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115720. * * 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
  115721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115725. * @param name defines the name of the mesh
  115726. * @param options defines the options used to create the mesh
  115727. * @param scene defines the hosting scene
  115728. * @returns the lathe mesh
  115729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115730. */
  115731. static CreateLathe(name: string, options: {
  115732. shape: Vector3[];
  115733. radius?: number;
  115734. tessellation?: number;
  115735. clip?: number;
  115736. arc?: number;
  115737. closed?: boolean;
  115738. updatable?: boolean;
  115739. sideOrientation?: number;
  115740. frontUVs?: Vector4;
  115741. backUVs?: Vector4;
  115742. cap?: number;
  115743. invertUV?: boolean;
  115744. }, scene?: Nullable<Scene>): Mesh;
  115745. }
  115746. }
  115747. declare module BABYLON {
  115748. /**
  115749. * Class containing static functions to help procedurally build meshes
  115750. */
  115751. export class TiledPlaneBuilder {
  115752. /**
  115753. * Creates a tiled plane mesh
  115754. * * The parameter `pattern` will, depending on value, do nothing or
  115755. * * * flip (reflect about central vertical) alternate tiles across and up
  115756. * * * flip every tile on alternate rows
  115757. * * * rotate (180 degs) alternate tiles across and up
  115758. * * * rotate every tile on alternate rows
  115759. * * * flip and rotate alternate tiles across and up
  115760. * * * flip and rotate every tile on alternate rows
  115761. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115762. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115765. * * 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)
  115766. * * 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)
  115767. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115768. * @param name defines the name of the mesh
  115769. * @param options defines the options used to create the mesh
  115770. * @param scene defines the hosting scene
  115771. * @returns the box mesh
  115772. */
  115773. static CreateTiledPlane(name: string, options: {
  115774. pattern?: number;
  115775. tileSize?: number;
  115776. tileWidth?: number;
  115777. tileHeight?: number;
  115778. size?: number;
  115779. width?: number;
  115780. height?: number;
  115781. alignHorizontal?: number;
  115782. alignVertical?: number;
  115783. sideOrientation?: number;
  115784. frontUVs?: Vector4;
  115785. backUVs?: Vector4;
  115786. updatable?: boolean;
  115787. }, scene?: Nullable<Scene>): Mesh;
  115788. }
  115789. }
  115790. declare module BABYLON {
  115791. /**
  115792. * Class containing static functions to help procedurally build meshes
  115793. */
  115794. export class TubeBuilder {
  115795. /**
  115796. * Creates a tube mesh.
  115797. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115798. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115799. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115800. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115801. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115802. * * 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)
  115803. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115804. * * 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
  115805. * * 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
  115806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115810. * @param name defines the name of the mesh
  115811. * @param options defines the options used to create the mesh
  115812. * @param scene defines the hosting scene
  115813. * @returns the tube mesh
  115814. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115815. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115816. */
  115817. static CreateTube(name: string, options: {
  115818. path: Vector3[];
  115819. radius?: number;
  115820. tessellation?: number;
  115821. radiusFunction?: {
  115822. (i: number, distance: number): number;
  115823. };
  115824. cap?: number;
  115825. arc?: number;
  115826. updatable?: boolean;
  115827. sideOrientation?: number;
  115828. frontUVs?: Vector4;
  115829. backUVs?: Vector4;
  115830. instance?: Mesh;
  115831. invertUV?: boolean;
  115832. }, scene?: Nullable<Scene>): Mesh;
  115833. }
  115834. }
  115835. declare module BABYLON {
  115836. /**
  115837. * Class containing static functions to help procedurally build meshes
  115838. */
  115839. export class IcoSphereBuilder {
  115840. /**
  115841. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115842. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115843. * * 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`)
  115844. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115845. * * 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
  115846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115849. * @param name defines the name of the mesh
  115850. * @param options defines the options used to create the mesh
  115851. * @param scene defines the hosting scene
  115852. * @returns the icosahedron mesh
  115853. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115854. */
  115855. static CreateIcoSphere(name: string, options: {
  115856. radius?: number;
  115857. radiusX?: number;
  115858. radiusY?: number;
  115859. radiusZ?: number;
  115860. flat?: boolean;
  115861. subdivisions?: number;
  115862. sideOrientation?: number;
  115863. frontUVs?: Vector4;
  115864. backUVs?: Vector4;
  115865. updatable?: boolean;
  115866. }, scene?: Nullable<Scene>): Mesh;
  115867. }
  115868. }
  115869. declare module BABYLON {
  115870. /**
  115871. * Class containing static functions to help procedurally build meshes
  115872. */
  115873. export class DecalBuilder {
  115874. /**
  115875. * Creates a decal mesh.
  115876. * 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
  115877. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115878. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115879. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115880. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115881. * @param name defines the name of the mesh
  115882. * @param sourceMesh defines the mesh where the decal must be applied
  115883. * @param options defines the options used to create the mesh
  115884. * @param scene defines the hosting scene
  115885. * @returns the decal mesh
  115886. * @see https://doc.babylonjs.com/how_to/decals
  115887. */
  115888. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115889. position?: Vector3;
  115890. normal?: Vector3;
  115891. size?: Vector3;
  115892. angle?: number;
  115893. }): Mesh;
  115894. }
  115895. }
  115896. declare module BABYLON {
  115897. /**
  115898. * Class containing static functions to help procedurally build meshes
  115899. */
  115900. export class MeshBuilder {
  115901. /**
  115902. * Creates a box mesh
  115903. * * The parameter `size` sets the size (float) of each box side (default 1)
  115904. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115905. * * 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)
  115906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115910. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115911. * @param name defines the name of the mesh
  115912. * @param options defines the options used to create the mesh
  115913. * @param scene defines the hosting scene
  115914. * @returns the box mesh
  115915. */
  115916. static CreateBox(name: string, options: {
  115917. size?: number;
  115918. width?: number;
  115919. height?: number;
  115920. depth?: number;
  115921. faceUV?: Vector4[];
  115922. faceColors?: Color4[];
  115923. sideOrientation?: number;
  115924. frontUVs?: Vector4;
  115925. backUVs?: Vector4;
  115926. updatable?: boolean;
  115927. }, scene?: Nullable<Scene>): Mesh;
  115928. /**
  115929. * Creates a tiled box mesh
  115930. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115932. * @param name defines the name of the mesh
  115933. * @param options defines the options used to create the mesh
  115934. * @param scene defines the hosting scene
  115935. * @returns the tiled box mesh
  115936. */
  115937. static CreateTiledBox(name: string, options: {
  115938. pattern?: number;
  115939. size?: number;
  115940. width?: number;
  115941. height?: number;
  115942. depth: number;
  115943. tileSize?: number;
  115944. tileWidth?: number;
  115945. tileHeight?: number;
  115946. faceUV?: Vector4[];
  115947. faceColors?: Color4[];
  115948. alignHorizontal?: number;
  115949. alignVertical?: number;
  115950. sideOrientation?: number;
  115951. updatable?: boolean;
  115952. }, scene?: Nullable<Scene>): Mesh;
  115953. /**
  115954. * Creates a sphere mesh
  115955. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115956. * * 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`)
  115957. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115958. * * 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
  115959. * * 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)
  115960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115963. * @param name defines the name of the mesh
  115964. * @param options defines the options used to create the mesh
  115965. * @param scene defines the hosting scene
  115966. * @returns the sphere mesh
  115967. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115968. */
  115969. static CreateSphere(name: string, options: {
  115970. segments?: number;
  115971. diameter?: number;
  115972. diameterX?: number;
  115973. diameterY?: number;
  115974. diameterZ?: number;
  115975. arc?: number;
  115976. slice?: number;
  115977. sideOrientation?: number;
  115978. frontUVs?: Vector4;
  115979. backUVs?: Vector4;
  115980. updatable?: boolean;
  115981. }, scene?: Nullable<Scene>): Mesh;
  115982. /**
  115983. * Creates a plane polygonal mesh. By default, this is a disc
  115984. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115985. * * 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
  115986. * * 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
  115987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115990. * @param name defines the name of the mesh
  115991. * @param options defines the options used to create the mesh
  115992. * @param scene defines the hosting scene
  115993. * @returns the plane polygonal mesh
  115994. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115995. */
  115996. static CreateDisc(name: string, options: {
  115997. radius?: number;
  115998. tessellation?: number;
  115999. arc?: number;
  116000. updatable?: boolean;
  116001. sideOrientation?: number;
  116002. frontUVs?: Vector4;
  116003. backUVs?: Vector4;
  116004. }, scene?: Nullable<Scene>): Mesh;
  116005. /**
  116006. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  116007. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  116008. * * 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`)
  116009. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  116010. * * 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
  116011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116014. * @param name defines the name of the mesh
  116015. * @param options defines the options used to create the mesh
  116016. * @param scene defines the hosting scene
  116017. * @returns the icosahedron mesh
  116018. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  116019. */
  116020. static CreateIcoSphere(name: string, options: {
  116021. radius?: number;
  116022. radiusX?: number;
  116023. radiusY?: number;
  116024. radiusZ?: number;
  116025. flat?: boolean;
  116026. subdivisions?: number;
  116027. sideOrientation?: number;
  116028. frontUVs?: Vector4;
  116029. backUVs?: Vector4;
  116030. updatable?: boolean;
  116031. }, scene?: Nullable<Scene>): Mesh;
  116032. /**
  116033. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116034. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116035. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116036. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116037. * * 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
  116038. * * 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
  116039. * * 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
  116040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116042. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116043. * * 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
  116044. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116045. * * 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
  116046. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116048. * @param name defines the name of the mesh
  116049. * @param options defines the options used to create the mesh
  116050. * @param scene defines the hosting scene
  116051. * @returns the ribbon mesh
  116052. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116053. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116054. */
  116055. static CreateRibbon(name: string, options: {
  116056. pathArray: Vector3[][];
  116057. closeArray?: boolean;
  116058. closePath?: boolean;
  116059. offset?: number;
  116060. updatable?: boolean;
  116061. sideOrientation?: number;
  116062. frontUVs?: Vector4;
  116063. backUVs?: Vector4;
  116064. instance?: Mesh;
  116065. invertUV?: boolean;
  116066. uvs?: Vector2[];
  116067. colors?: Color4[];
  116068. }, scene?: Nullable<Scene>): Mesh;
  116069. /**
  116070. * Creates a cylinder or a cone mesh
  116071. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116072. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116073. * * 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.
  116074. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116075. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116076. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116077. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116078. * * 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).
  116079. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116080. * * 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).
  116081. * * 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
  116082. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116083. * * 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
  116084. * * 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.
  116085. * * If `enclose` is false, a ring surface is one element.
  116086. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116087. * * 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
  116088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116091. * @param name defines the name of the mesh
  116092. * @param options defines the options used to create the mesh
  116093. * @param scene defines the hosting scene
  116094. * @returns the cylinder mesh
  116095. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116096. */
  116097. static CreateCylinder(name: string, options: {
  116098. height?: number;
  116099. diameterTop?: number;
  116100. diameterBottom?: number;
  116101. diameter?: number;
  116102. tessellation?: number;
  116103. subdivisions?: number;
  116104. arc?: number;
  116105. faceColors?: Color4[];
  116106. faceUV?: Vector4[];
  116107. updatable?: boolean;
  116108. hasRings?: boolean;
  116109. enclose?: boolean;
  116110. cap?: number;
  116111. sideOrientation?: number;
  116112. frontUVs?: Vector4;
  116113. backUVs?: Vector4;
  116114. }, scene?: Nullable<Scene>): Mesh;
  116115. /**
  116116. * Creates a torus mesh
  116117. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116118. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116119. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116123. * @param name defines the name of the mesh
  116124. * @param options defines the options used to create the mesh
  116125. * @param scene defines the hosting scene
  116126. * @returns the torus mesh
  116127. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116128. */
  116129. static CreateTorus(name: string, options: {
  116130. diameter?: number;
  116131. thickness?: number;
  116132. tessellation?: number;
  116133. updatable?: boolean;
  116134. sideOrientation?: number;
  116135. frontUVs?: Vector4;
  116136. backUVs?: Vector4;
  116137. }, scene?: Nullable<Scene>): Mesh;
  116138. /**
  116139. * Creates a torus knot mesh
  116140. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116141. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116142. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116143. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116147. * @param name defines the name of the mesh
  116148. * @param options defines the options used to create the mesh
  116149. * @param scene defines the hosting scene
  116150. * @returns the torus knot mesh
  116151. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116152. */
  116153. static CreateTorusKnot(name: string, options: {
  116154. radius?: number;
  116155. tube?: number;
  116156. radialSegments?: number;
  116157. tubularSegments?: number;
  116158. p?: number;
  116159. q?: number;
  116160. updatable?: boolean;
  116161. sideOrientation?: number;
  116162. frontUVs?: Vector4;
  116163. backUVs?: Vector4;
  116164. }, scene?: Nullable<Scene>): Mesh;
  116165. /**
  116166. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116167. * * 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
  116168. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116169. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116170. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116171. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116172. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116173. * * 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
  116174. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116177. * @param name defines the name of the new line system
  116178. * @param options defines the options used to create the line system
  116179. * @param scene defines the hosting scene
  116180. * @returns a new line system mesh
  116181. */
  116182. static CreateLineSystem(name: string, options: {
  116183. lines: Vector3[][];
  116184. updatable?: boolean;
  116185. instance?: Nullable<LinesMesh>;
  116186. colors?: Nullable<Color4[][]>;
  116187. useVertexAlpha?: boolean;
  116188. }, scene: Nullable<Scene>): LinesMesh;
  116189. /**
  116190. * Creates a line mesh
  116191. * 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
  116192. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116193. * * The parameter `points` is an array successive Vector3
  116194. * * 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
  116195. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116196. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116197. * * When updating an instance, remember that only point positions can change, not the number of points
  116198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116200. * @param name defines the name of the new line system
  116201. * @param options defines the options used to create the line system
  116202. * @param scene defines the hosting scene
  116203. * @returns a new line mesh
  116204. */
  116205. static CreateLines(name: string, options: {
  116206. points: Vector3[];
  116207. updatable?: boolean;
  116208. instance?: Nullable<LinesMesh>;
  116209. colors?: Color4[];
  116210. useVertexAlpha?: boolean;
  116211. }, scene?: Nullable<Scene>): LinesMesh;
  116212. /**
  116213. * Creates a dashed line mesh
  116214. * * 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
  116215. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116216. * * The parameter `points` is an array successive Vector3
  116217. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116218. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116219. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116220. * * 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
  116221. * * When updating an instance, remember that only point positions can change, not the number of points
  116222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116223. * @param name defines the name of the mesh
  116224. * @param options defines the options used to create the mesh
  116225. * @param scene defines the hosting scene
  116226. * @returns the dashed line mesh
  116227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116228. */
  116229. static CreateDashedLines(name: string, options: {
  116230. points: Vector3[];
  116231. dashSize?: number;
  116232. gapSize?: number;
  116233. dashNb?: number;
  116234. updatable?: boolean;
  116235. instance?: LinesMesh;
  116236. }, scene?: Nullable<Scene>): LinesMesh;
  116237. /**
  116238. * 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.
  116239. * * 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.
  116240. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116241. * * 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.
  116242. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116243. * * 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
  116244. * * 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
  116245. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116248. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116250. * @param name defines the name of the mesh
  116251. * @param options defines the options used to create the mesh
  116252. * @param scene defines the hosting scene
  116253. * @returns the extruded shape mesh
  116254. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116256. */
  116257. static ExtrudeShape(name: string, options: {
  116258. shape: Vector3[];
  116259. path: Vector3[];
  116260. scale?: number;
  116261. rotation?: number;
  116262. cap?: number;
  116263. updatable?: boolean;
  116264. sideOrientation?: number;
  116265. frontUVs?: Vector4;
  116266. backUVs?: Vector4;
  116267. instance?: Mesh;
  116268. invertUV?: boolean;
  116269. }, scene?: Nullable<Scene>): Mesh;
  116270. /**
  116271. * Creates an custom extruded shape mesh.
  116272. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116273. * * 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.
  116274. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116275. * * 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
  116276. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116277. * * 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
  116278. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116279. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116280. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116281. * * 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
  116282. * * 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
  116283. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116286. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116288. * @param name defines the name of the mesh
  116289. * @param options defines the options used to create the mesh
  116290. * @param scene defines the hosting scene
  116291. * @returns the custom extruded shape mesh
  116292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116293. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116295. */
  116296. static ExtrudeShapeCustom(name: string, options: {
  116297. shape: Vector3[];
  116298. path: Vector3[];
  116299. scaleFunction?: any;
  116300. rotationFunction?: any;
  116301. ribbonCloseArray?: boolean;
  116302. ribbonClosePath?: boolean;
  116303. cap?: number;
  116304. updatable?: boolean;
  116305. sideOrientation?: number;
  116306. frontUVs?: Vector4;
  116307. backUVs?: Vector4;
  116308. instance?: Mesh;
  116309. invertUV?: boolean;
  116310. }, scene?: Nullable<Scene>): Mesh;
  116311. /**
  116312. * Creates lathe mesh.
  116313. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116314. * * 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
  116315. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116316. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116317. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116318. * * 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
  116319. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116320. * * 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
  116321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116325. * @param name defines the name of the mesh
  116326. * @param options defines the options used to create the mesh
  116327. * @param scene defines the hosting scene
  116328. * @returns the lathe mesh
  116329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116330. */
  116331. static CreateLathe(name: string, options: {
  116332. shape: Vector3[];
  116333. radius?: number;
  116334. tessellation?: number;
  116335. clip?: number;
  116336. arc?: number;
  116337. closed?: boolean;
  116338. updatable?: boolean;
  116339. sideOrientation?: number;
  116340. frontUVs?: Vector4;
  116341. backUVs?: Vector4;
  116342. cap?: number;
  116343. invertUV?: boolean;
  116344. }, scene?: Nullable<Scene>): Mesh;
  116345. /**
  116346. * Creates a tiled plane mesh
  116347. * * You can set a limited pattern arrangement with the tiles
  116348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116351. * @param name defines the name of the mesh
  116352. * @param options defines the options used to create the mesh
  116353. * @param scene defines the hosting scene
  116354. * @returns the plane mesh
  116355. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116356. */
  116357. static CreateTiledPlane(name: string, options: {
  116358. pattern?: number;
  116359. tileSize?: number;
  116360. tileWidth?: number;
  116361. tileHeight?: number;
  116362. size?: number;
  116363. width?: number;
  116364. height?: number;
  116365. alignHorizontal?: number;
  116366. alignVertical?: number;
  116367. sideOrientation?: number;
  116368. frontUVs?: Vector4;
  116369. backUVs?: Vector4;
  116370. updatable?: boolean;
  116371. }, scene?: Nullable<Scene>): Mesh;
  116372. /**
  116373. * Creates a plane mesh
  116374. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116375. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116376. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116380. * @param name defines the name of the mesh
  116381. * @param options defines the options used to create the mesh
  116382. * @param scene defines the hosting scene
  116383. * @returns the plane mesh
  116384. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116385. */
  116386. static CreatePlane(name: string, options: {
  116387. size?: number;
  116388. width?: number;
  116389. height?: number;
  116390. sideOrientation?: number;
  116391. frontUVs?: Vector4;
  116392. backUVs?: Vector4;
  116393. updatable?: boolean;
  116394. sourcePlane?: Plane;
  116395. }, scene?: Nullable<Scene>): Mesh;
  116396. /**
  116397. * Creates a ground mesh
  116398. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116399. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116401. * @param name defines the name of the mesh
  116402. * @param options defines the options used to create the mesh
  116403. * @param scene defines the hosting scene
  116404. * @returns the ground mesh
  116405. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116406. */
  116407. static CreateGround(name: string, options: {
  116408. width?: number;
  116409. height?: number;
  116410. subdivisions?: number;
  116411. subdivisionsX?: number;
  116412. subdivisionsY?: number;
  116413. updatable?: boolean;
  116414. }, scene?: Nullable<Scene>): Mesh;
  116415. /**
  116416. * Creates a tiled ground mesh
  116417. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116418. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116419. * * 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
  116420. * * 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
  116421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116422. * @param name defines the name of the mesh
  116423. * @param options defines the options used to create the mesh
  116424. * @param scene defines the hosting scene
  116425. * @returns the tiled ground mesh
  116426. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116427. */
  116428. static CreateTiledGround(name: string, options: {
  116429. xmin: number;
  116430. zmin: number;
  116431. xmax: number;
  116432. zmax: number;
  116433. subdivisions?: {
  116434. w: number;
  116435. h: number;
  116436. };
  116437. precision?: {
  116438. w: number;
  116439. h: number;
  116440. };
  116441. updatable?: boolean;
  116442. }, scene?: Nullable<Scene>): Mesh;
  116443. /**
  116444. * Creates a ground mesh from a height map
  116445. * * The parameter `url` sets the URL of the height map image resource.
  116446. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116447. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116448. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116449. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116450. * * 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.
  116451. * * 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).
  116452. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116454. * @param name defines the name of the mesh
  116455. * @param url defines the url to the height map
  116456. * @param options defines the options used to create the mesh
  116457. * @param scene defines the hosting scene
  116458. * @returns the ground mesh
  116459. * @see https://doc.babylonjs.com/babylon101/height_map
  116460. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116461. */
  116462. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116463. width?: number;
  116464. height?: number;
  116465. subdivisions?: number;
  116466. minHeight?: number;
  116467. maxHeight?: number;
  116468. colorFilter?: Color3;
  116469. alphaFilter?: number;
  116470. updatable?: boolean;
  116471. onReady?: (mesh: GroundMesh) => void;
  116472. }, scene?: Nullable<Scene>): GroundMesh;
  116473. /**
  116474. * Creates a polygon mesh
  116475. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116476. * * 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
  116477. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116480. * * Remember you can only change the shape positions, not their number when updating a polygon
  116481. * @param name defines the name of the mesh
  116482. * @param options defines the options used to create the mesh
  116483. * @param scene defines the hosting scene
  116484. * @param earcutInjection can be used to inject your own earcut reference
  116485. * @returns the polygon mesh
  116486. */
  116487. static CreatePolygon(name: string, options: {
  116488. shape: Vector3[];
  116489. holes?: Vector3[][];
  116490. depth?: number;
  116491. faceUV?: Vector4[];
  116492. faceColors?: Color4[];
  116493. updatable?: boolean;
  116494. sideOrientation?: number;
  116495. frontUVs?: Vector4;
  116496. backUVs?: Vector4;
  116497. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116498. /**
  116499. * Creates an extruded polygon mesh, with depth in the Y direction.
  116500. * * 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)
  116501. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116502. * @param name defines the name of the mesh
  116503. * @param options defines the options used to create the mesh
  116504. * @param scene defines the hosting scene
  116505. * @param earcutInjection can be used to inject your own earcut reference
  116506. * @returns the polygon mesh
  116507. */
  116508. static ExtrudePolygon(name: string, options: {
  116509. shape: Vector3[];
  116510. holes?: Vector3[][];
  116511. depth?: number;
  116512. faceUV?: Vector4[];
  116513. faceColors?: Color4[];
  116514. updatable?: boolean;
  116515. sideOrientation?: number;
  116516. frontUVs?: Vector4;
  116517. backUVs?: Vector4;
  116518. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116519. /**
  116520. * Creates a tube mesh.
  116521. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116522. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116523. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116524. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116525. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116526. * * 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)
  116527. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116528. * * 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
  116529. * * 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
  116530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116531. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116532. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116534. * @param name defines the name of the mesh
  116535. * @param options defines the options used to create the mesh
  116536. * @param scene defines the hosting scene
  116537. * @returns the tube mesh
  116538. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116539. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116540. */
  116541. static CreateTube(name: string, options: {
  116542. path: Vector3[];
  116543. radius?: number;
  116544. tessellation?: number;
  116545. radiusFunction?: {
  116546. (i: number, distance: number): number;
  116547. };
  116548. cap?: number;
  116549. arc?: number;
  116550. updatable?: boolean;
  116551. sideOrientation?: number;
  116552. frontUVs?: Vector4;
  116553. backUVs?: Vector4;
  116554. instance?: Mesh;
  116555. invertUV?: boolean;
  116556. }, scene?: Nullable<Scene>): Mesh;
  116557. /**
  116558. * Creates a polyhedron mesh
  116559. * * 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
  116560. * * The parameter `size` (positive float, default 1) sets the polygon size
  116561. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116562. * * 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`
  116563. * * 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
  116564. * * 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)`)
  116565. * * 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
  116566. * * 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
  116567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116570. * @param name defines the name of the mesh
  116571. * @param options defines the options used to create the mesh
  116572. * @param scene defines the hosting scene
  116573. * @returns the polyhedron mesh
  116574. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116575. */
  116576. static CreatePolyhedron(name: string, options: {
  116577. type?: number;
  116578. size?: number;
  116579. sizeX?: number;
  116580. sizeY?: number;
  116581. sizeZ?: number;
  116582. custom?: any;
  116583. faceUV?: Vector4[];
  116584. faceColors?: Color4[];
  116585. flat?: boolean;
  116586. updatable?: boolean;
  116587. sideOrientation?: number;
  116588. frontUVs?: Vector4;
  116589. backUVs?: Vector4;
  116590. }, scene?: Nullable<Scene>): Mesh;
  116591. /**
  116592. * Creates a decal mesh.
  116593. * 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
  116594. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116595. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116596. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116597. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116598. * @param name defines the name of the mesh
  116599. * @param sourceMesh defines the mesh where the decal must be applied
  116600. * @param options defines the options used to create the mesh
  116601. * @param scene defines the hosting scene
  116602. * @returns the decal mesh
  116603. * @see https://doc.babylonjs.com/how_to/decals
  116604. */
  116605. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116606. position?: Vector3;
  116607. normal?: Vector3;
  116608. size?: Vector3;
  116609. angle?: number;
  116610. }): Mesh;
  116611. }
  116612. }
  116613. declare module BABYLON {
  116614. /**
  116615. * A simplifier interface for future simplification implementations
  116616. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116617. */
  116618. export interface ISimplifier {
  116619. /**
  116620. * Simplification of a given mesh according to the given settings.
  116621. * Since this requires computation, it is assumed that the function runs async.
  116622. * @param settings The settings of the simplification, including quality and distance
  116623. * @param successCallback A callback that will be called after the mesh was simplified.
  116624. * @param errorCallback in case of an error, this callback will be called. optional.
  116625. */
  116626. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116627. }
  116628. /**
  116629. * Expected simplification settings.
  116630. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116631. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116632. */
  116633. export interface ISimplificationSettings {
  116634. /**
  116635. * Gets or sets the expected quality
  116636. */
  116637. quality: number;
  116638. /**
  116639. * Gets or sets the distance when this optimized version should be used
  116640. */
  116641. distance: number;
  116642. /**
  116643. * Gets an already optimized mesh
  116644. */
  116645. optimizeMesh?: boolean;
  116646. }
  116647. /**
  116648. * Class used to specify simplification options
  116649. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116650. */
  116651. export class SimplificationSettings implements ISimplificationSettings {
  116652. /** expected quality */
  116653. quality: number;
  116654. /** distance when this optimized version should be used */
  116655. distance: number;
  116656. /** already optimized mesh */
  116657. optimizeMesh?: boolean | undefined;
  116658. /**
  116659. * Creates a SimplificationSettings
  116660. * @param quality expected quality
  116661. * @param distance distance when this optimized version should be used
  116662. * @param optimizeMesh already optimized mesh
  116663. */
  116664. constructor(
  116665. /** expected quality */
  116666. quality: number,
  116667. /** distance when this optimized version should be used */
  116668. distance: number,
  116669. /** already optimized mesh */
  116670. optimizeMesh?: boolean | undefined);
  116671. }
  116672. /**
  116673. * Interface used to define a simplification task
  116674. */
  116675. export interface ISimplificationTask {
  116676. /**
  116677. * Array of settings
  116678. */
  116679. settings: Array<ISimplificationSettings>;
  116680. /**
  116681. * Simplification type
  116682. */
  116683. simplificationType: SimplificationType;
  116684. /**
  116685. * Mesh to simplify
  116686. */
  116687. mesh: Mesh;
  116688. /**
  116689. * Callback called on success
  116690. */
  116691. successCallback?: () => void;
  116692. /**
  116693. * Defines if parallel processing can be used
  116694. */
  116695. parallelProcessing: boolean;
  116696. }
  116697. /**
  116698. * Queue used to order the simplification tasks
  116699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116700. */
  116701. export class SimplificationQueue {
  116702. private _simplificationArray;
  116703. /**
  116704. * Gets a boolean indicating that the process is still running
  116705. */
  116706. running: boolean;
  116707. /**
  116708. * Creates a new queue
  116709. */
  116710. constructor();
  116711. /**
  116712. * Adds a new simplification task
  116713. * @param task defines a task to add
  116714. */
  116715. addTask(task: ISimplificationTask): void;
  116716. /**
  116717. * Execute next task
  116718. */
  116719. executeNext(): void;
  116720. /**
  116721. * Execute a simplification task
  116722. * @param task defines the task to run
  116723. */
  116724. runSimplification(task: ISimplificationTask): void;
  116725. private getSimplifier;
  116726. }
  116727. /**
  116728. * The implemented types of simplification
  116729. * At the moment only Quadratic Error Decimation is implemented
  116730. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116731. */
  116732. export enum SimplificationType {
  116733. /** Quadratic error decimation */
  116734. QUADRATIC = 0
  116735. }
  116736. }
  116737. declare module BABYLON {
  116738. interface Scene {
  116739. /** @hidden (Backing field) */
  116740. _simplificationQueue: SimplificationQueue;
  116741. /**
  116742. * Gets or sets the simplification queue attached to the scene
  116743. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116744. */
  116745. simplificationQueue: SimplificationQueue;
  116746. }
  116747. interface Mesh {
  116748. /**
  116749. * Simplify the mesh according to the given array of settings.
  116750. * Function will return immediately and will simplify async
  116751. * @param settings a collection of simplification settings
  116752. * @param parallelProcessing should all levels calculate parallel or one after the other
  116753. * @param simplificationType the type of simplification to run
  116754. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116755. * @returns the current mesh
  116756. */
  116757. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116758. }
  116759. /**
  116760. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116761. * created in a scene
  116762. */
  116763. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116764. /**
  116765. * The component name helpfull to identify the component in the list of scene components.
  116766. */
  116767. readonly name: string;
  116768. /**
  116769. * The scene the component belongs to.
  116770. */
  116771. scene: Scene;
  116772. /**
  116773. * Creates a new instance of the component for the given scene
  116774. * @param scene Defines the scene to register the component in
  116775. */
  116776. constructor(scene: Scene);
  116777. /**
  116778. * Registers the component in a given scene
  116779. */
  116780. register(): void;
  116781. /**
  116782. * Rebuilds the elements related to this component in case of
  116783. * context lost for instance.
  116784. */
  116785. rebuild(): void;
  116786. /**
  116787. * Disposes the component and the associated ressources
  116788. */
  116789. dispose(): void;
  116790. private _beforeCameraUpdate;
  116791. }
  116792. }
  116793. declare module BABYLON {
  116794. /**
  116795. * Class used to enable access to IndexedDB
  116796. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116797. */
  116798. export class Database implements IOfflineProvider {
  116799. private _callbackManifestChecked;
  116800. private _currentSceneUrl;
  116801. private _db;
  116802. private _enableSceneOffline;
  116803. private _enableTexturesOffline;
  116804. private _manifestVersionFound;
  116805. private _mustUpdateRessources;
  116806. private _hasReachedQuota;
  116807. private _isSupported;
  116808. private _idbFactory;
  116809. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116810. private static IsUASupportingBlobStorage;
  116811. /**
  116812. * Gets a boolean indicating if Database storate is enabled (off by default)
  116813. */
  116814. static IDBStorageEnabled: boolean;
  116815. /**
  116816. * Gets a boolean indicating if scene must be saved in the database
  116817. */
  116818. readonly enableSceneOffline: boolean;
  116819. /**
  116820. * Gets a boolean indicating if textures must be saved in the database
  116821. */
  116822. readonly enableTexturesOffline: boolean;
  116823. /**
  116824. * Creates a new Database
  116825. * @param urlToScene defines the url to load the scene
  116826. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116827. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116828. */
  116829. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116830. private static _ParseURL;
  116831. private static _ReturnFullUrlLocation;
  116832. private _checkManifestFile;
  116833. /**
  116834. * Open the database and make it available
  116835. * @param successCallback defines the callback to call on success
  116836. * @param errorCallback defines the callback to call on error
  116837. */
  116838. open(successCallback: () => void, errorCallback: () => void): void;
  116839. /**
  116840. * Loads an image from the database
  116841. * @param url defines the url to load from
  116842. * @param image defines the target DOM image
  116843. */
  116844. loadImage(url: string, image: HTMLImageElement): void;
  116845. private _loadImageFromDBAsync;
  116846. private _saveImageIntoDBAsync;
  116847. private _checkVersionFromDB;
  116848. private _loadVersionFromDBAsync;
  116849. private _saveVersionIntoDBAsync;
  116850. /**
  116851. * Loads a file from database
  116852. * @param url defines the URL to load from
  116853. * @param sceneLoaded defines a callback to call on success
  116854. * @param progressCallBack defines a callback to call when progress changed
  116855. * @param errorCallback defines a callback to call on error
  116856. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116857. */
  116858. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116859. private _loadFileAsync;
  116860. private _saveFileAsync;
  116861. /**
  116862. * Validates if xhr data is correct
  116863. * @param xhr defines the request to validate
  116864. * @param dataType defines the expected data type
  116865. * @returns true if data is correct
  116866. */
  116867. private static _ValidateXHRData;
  116868. }
  116869. }
  116870. declare module BABYLON {
  116871. /** @hidden */
  116872. export var gpuUpdateParticlesPixelShader: {
  116873. name: string;
  116874. shader: string;
  116875. };
  116876. }
  116877. declare module BABYLON {
  116878. /** @hidden */
  116879. export var gpuUpdateParticlesVertexShader: {
  116880. name: string;
  116881. shader: string;
  116882. };
  116883. }
  116884. declare module BABYLON {
  116885. /** @hidden */
  116886. export var clipPlaneFragmentDeclaration2: {
  116887. name: string;
  116888. shader: string;
  116889. };
  116890. }
  116891. declare module BABYLON {
  116892. /** @hidden */
  116893. export var gpuRenderParticlesPixelShader: {
  116894. name: string;
  116895. shader: string;
  116896. };
  116897. }
  116898. declare module BABYLON {
  116899. /** @hidden */
  116900. export var clipPlaneVertexDeclaration2: {
  116901. name: string;
  116902. shader: string;
  116903. };
  116904. }
  116905. declare module BABYLON {
  116906. /** @hidden */
  116907. export var gpuRenderParticlesVertexShader: {
  116908. name: string;
  116909. shader: string;
  116910. };
  116911. }
  116912. declare module BABYLON {
  116913. /**
  116914. * This represents a GPU particle system in Babylon
  116915. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116916. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116917. */
  116918. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116919. /**
  116920. * The layer mask we are rendering the particles through.
  116921. */
  116922. layerMask: number;
  116923. private _capacity;
  116924. private _activeCount;
  116925. private _currentActiveCount;
  116926. private _accumulatedCount;
  116927. private _renderEffect;
  116928. private _updateEffect;
  116929. private _buffer0;
  116930. private _buffer1;
  116931. private _spriteBuffer;
  116932. private _updateVAO;
  116933. private _renderVAO;
  116934. private _targetIndex;
  116935. private _sourceBuffer;
  116936. private _targetBuffer;
  116937. private _engine;
  116938. private _currentRenderId;
  116939. private _started;
  116940. private _stopped;
  116941. private _timeDelta;
  116942. private _randomTexture;
  116943. private _randomTexture2;
  116944. private _attributesStrideSize;
  116945. private _updateEffectOptions;
  116946. private _randomTextureSize;
  116947. private _actualFrame;
  116948. private readonly _rawTextureWidth;
  116949. /**
  116950. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116951. */
  116952. static readonly IsSupported: boolean;
  116953. /**
  116954. * An event triggered when the system is disposed.
  116955. */
  116956. onDisposeObservable: Observable<GPUParticleSystem>;
  116957. /**
  116958. * Gets the maximum number of particles active at the same time.
  116959. * @returns The max number of active particles.
  116960. */
  116961. getCapacity(): number;
  116962. /**
  116963. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116964. * to override the particles.
  116965. */
  116966. forceDepthWrite: boolean;
  116967. /**
  116968. * Gets or set the number of active particles
  116969. */
  116970. activeParticleCount: number;
  116971. private _preWarmDone;
  116972. /**
  116973. * Is this system ready to be used/rendered
  116974. * @return true if the system is ready
  116975. */
  116976. isReady(): boolean;
  116977. /**
  116978. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116979. * @returns True if it has been started, otherwise false.
  116980. */
  116981. isStarted(): boolean;
  116982. /**
  116983. * Starts the particle system and begins to emit
  116984. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  116985. */
  116986. start(delay?: number): void;
  116987. /**
  116988. * Stops the particle system.
  116989. */
  116990. stop(): void;
  116991. /**
  116992. * Remove all active particles
  116993. */
  116994. reset(): void;
  116995. /**
  116996. * Returns the string "GPUParticleSystem"
  116997. * @returns a string containing the class name
  116998. */
  116999. getClassName(): string;
  117000. private _colorGradientsTexture;
  117001. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  117002. /**
  117003. * Adds a new color gradient
  117004. * @param gradient defines the gradient to use (between 0 and 1)
  117005. * @param color1 defines the color to affect to the specified gradient
  117006. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  117007. * @returns the current particle system
  117008. */
  117009. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  117010. /**
  117011. * Remove a specific color gradient
  117012. * @param gradient defines the gradient to remove
  117013. * @returns the current particle system
  117014. */
  117015. removeColorGradient(gradient: number): GPUParticleSystem;
  117016. private _angularSpeedGradientsTexture;
  117017. private _sizeGradientsTexture;
  117018. private _velocityGradientsTexture;
  117019. private _limitVelocityGradientsTexture;
  117020. private _dragGradientsTexture;
  117021. private _addFactorGradient;
  117022. /**
  117023. * Adds a new size gradient
  117024. * @param gradient defines the gradient to use (between 0 and 1)
  117025. * @param factor defines the size factor to affect to the specified gradient
  117026. * @returns the current particle system
  117027. */
  117028. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  117029. /**
  117030. * Remove a specific size gradient
  117031. * @param gradient defines the gradient to remove
  117032. * @returns the current particle system
  117033. */
  117034. removeSizeGradient(gradient: number): GPUParticleSystem;
  117035. /**
  117036. * Adds a new angular speed gradient
  117037. * @param gradient defines the gradient to use (between 0 and 1)
  117038. * @param factor defines the angular speed to affect to the specified gradient
  117039. * @returns the current particle system
  117040. */
  117041. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  117042. /**
  117043. * Remove a specific angular speed gradient
  117044. * @param gradient defines the gradient to remove
  117045. * @returns the current particle system
  117046. */
  117047. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  117048. /**
  117049. * Adds a new velocity gradient
  117050. * @param gradient defines the gradient to use (between 0 and 1)
  117051. * @param factor defines the velocity to affect to the specified gradient
  117052. * @returns the current particle system
  117053. */
  117054. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117055. /**
  117056. * Remove a specific velocity gradient
  117057. * @param gradient defines the gradient to remove
  117058. * @returns the current particle system
  117059. */
  117060. removeVelocityGradient(gradient: number): GPUParticleSystem;
  117061. /**
  117062. * Adds a new limit velocity gradient
  117063. * @param gradient defines the gradient to use (between 0 and 1)
  117064. * @param factor defines the limit velocity value to affect to the specified gradient
  117065. * @returns the current particle system
  117066. */
  117067. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117068. /**
  117069. * Remove a specific limit velocity gradient
  117070. * @param gradient defines the gradient to remove
  117071. * @returns the current particle system
  117072. */
  117073. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  117074. /**
  117075. * Adds a new drag gradient
  117076. * @param gradient defines the gradient to use (between 0 and 1)
  117077. * @param factor defines the drag value to affect to the specified gradient
  117078. * @returns the current particle system
  117079. */
  117080. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  117081. /**
  117082. * Remove a specific drag gradient
  117083. * @param gradient defines the gradient to remove
  117084. * @returns the current particle system
  117085. */
  117086. removeDragGradient(gradient: number): GPUParticleSystem;
  117087. /**
  117088. * Not supported by GPUParticleSystem
  117089. * @param gradient defines the gradient to use (between 0 and 1)
  117090. * @param factor defines the emit rate value to affect to the specified gradient
  117091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117092. * @returns the current particle system
  117093. */
  117094. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117095. /**
  117096. * Not supported by GPUParticleSystem
  117097. * @param gradient defines the gradient to remove
  117098. * @returns the current particle system
  117099. */
  117100. removeEmitRateGradient(gradient: number): IParticleSystem;
  117101. /**
  117102. * Not supported by GPUParticleSystem
  117103. * @param gradient defines the gradient to use (between 0 and 1)
  117104. * @param factor defines the start size value to affect to the specified gradient
  117105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117106. * @returns the current particle system
  117107. */
  117108. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117109. /**
  117110. * Not supported by GPUParticleSystem
  117111. * @param gradient defines the gradient to remove
  117112. * @returns the current particle system
  117113. */
  117114. removeStartSizeGradient(gradient: number): IParticleSystem;
  117115. /**
  117116. * Not supported by GPUParticleSystem
  117117. * @param gradient defines the gradient to use (between 0 and 1)
  117118. * @param min defines the color remap minimal range
  117119. * @param max defines the color remap maximal range
  117120. * @returns the current particle system
  117121. */
  117122. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117123. /**
  117124. * Not supported by GPUParticleSystem
  117125. * @param gradient defines the gradient to remove
  117126. * @returns the current particle system
  117127. */
  117128. removeColorRemapGradient(): IParticleSystem;
  117129. /**
  117130. * Not supported by GPUParticleSystem
  117131. * @param gradient defines the gradient to use (between 0 and 1)
  117132. * @param min defines the alpha remap minimal range
  117133. * @param max defines the alpha remap maximal range
  117134. * @returns the current particle system
  117135. */
  117136. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117137. /**
  117138. * Not supported by GPUParticleSystem
  117139. * @param gradient defines the gradient to remove
  117140. * @returns the current particle system
  117141. */
  117142. removeAlphaRemapGradient(): IParticleSystem;
  117143. /**
  117144. * Not supported by GPUParticleSystem
  117145. * @param gradient defines the gradient to use (between 0 and 1)
  117146. * @param color defines the color to affect to the specified gradient
  117147. * @returns the current particle system
  117148. */
  117149. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  117150. /**
  117151. * Not supported by GPUParticleSystem
  117152. * @param gradient defines the gradient to remove
  117153. * @returns the current particle system
  117154. */
  117155. removeRampGradient(): IParticleSystem;
  117156. /**
  117157. * Not supported by GPUParticleSystem
  117158. * @returns the list of ramp gradients
  117159. */
  117160. getRampGradients(): Nullable<Array<Color3Gradient>>;
  117161. /**
  117162. * Not supported by GPUParticleSystem
  117163. * Gets or sets a boolean indicating that ramp gradients must be used
  117164. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  117165. */
  117166. useRampGradients: boolean;
  117167. /**
  117168. * Not supported by GPUParticleSystem
  117169. * @param gradient defines the gradient to use (between 0 and 1)
  117170. * @param factor defines the life time factor to affect to the specified gradient
  117171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117172. * @returns the current particle system
  117173. */
  117174. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117175. /**
  117176. * Not supported by GPUParticleSystem
  117177. * @param gradient defines the gradient to remove
  117178. * @returns the current particle system
  117179. */
  117180. removeLifeTimeGradient(gradient: number): IParticleSystem;
  117181. /**
  117182. * Instantiates a GPU particle system.
  117183. * 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.
  117184. * @param name The name of the particle system
  117185. * @param options The options used to create the system
  117186. * @param scene The scene the particle system belongs to
  117187. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  117188. */
  117189. constructor(name: string, options: Partial<{
  117190. capacity: number;
  117191. randomTextureSize: number;
  117192. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  117193. protected _reset(): void;
  117194. private _createUpdateVAO;
  117195. private _createRenderVAO;
  117196. private _initialize;
  117197. /** @hidden */
  117198. _recreateUpdateEffect(): void;
  117199. /** @hidden */
  117200. _recreateRenderEffect(): void;
  117201. /**
  117202. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  117203. * @param preWarm defines if we are in the pre-warmimg phase
  117204. */
  117205. animate(preWarm?: boolean): void;
  117206. private _createFactorGradientTexture;
  117207. private _createSizeGradientTexture;
  117208. private _createAngularSpeedGradientTexture;
  117209. private _createVelocityGradientTexture;
  117210. private _createLimitVelocityGradientTexture;
  117211. private _createDragGradientTexture;
  117212. private _createColorGradientTexture;
  117213. /**
  117214. * Renders the particle system in its current state
  117215. * @param preWarm defines if the system should only update the particles but not render them
  117216. * @returns the current number of particles
  117217. */
  117218. render(preWarm?: boolean): number;
  117219. /**
  117220. * Rebuilds the particle system
  117221. */
  117222. rebuild(): void;
  117223. private _releaseBuffers;
  117224. private _releaseVAOs;
  117225. /**
  117226. * Disposes the particle system and free the associated resources
  117227. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  117228. */
  117229. dispose(disposeTexture?: boolean): void;
  117230. /**
  117231. * Clones the particle system.
  117232. * @param name The name of the cloned object
  117233. * @param newEmitter The new emitter to use
  117234. * @returns the cloned particle system
  117235. */
  117236. clone(name: string, newEmitter: any): GPUParticleSystem;
  117237. /**
  117238. * Serializes the particle system to a JSON object.
  117239. * @returns the JSON object
  117240. */
  117241. serialize(): any;
  117242. /**
  117243. * Parses a JSON object to create a GPU particle system.
  117244. * @param parsedParticleSystem The JSON object to parse
  117245. * @param scene The scene to create the particle system in
  117246. * @param rootUrl The root url to use to load external dependencies like texture
  117247. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  117248. * @returns the parsed GPU particle system
  117249. */
  117250. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  117251. }
  117252. }
  117253. declare module BABYLON {
  117254. /**
  117255. * Represents a set of particle systems working together to create a specific effect
  117256. */
  117257. export class ParticleSystemSet implements IDisposable {
  117258. private _emitterCreationOptions;
  117259. private _emitterNode;
  117260. /**
  117261. * Gets the particle system list
  117262. */
  117263. systems: IParticleSystem[];
  117264. /**
  117265. * Gets the emitter node used with this set
  117266. */
  117267. readonly emitterNode: Nullable<TransformNode>;
  117268. /**
  117269. * Creates a new emitter mesh as a sphere
  117270. * @param options defines the options used to create the sphere
  117271. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  117272. * @param scene defines the hosting scene
  117273. */
  117274. setEmitterAsSphere(options: {
  117275. diameter: number;
  117276. segments: number;
  117277. color: Color3;
  117278. }, renderingGroupId: number, scene: Scene): void;
  117279. /**
  117280. * Starts all particle systems of the set
  117281. * @param emitter defines an optional mesh to use as emitter for the particle systems
  117282. */
  117283. start(emitter?: AbstractMesh): void;
  117284. /**
  117285. * Release all associated resources
  117286. */
  117287. dispose(): void;
  117288. /**
  117289. * Serialize the set into a JSON compatible object
  117290. * @returns a JSON compatible representation of the set
  117291. */
  117292. serialize(): any;
  117293. /**
  117294. * Parse a new ParticleSystemSet from a serialized source
  117295. * @param data defines a JSON compatible representation of the set
  117296. * @param scene defines the hosting scene
  117297. * @param gpu defines if we want GPU particles or CPU particles
  117298. * @returns a new ParticleSystemSet
  117299. */
  117300. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117301. }
  117302. }
  117303. declare module BABYLON {
  117304. /**
  117305. * This class is made for on one-liner static method to help creating particle system set.
  117306. */
  117307. export class ParticleHelper {
  117308. /**
  117309. * Gets or sets base Assets URL
  117310. */
  117311. static BaseAssetsUrl: string;
  117312. /**
  117313. * Create a default particle system that you can tweak
  117314. * @param emitter defines the emitter to use
  117315. * @param capacity defines the system capacity (default is 500 particles)
  117316. * @param scene defines the hosting scene
  117317. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117318. * @returns the new Particle system
  117319. */
  117320. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117321. /**
  117322. * This is the main static method (one-liner) of this helper to create different particle systems
  117323. * @param type This string represents the type to the particle system to create
  117324. * @param scene The scene where the particle system should live
  117325. * @param gpu If the system will use gpu
  117326. * @returns the ParticleSystemSet created
  117327. */
  117328. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117329. /**
  117330. * Static function used to export a particle system to a ParticleSystemSet variable.
  117331. * Please note that the emitter shape is not exported
  117332. * @param systems defines the particle systems to export
  117333. * @returns the created particle system set
  117334. */
  117335. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117336. }
  117337. }
  117338. declare module BABYLON {
  117339. interface Engine {
  117340. /**
  117341. * Create an effect to use with particle systems.
  117342. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117343. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117344. * @param uniformsNames defines a list of attribute names
  117345. * @param samplers defines an array of string used to represent textures
  117346. * @param defines defines the string containing the defines to use to compile the shaders
  117347. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117348. * @param onCompiled defines a function to call when the effect creation is successful
  117349. * @param onError defines a function to call when the effect creation has failed
  117350. * @returns the new Effect
  117351. */
  117352. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117353. }
  117354. interface Mesh {
  117355. /**
  117356. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117357. * @returns an array of IParticleSystem
  117358. */
  117359. getEmittedParticleSystems(): IParticleSystem[];
  117360. /**
  117361. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117362. * @returns an array of IParticleSystem
  117363. */
  117364. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117365. }
  117366. /**
  117367. * @hidden
  117368. */
  117369. export var _IDoNeedToBeInTheBuild: number;
  117370. }
  117371. declare module BABYLON {
  117372. interface Scene {
  117373. /** @hidden (Backing field) */
  117374. _physicsEngine: Nullable<IPhysicsEngine>;
  117375. /**
  117376. * Gets the current physics engine
  117377. * @returns a IPhysicsEngine or null if none attached
  117378. */
  117379. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117380. /**
  117381. * Enables physics to the current scene
  117382. * @param gravity defines the scene's gravity for the physics engine
  117383. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117384. * @return a boolean indicating if the physics engine was initialized
  117385. */
  117386. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117387. /**
  117388. * Disables and disposes the physics engine associated with the scene
  117389. */
  117390. disablePhysicsEngine(): void;
  117391. /**
  117392. * Gets a boolean indicating if there is an active physics engine
  117393. * @returns a boolean indicating if there is an active physics engine
  117394. */
  117395. isPhysicsEnabled(): boolean;
  117396. /**
  117397. * Deletes a physics compound impostor
  117398. * @param compound defines the compound to delete
  117399. */
  117400. deleteCompoundImpostor(compound: any): void;
  117401. /**
  117402. * An event triggered when physic simulation is about to be run
  117403. */
  117404. onBeforePhysicsObservable: Observable<Scene>;
  117405. /**
  117406. * An event triggered when physic simulation has been done
  117407. */
  117408. onAfterPhysicsObservable: Observable<Scene>;
  117409. }
  117410. interface AbstractMesh {
  117411. /** @hidden */
  117412. _physicsImpostor: Nullable<PhysicsImpostor>;
  117413. /**
  117414. * Gets or sets impostor used for physic simulation
  117415. * @see http://doc.babylonjs.com/features/physics_engine
  117416. */
  117417. physicsImpostor: Nullable<PhysicsImpostor>;
  117418. /**
  117419. * Gets the current physics impostor
  117420. * @see http://doc.babylonjs.com/features/physics_engine
  117421. * @returns a physics impostor or null
  117422. */
  117423. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117424. /** Apply a physic impulse to the mesh
  117425. * @param force defines the force to apply
  117426. * @param contactPoint defines where to apply the force
  117427. * @returns the current mesh
  117428. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117429. */
  117430. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117431. /**
  117432. * Creates a physic joint between two meshes
  117433. * @param otherMesh defines the other mesh to use
  117434. * @param pivot1 defines the pivot to use on this mesh
  117435. * @param pivot2 defines the pivot to use on the other mesh
  117436. * @param options defines additional options (can be plugin dependent)
  117437. * @returns the current mesh
  117438. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117439. */
  117440. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117441. /** @hidden */
  117442. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117443. }
  117444. /**
  117445. * Defines the physics engine scene component responsible to manage a physics engine
  117446. */
  117447. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117448. /**
  117449. * The component name helpful to identify the component in the list of scene components.
  117450. */
  117451. readonly name: string;
  117452. /**
  117453. * The scene the component belongs to.
  117454. */
  117455. scene: Scene;
  117456. /**
  117457. * Creates a new instance of the component for the given scene
  117458. * @param scene Defines the scene to register the component in
  117459. */
  117460. constructor(scene: Scene);
  117461. /**
  117462. * Registers the component in a given scene
  117463. */
  117464. register(): void;
  117465. /**
  117466. * Rebuilds the elements related to this component in case of
  117467. * context lost for instance.
  117468. */
  117469. rebuild(): void;
  117470. /**
  117471. * Disposes the component and the associated ressources
  117472. */
  117473. dispose(): void;
  117474. }
  117475. }
  117476. declare module BABYLON {
  117477. /**
  117478. * A helper for physics simulations
  117479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117480. */
  117481. export class PhysicsHelper {
  117482. private _scene;
  117483. private _physicsEngine;
  117484. /**
  117485. * Initializes the Physics helper
  117486. * @param scene Babylon.js scene
  117487. */
  117488. constructor(scene: Scene);
  117489. /**
  117490. * Applies a radial explosion impulse
  117491. * @param origin the origin of the explosion
  117492. * @param radiusOrEventOptions the radius or the options of radial explosion
  117493. * @param strength the explosion strength
  117494. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117495. * @returns A physics radial explosion event, or null
  117496. */
  117497. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117498. /**
  117499. * Applies a radial explosion force
  117500. * @param origin the origin of the explosion
  117501. * @param radiusOrEventOptions the radius or the options of radial explosion
  117502. * @param strength the explosion strength
  117503. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117504. * @returns A physics radial explosion event, or null
  117505. */
  117506. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117507. /**
  117508. * Creates a gravitational field
  117509. * @param origin the origin of the explosion
  117510. * @param radiusOrEventOptions the radius or the options of radial explosion
  117511. * @param strength the explosion strength
  117512. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117513. * @returns A physics gravitational field event, or null
  117514. */
  117515. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117516. /**
  117517. * Creates a physics updraft event
  117518. * @param origin the origin of the updraft
  117519. * @param radiusOrEventOptions the radius or the options of the updraft
  117520. * @param strength the strength of the updraft
  117521. * @param height the height of the updraft
  117522. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117523. * @returns A physics updraft event, or null
  117524. */
  117525. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117526. /**
  117527. * Creates a physics vortex event
  117528. * @param origin the of the vortex
  117529. * @param radiusOrEventOptions the radius or the options of the vortex
  117530. * @param strength the strength of the vortex
  117531. * @param height the height of the vortex
  117532. * @returns a Physics vortex event, or null
  117533. * A physics vortex event or null
  117534. */
  117535. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117536. }
  117537. /**
  117538. * Represents a physics radial explosion event
  117539. */
  117540. class PhysicsRadialExplosionEvent {
  117541. private _scene;
  117542. private _options;
  117543. private _sphere;
  117544. private _dataFetched;
  117545. /**
  117546. * Initializes a radial explosioin event
  117547. * @param _scene BabylonJS scene
  117548. * @param _options The options for the vortex event
  117549. */
  117550. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117551. /**
  117552. * Returns the data related to the radial explosion event (sphere).
  117553. * @returns The radial explosion event data
  117554. */
  117555. getData(): PhysicsRadialExplosionEventData;
  117556. /**
  117557. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117558. * @param impostor A physics imposter
  117559. * @param origin the origin of the explosion
  117560. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117561. */
  117562. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117563. /**
  117564. * Triggers affecterd impostors callbacks
  117565. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117566. */
  117567. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117568. /**
  117569. * Disposes the sphere.
  117570. * @param force Specifies if the sphere should be disposed by force
  117571. */
  117572. dispose(force?: boolean): void;
  117573. /*** Helpers ***/
  117574. private _prepareSphere;
  117575. private _intersectsWithSphere;
  117576. }
  117577. /**
  117578. * Represents a gravitational field event
  117579. */
  117580. class PhysicsGravitationalFieldEvent {
  117581. private _physicsHelper;
  117582. private _scene;
  117583. private _origin;
  117584. private _options;
  117585. private _tickCallback;
  117586. private _sphere;
  117587. private _dataFetched;
  117588. /**
  117589. * Initializes the physics gravitational field event
  117590. * @param _physicsHelper A physics helper
  117591. * @param _scene BabylonJS scene
  117592. * @param _origin The origin position of the gravitational field event
  117593. * @param _options The options for the vortex event
  117594. */
  117595. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117596. /**
  117597. * Returns the data related to the gravitational field event (sphere).
  117598. * @returns A gravitational field event
  117599. */
  117600. getData(): PhysicsGravitationalFieldEventData;
  117601. /**
  117602. * Enables the gravitational field.
  117603. */
  117604. enable(): void;
  117605. /**
  117606. * Disables the gravitational field.
  117607. */
  117608. disable(): void;
  117609. /**
  117610. * Disposes the sphere.
  117611. * @param force The force to dispose from the gravitational field event
  117612. */
  117613. dispose(force?: boolean): void;
  117614. private _tick;
  117615. }
  117616. /**
  117617. * Represents a physics updraft event
  117618. */
  117619. class PhysicsUpdraftEvent {
  117620. private _scene;
  117621. private _origin;
  117622. private _options;
  117623. private _physicsEngine;
  117624. private _originTop;
  117625. private _originDirection;
  117626. private _tickCallback;
  117627. private _cylinder;
  117628. private _cylinderPosition;
  117629. private _dataFetched;
  117630. /**
  117631. * Initializes the physics updraft event
  117632. * @param _scene BabylonJS scene
  117633. * @param _origin The origin position of the updraft
  117634. * @param _options The options for the updraft event
  117635. */
  117636. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117637. /**
  117638. * Returns the data related to the updraft event (cylinder).
  117639. * @returns A physics updraft event
  117640. */
  117641. getData(): PhysicsUpdraftEventData;
  117642. /**
  117643. * Enables the updraft.
  117644. */
  117645. enable(): void;
  117646. /**
  117647. * Disables the updraft.
  117648. */
  117649. disable(): void;
  117650. /**
  117651. * Disposes the cylinder.
  117652. * @param force Specifies if the updraft should be disposed by force
  117653. */
  117654. dispose(force?: boolean): void;
  117655. private getImpostorHitData;
  117656. private _tick;
  117657. /*** Helpers ***/
  117658. private _prepareCylinder;
  117659. private _intersectsWithCylinder;
  117660. }
  117661. /**
  117662. * Represents a physics vortex event
  117663. */
  117664. class PhysicsVortexEvent {
  117665. private _scene;
  117666. private _origin;
  117667. private _options;
  117668. private _physicsEngine;
  117669. private _originTop;
  117670. private _tickCallback;
  117671. private _cylinder;
  117672. private _cylinderPosition;
  117673. private _dataFetched;
  117674. /**
  117675. * Initializes the physics vortex event
  117676. * @param _scene The BabylonJS scene
  117677. * @param _origin The origin position of the vortex
  117678. * @param _options The options for the vortex event
  117679. */
  117680. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117681. /**
  117682. * Returns the data related to the vortex event (cylinder).
  117683. * @returns The physics vortex event data
  117684. */
  117685. getData(): PhysicsVortexEventData;
  117686. /**
  117687. * Enables the vortex.
  117688. */
  117689. enable(): void;
  117690. /**
  117691. * Disables the cortex.
  117692. */
  117693. disable(): void;
  117694. /**
  117695. * Disposes the sphere.
  117696. * @param force
  117697. */
  117698. dispose(force?: boolean): void;
  117699. private getImpostorHitData;
  117700. private _tick;
  117701. /*** Helpers ***/
  117702. private _prepareCylinder;
  117703. private _intersectsWithCylinder;
  117704. }
  117705. /**
  117706. * Options fot the radial explosion event
  117707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117708. */
  117709. export class PhysicsRadialExplosionEventOptions {
  117710. /**
  117711. * The radius of the sphere for the radial explosion.
  117712. */
  117713. radius: number;
  117714. /**
  117715. * The strenth of the explosion.
  117716. */
  117717. strength: number;
  117718. /**
  117719. * The strenght of the force in correspondence to the distance of the affected object
  117720. */
  117721. falloff: PhysicsRadialImpulseFalloff;
  117722. /**
  117723. * Sphere options for the radial explosion.
  117724. */
  117725. sphere: {
  117726. segments: number;
  117727. diameter: number;
  117728. };
  117729. /**
  117730. * Sphere options for the radial explosion.
  117731. */
  117732. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117733. }
  117734. /**
  117735. * Options fot the updraft event
  117736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117737. */
  117738. export class PhysicsUpdraftEventOptions {
  117739. /**
  117740. * The radius of the cylinder for the vortex
  117741. */
  117742. radius: number;
  117743. /**
  117744. * The strenth of the updraft.
  117745. */
  117746. strength: number;
  117747. /**
  117748. * The height of the cylinder for the updraft.
  117749. */
  117750. height: number;
  117751. /**
  117752. * The mode for the the updraft.
  117753. */
  117754. updraftMode: PhysicsUpdraftMode;
  117755. }
  117756. /**
  117757. * Options fot the vortex event
  117758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117759. */
  117760. export class PhysicsVortexEventOptions {
  117761. /**
  117762. * The radius of the cylinder for the vortex
  117763. */
  117764. radius: number;
  117765. /**
  117766. * The strenth of the vortex.
  117767. */
  117768. strength: number;
  117769. /**
  117770. * The height of the cylinder for the vortex.
  117771. */
  117772. height: number;
  117773. /**
  117774. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117775. */
  117776. centripetalForceThreshold: number;
  117777. /**
  117778. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117779. */
  117780. centripetalForceMultiplier: number;
  117781. /**
  117782. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117783. */
  117784. centrifugalForceMultiplier: number;
  117785. /**
  117786. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117787. */
  117788. updraftForceMultiplier: number;
  117789. }
  117790. /**
  117791. * The strenght of the force in correspondence to the distance of the affected object
  117792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117793. */
  117794. export enum PhysicsRadialImpulseFalloff {
  117795. /** Defines that impulse is constant in strength across it's whole radius */
  117796. Constant = 0,
  117797. /** Defines that impulse gets weaker if it's further from the origin */
  117798. Linear = 1
  117799. }
  117800. /**
  117801. * The strength of the force in correspondence to the distance of the affected object
  117802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117803. */
  117804. export enum PhysicsUpdraftMode {
  117805. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117806. Center = 0,
  117807. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117808. Perpendicular = 1
  117809. }
  117810. /**
  117811. * Interface for a physics hit data
  117812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117813. */
  117814. export interface PhysicsHitData {
  117815. /**
  117816. * The force applied at the contact point
  117817. */
  117818. force: Vector3;
  117819. /**
  117820. * The contact point
  117821. */
  117822. contactPoint: Vector3;
  117823. /**
  117824. * The distance from the origin to the contact point
  117825. */
  117826. distanceFromOrigin: number;
  117827. }
  117828. /**
  117829. * Interface for radial explosion event data
  117830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117831. */
  117832. export interface PhysicsRadialExplosionEventData {
  117833. /**
  117834. * A sphere used for the radial explosion event
  117835. */
  117836. sphere: Mesh;
  117837. }
  117838. /**
  117839. * Interface for gravitational field event data
  117840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117841. */
  117842. export interface PhysicsGravitationalFieldEventData {
  117843. /**
  117844. * A sphere mesh used for the gravitational field event
  117845. */
  117846. sphere: Mesh;
  117847. }
  117848. /**
  117849. * Interface for updraft event data
  117850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117851. */
  117852. export interface PhysicsUpdraftEventData {
  117853. /**
  117854. * A cylinder used for the updraft event
  117855. */
  117856. cylinder: Mesh;
  117857. }
  117858. /**
  117859. * Interface for vortex event data
  117860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117861. */
  117862. export interface PhysicsVortexEventData {
  117863. /**
  117864. * A cylinder used for the vortex event
  117865. */
  117866. cylinder: Mesh;
  117867. }
  117868. /**
  117869. * Interface for an affected physics impostor
  117870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117871. */
  117872. export interface PhysicsAffectedImpostorWithData {
  117873. /**
  117874. * The impostor affected by the effect
  117875. */
  117876. impostor: PhysicsImpostor;
  117877. /**
  117878. * The data about the hit/horce from the explosion
  117879. */
  117880. hitData: PhysicsHitData;
  117881. }
  117882. }
  117883. declare module BABYLON {
  117884. /** @hidden */
  117885. export var blackAndWhitePixelShader: {
  117886. name: string;
  117887. shader: string;
  117888. };
  117889. }
  117890. declare module BABYLON {
  117891. /**
  117892. * Post process used to render in black and white
  117893. */
  117894. export class BlackAndWhitePostProcess extends PostProcess {
  117895. /**
  117896. * Linear about to convert he result to black and white (default: 1)
  117897. */
  117898. degree: number;
  117899. /**
  117900. * Creates a black and white post process
  117901. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117902. * @param name The name of the effect.
  117903. * @param options The required width/height ratio to downsize to before computing the render pass.
  117904. * @param camera The camera to apply the render pass to.
  117905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117906. * @param engine The engine which the post process will be applied. (default: current engine)
  117907. * @param reusable If the post process can be reused on the same frame. (default: false)
  117908. */
  117909. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117910. }
  117911. }
  117912. declare module BABYLON {
  117913. /**
  117914. * This represents a set of one or more post processes in Babylon.
  117915. * A post process can be used to apply a shader to a texture after it is rendered.
  117916. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117917. */
  117918. export class PostProcessRenderEffect {
  117919. private _postProcesses;
  117920. private _getPostProcesses;
  117921. private _singleInstance;
  117922. private _cameras;
  117923. private _indicesForCamera;
  117924. /**
  117925. * Name of the effect
  117926. * @hidden
  117927. */
  117928. _name: string;
  117929. /**
  117930. * Instantiates a post process render effect.
  117931. * A post process can be used to apply a shader to a texture after it is rendered.
  117932. * @param engine The engine the effect is tied to
  117933. * @param name The name of the effect
  117934. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117935. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117936. */
  117937. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117938. /**
  117939. * Checks if all the post processes in the effect are supported.
  117940. */
  117941. readonly isSupported: boolean;
  117942. /**
  117943. * Updates the current state of the effect
  117944. * @hidden
  117945. */
  117946. _update(): void;
  117947. /**
  117948. * Attaches the effect on cameras
  117949. * @param cameras The camera to attach to.
  117950. * @hidden
  117951. */
  117952. _attachCameras(cameras: Camera): void;
  117953. /**
  117954. * Attaches the effect on cameras
  117955. * @param cameras The camera to attach to.
  117956. * @hidden
  117957. */
  117958. _attachCameras(cameras: Camera[]): void;
  117959. /**
  117960. * Detaches the effect on cameras
  117961. * @param cameras The camera to detatch from.
  117962. * @hidden
  117963. */
  117964. _detachCameras(cameras: Camera): void;
  117965. /**
  117966. * Detatches the effect on cameras
  117967. * @param cameras The camera to detatch from.
  117968. * @hidden
  117969. */
  117970. _detachCameras(cameras: Camera[]): void;
  117971. /**
  117972. * Enables the effect on given cameras
  117973. * @param cameras The camera to enable.
  117974. * @hidden
  117975. */
  117976. _enable(cameras: Camera): void;
  117977. /**
  117978. * Enables the effect on given cameras
  117979. * @param cameras The camera to enable.
  117980. * @hidden
  117981. */
  117982. _enable(cameras: Nullable<Camera[]>): void;
  117983. /**
  117984. * Disables the effect on the given cameras
  117985. * @param cameras The camera to disable.
  117986. * @hidden
  117987. */
  117988. _disable(cameras: Camera): void;
  117989. /**
  117990. * Disables the effect on the given cameras
  117991. * @param cameras The camera to disable.
  117992. * @hidden
  117993. */
  117994. _disable(cameras: Nullable<Camera[]>): void;
  117995. /**
  117996. * Gets a list of the post processes contained in the effect.
  117997. * @param camera The camera to get the post processes on.
  117998. * @returns The list of the post processes in the effect.
  117999. */
  118000. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  118001. }
  118002. }
  118003. declare module BABYLON {
  118004. /** @hidden */
  118005. export var extractHighlightsPixelShader: {
  118006. name: string;
  118007. shader: string;
  118008. };
  118009. }
  118010. declare module BABYLON {
  118011. /**
  118012. * 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.
  118013. */
  118014. export class ExtractHighlightsPostProcess extends PostProcess {
  118015. /**
  118016. * The luminance threshold, pixels below this value will be set to black.
  118017. */
  118018. threshold: number;
  118019. /** @hidden */
  118020. _exposure: number;
  118021. /**
  118022. * Post process which has the input texture to be used when performing highlight extraction
  118023. * @hidden
  118024. */
  118025. _inputPostProcess: Nullable<PostProcess>;
  118026. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118027. }
  118028. }
  118029. declare module BABYLON {
  118030. /** @hidden */
  118031. export var bloomMergePixelShader: {
  118032. name: string;
  118033. shader: string;
  118034. };
  118035. }
  118036. declare module BABYLON {
  118037. /**
  118038. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118039. */
  118040. export class BloomMergePostProcess extends PostProcess {
  118041. /** Weight of the bloom to be added to the original input. */
  118042. weight: number;
  118043. /**
  118044. * Creates a new instance of @see BloomMergePostProcess
  118045. * @param name The name of the effect.
  118046. * @param originalFromInput Post process which's input will be used for the merge.
  118047. * @param blurred Blurred highlights post process which's output will be used.
  118048. * @param weight Weight of the bloom to be added to the original input.
  118049. * @param options The required width/height ratio to downsize to before computing the render pass.
  118050. * @param camera The camera to apply the render pass to.
  118051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118052. * @param engine The engine which the post process will be applied. (default: current engine)
  118053. * @param reusable If the post process can be reused on the same frame. (default: false)
  118054. * @param textureType Type of textures used when performing the post process. (default: 0)
  118055. * @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)
  118056. */
  118057. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  118058. /** Weight of the bloom to be added to the original input. */
  118059. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118060. }
  118061. }
  118062. declare module BABYLON {
  118063. /**
  118064. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118065. */
  118066. export class BloomEffect extends PostProcessRenderEffect {
  118067. private bloomScale;
  118068. /**
  118069. * @hidden Internal
  118070. */
  118071. _effects: Array<PostProcess>;
  118072. /**
  118073. * @hidden Internal
  118074. */
  118075. _downscale: ExtractHighlightsPostProcess;
  118076. private _blurX;
  118077. private _blurY;
  118078. private _merge;
  118079. /**
  118080. * The luminance threshold to find bright areas of the image to bloom.
  118081. */
  118082. threshold: number;
  118083. /**
  118084. * The strength of the bloom.
  118085. */
  118086. weight: number;
  118087. /**
  118088. * Specifies the size of the bloom blur kernel, relative to the final output size
  118089. */
  118090. kernel: number;
  118091. /**
  118092. * Creates a new instance of @see BloomEffect
  118093. * @param scene The scene the effect belongs to.
  118094. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118095. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118096. * @param bloomWeight The the strength of bloom.
  118097. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118098. * @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)
  118099. */
  118100. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  118101. /**
  118102. * Disposes each of the internal effects for a given camera.
  118103. * @param camera The camera to dispose the effect on.
  118104. */
  118105. disposeEffects(camera: Camera): void;
  118106. /**
  118107. * @hidden Internal
  118108. */
  118109. _updateEffects(): void;
  118110. /**
  118111. * Internal
  118112. * @returns if all the contained post processes are ready.
  118113. * @hidden
  118114. */
  118115. _isReady(): boolean;
  118116. }
  118117. }
  118118. declare module BABYLON {
  118119. /** @hidden */
  118120. export var chromaticAberrationPixelShader: {
  118121. name: string;
  118122. shader: string;
  118123. };
  118124. }
  118125. declare module BABYLON {
  118126. /**
  118127. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118128. */
  118129. export class ChromaticAberrationPostProcess extends PostProcess {
  118130. /**
  118131. * The amount of seperation of rgb channels (default: 30)
  118132. */
  118133. aberrationAmount: number;
  118134. /**
  118135. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118136. */
  118137. radialIntensity: number;
  118138. /**
  118139. * 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))
  118140. */
  118141. direction: Vector2;
  118142. /**
  118143. * 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))
  118144. */
  118145. centerPosition: Vector2;
  118146. /**
  118147. * Creates a new instance ChromaticAberrationPostProcess
  118148. * @param name The name of the effect.
  118149. * @param screenWidth The width of the screen to apply the effect on.
  118150. * @param screenHeight The height of the screen to apply the effect on.
  118151. * @param options The required width/height ratio to downsize to before computing the render pass.
  118152. * @param camera The camera to apply the render pass to.
  118153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118154. * @param engine The engine which the post process will be applied. (default: current engine)
  118155. * @param reusable If the post process can be reused on the same frame. (default: false)
  118156. * @param textureType Type of textures used when performing the post process. (default: 0)
  118157. * @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)
  118158. */
  118159. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118160. }
  118161. }
  118162. declare module BABYLON {
  118163. /** @hidden */
  118164. export var circleOfConfusionPixelShader: {
  118165. name: string;
  118166. shader: string;
  118167. };
  118168. }
  118169. declare module BABYLON {
  118170. /**
  118171. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118172. */
  118173. export class CircleOfConfusionPostProcess extends PostProcess {
  118174. /**
  118175. * 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.
  118176. */
  118177. lensSize: number;
  118178. /**
  118179. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118180. */
  118181. fStop: number;
  118182. /**
  118183. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118184. */
  118185. focusDistance: number;
  118186. /**
  118187. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  118188. */
  118189. focalLength: number;
  118190. private _depthTexture;
  118191. /**
  118192. * Creates a new instance CircleOfConfusionPostProcess
  118193. * @param name The name of the effect.
  118194. * @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.
  118195. * @param options The required width/height ratio to downsize to before computing the render pass.
  118196. * @param camera The camera to apply the render pass to.
  118197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118198. * @param engine The engine which the post process will be applied. (default: current engine)
  118199. * @param reusable If the post process can be reused on the same frame. (default: false)
  118200. * @param textureType Type of textures used when performing the post process. (default: 0)
  118201. * @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)
  118202. */
  118203. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118204. /**
  118205. * 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.
  118206. */
  118207. depthTexture: RenderTargetTexture;
  118208. }
  118209. }
  118210. declare module BABYLON {
  118211. /** @hidden */
  118212. export var colorCorrectionPixelShader: {
  118213. name: string;
  118214. shader: string;
  118215. };
  118216. }
  118217. declare module BABYLON {
  118218. /**
  118219. *
  118220. * This post-process allows the modification of rendered colors by using
  118221. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118222. *
  118223. * The object needs to be provided an url to a texture containing the color
  118224. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118225. * Use an image editing software to tweak the LUT to match your needs.
  118226. *
  118227. * For an example of a color LUT, see here:
  118228. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118229. * For explanations on color grading, see here:
  118230. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118231. *
  118232. */
  118233. export class ColorCorrectionPostProcess extends PostProcess {
  118234. private _colorTableTexture;
  118235. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118236. }
  118237. }
  118238. declare module BABYLON {
  118239. /** @hidden */
  118240. export var convolutionPixelShader: {
  118241. name: string;
  118242. shader: string;
  118243. };
  118244. }
  118245. declare module BABYLON {
  118246. /**
  118247. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118248. * input texture to perform effects such as edge detection or sharpening
  118249. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118250. */
  118251. export class ConvolutionPostProcess extends PostProcess {
  118252. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118253. kernel: number[];
  118254. /**
  118255. * Creates a new instance ConvolutionPostProcess
  118256. * @param name The name of the effect.
  118257. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  118258. * @param options The required width/height ratio to downsize to before computing the render pass.
  118259. * @param camera The camera to apply the render pass to.
  118260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118261. * @param engine The engine which the post process will be applied. (default: current engine)
  118262. * @param reusable If the post process can be reused on the same frame. (default: false)
  118263. * @param textureType Type of textures used when performing the post process. (default: 0)
  118264. */
  118265. constructor(name: string,
  118266. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118267. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118268. /**
  118269. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118270. */
  118271. static EdgeDetect0Kernel: number[];
  118272. /**
  118273. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118274. */
  118275. static EdgeDetect1Kernel: number[];
  118276. /**
  118277. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118278. */
  118279. static EdgeDetect2Kernel: number[];
  118280. /**
  118281. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118282. */
  118283. static SharpenKernel: number[];
  118284. /**
  118285. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118286. */
  118287. static EmbossKernel: number[];
  118288. /**
  118289. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118290. */
  118291. static GaussianKernel: number[];
  118292. }
  118293. }
  118294. declare module BABYLON {
  118295. /**
  118296. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118297. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118298. * based on samples that have a large difference in distance than the center pixel.
  118299. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118300. */
  118301. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118302. direction: Vector2;
  118303. /**
  118304. * Creates a new instance CircleOfConfusionPostProcess
  118305. * @param name The name of the effect.
  118306. * @param scene The scene the effect belongs to.
  118307. * @param direction The direction the blur should be applied.
  118308. * @param kernel The size of the kernel used to blur.
  118309. * @param options The required width/height ratio to downsize to before computing the render pass.
  118310. * @param camera The camera to apply the render pass to.
  118311. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118312. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118314. * @param engine The engine which the post process will be applied. (default: current engine)
  118315. * @param reusable If the post process can be reused on the same frame. (default: false)
  118316. * @param textureType Type of textures used when performing the post process. (default: 0)
  118317. * @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)
  118318. */
  118319. 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);
  118320. }
  118321. }
  118322. declare module BABYLON {
  118323. /** @hidden */
  118324. export var depthOfFieldMergePixelShader: {
  118325. name: string;
  118326. shader: string;
  118327. };
  118328. }
  118329. declare module BABYLON {
  118330. /**
  118331. * Options to be set when merging outputs from the default pipeline.
  118332. */
  118333. export class DepthOfFieldMergePostProcessOptions {
  118334. /**
  118335. * The original image to merge on top of
  118336. */
  118337. originalFromInput: PostProcess;
  118338. /**
  118339. * Parameters to perform the merge of the depth of field effect
  118340. */
  118341. depthOfField?: {
  118342. circleOfConfusion: PostProcess;
  118343. blurSteps: Array<PostProcess>;
  118344. };
  118345. /**
  118346. * Parameters to perform the merge of bloom effect
  118347. */
  118348. bloom?: {
  118349. blurred: PostProcess;
  118350. weight: number;
  118351. };
  118352. }
  118353. /**
  118354. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118355. */
  118356. export class DepthOfFieldMergePostProcess extends PostProcess {
  118357. private blurSteps;
  118358. /**
  118359. * Creates a new instance of DepthOfFieldMergePostProcess
  118360. * @param name The name of the effect.
  118361. * @param originalFromInput Post process which's input will be used for the merge.
  118362. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118363. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118364. * @param options The required width/height ratio to downsize to before computing the render pass.
  118365. * @param camera The camera to apply the render pass to.
  118366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118367. * @param engine The engine which the post process will be applied. (default: current engine)
  118368. * @param reusable If the post process can be reused on the same frame. (default: false)
  118369. * @param textureType Type of textures used when performing the post process. (default: 0)
  118370. * @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)
  118371. */
  118372. 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);
  118373. /**
  118374. * Updates the effect with the current post process compile time values and recompiles the shader.
  118375. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118376. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118377. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118378. * @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
  118379. * @param onCompiled Called when the shader has been compiled.
  118380. * @param onError Called if there is an error when compiling a shader.
  118381. */
  118382. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118383. }
  118384. }
  118385. declare module BABYLON {
  118386. /**
  118387. * Specifies the level of max blur that should be applied when using the depth of field effect
  118388. */
  118389. export enum DepthOfFieldEffectBlurLevel {
  118390. /**
  118391. * Subtle blur
  118392. */
  118393. Low = 0,
  118394. /**
  118395. * Medium blur
  118396. */
  118397. Medium = 1,
  118398. /**
  118399. * Large blur
  118400. */
  118401. High = 2
  118402. }
  118403. /**
  118404. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118405. */
  118406. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118407. private _circleOfConfusion;
  118408. /**
  118409. * @hidden Internal, blurs from high to low
  118410. */
  118411. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118412. private _depthOfFieldBlurY;
  118413. private _dofMerge;
  118414. /**
  118415. * @hidden Internal post processes in depth of field effect
  118416. */
  118417. _effects: Array<PostProcess>;
  118418. /**
  118419. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118420. */
  118421. focalLength: number;
  118422. /**
  118423. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118424. */
  118425. fStop: number;
  118426. /**
  118427. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118428. */
  118429. focusDistance: number;
  118430. /**
  118431. * 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.
  118432. */
  118433. lensSize: number;
  118434. /**
  118435. * Creates a new instance DepthOfFieldEffect
  118436. * @param scene The scene the effect belongs to.
  118437. * @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.
  118438. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118439. * @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)
  118440. */
  118441. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118442. /**
  118443. * Get the current class name of the current effet
  118444. * @returns "DepthOfFieldEffect"
  118445. */
  118446. getClassName(): string;
  118447. /**
  118448. * 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.
  118449. */
  118450. depthTexture: RenderTargetTexture;
  118451. /**
  118452. * Disposes each of the internal effects for a given camera.
  118453. * @param camera The camera to dispose the effect on.
  118454. */
  118455. disposeEffects(camera: Camera): void;
  118456. /**
  118457. * @hidden Internal
  118458. */
  118459. _updateEffects(): void;
  118460. /**
  118461. * Internal
  118462. * @returns if all the contained post processes are ready.
  118463. * @hidden
  118464. */
  118465. _isReady(): boolean;
  118466. }
  118467. }
  118468. declare module BABYLON {
  118469. /** @hidden */
  118470. export var displayPassPixelShader: {
  118471. name: string;
  118472. shader: string;
  118473. };
  118474. }
  118475. declare module BABYLON {
  118476. /**
  118477. * DisplayPassPostProcess which produces an output the same as it's input
  118478. */
  118479. export class DisplayPassPostProcess extends PostProcess {
  118480. /**
  118481. * Creates the DisplayPassPostProcess
  118482. * @param name The name of the effect.
  118483. * @param options The required width/height ratio to downsize to before computing the render pass.
  118484. * @param camera The camera to apply the render pass to.
  118485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118486. * @param engine The engine which the post process will be applied. (default: current engine)
  118487. * @param reusable If the post process can be reused on the same frame. (default: false)
  118488. */
  118489. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118490. }
  118491. }
  118492. declare module BABYLON {
  118493. /** @hidden */
  118494. export var filterPixelShader: {
  118495. name: string;
  118496. shader: string;
  118497. };
  118498. }
  118499. declare module BABYLON {
  118500. /**
  118501. * Applies a kernel filter to the image
  118502. */
  118503. export class FilterPostProcess extends PostProcess {
  118504. /** The matrix to be applied to the image */
  118505. kernelMatrix: Matrix;
  118506. /**
  118507. *
  118508. * @param name The name of the effect.
  118509. * @param kernelMatrix The matrix to be applied to the image
  118510. * @param options The required width/height ratio to downsize to before computing the render pass.
  118511. * @param camera The camera to apply the render pass to.
  118512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118513. * @param engine The engine which the post process will be applied. (default: current engine)
  118514. * @param reusable If the post process can be reused on the same frame. (default: false)
  118515. */
  118516. constructor(name: string,
  118517. /** The matrix to be applied to the image */
  118518. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118519. }
  118520. }
  118521. declare module BABYLON {
  118522. /** @hidden */
  118523. export var fxaaPixelShader: {
  118524. name: string;
  118525. shader: string;
  118526. };
  118527. }
  118528. declare module BABYLON {
  118529. /** @hidden */
  118530. export var fxaaVertexShader: {
  118531. name: string;
  118532. shader: string;
  118533. };
  118534. }
  118535. declare module BABYLON {
  118536. /**
  118537. * Fxaa post process
  118538. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118539. */
  118540. export class FxaaPostProcess extends PostProcess {
  118541. /** @hidden */
  118542. texelWidth: number;
  118543. /** @hidden */
  118544. texelHeight: number;
  118545. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118546. private _getDefines;
  118547. }
  118548. }
  118549. declare module BABYLON {
  118550. /** @hidden */
  118551. export var grainPixelShader: {
  118552. name: string;
  118553. shader: string;
  118554. };
  118555. }
  118556. declare module BABYLON {
  118557. /**
  118558. * The GrainPostProcess adds noise to the image at mid luminance levels
  118559. */
  118560. export class GrainPostProcess extends PostProcess {
  118561. /**
  118562. * The intensity of the grain added (default: 30)
  118563. */
  118564. intensity: number;
  118565. /**
  118566. * If the grain should be randomized on every frame
  118567. */
  118568. animated: boolean;
  118569. /**
  118570. * Creates a new instance of @see GrainPostProcess
  118571. * @param name The name of the effect.
  118572. * @param options The required width/height ratio to downsize to before computing the render pass.
  118573. * @param camera The camera to apply the render pass to.
  118574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118575. * @param engine The engine which the post process will be applied. (default: current engine)
  118576. * @param reusable If the post process can be reused on the same frame. (default: false)
  118577. * @param textureType Type of textures used when performing the post process. (default: 0)
  118578. * @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)
  118579. */
  118580. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118581. }
  118582. }
  118583. declare module BABYLON {
  118584. /** @hidden */
  118585. export var highlightsPixelShader: {
  118586. name: string;
  118587. shader: string;
  118588. };
  118589. }
  118590. declare module BABYLON {
  118591. /**
  118592. * Extracts highlights from the image
  118593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118594. */
  118595. export class HighlightsPostProcess extends PostProcess {
  118596. /**
  118597. * Extracts highlights from the image
  118598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118599. * @param name The name of the effect.
  118600. * @param options The required width/height ratio to downsize to before computing the render pass.
  118601. * @param camera The camera to apply the render pass to.
  118602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118603. * @param engine The engine which the post process will be applied. (default: current engine)
  118604. * @param reusable If the post process can be reused on the same frame. (default: false)
  118605. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118606. */
  118607. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118608. }
  118609. }
  118610. declare module BABYLON {
  118611. /** @hidden */
  118612. export var mrtFragmentDeclaration: {
  118613. name: string;
  118614. shader: string;
  118615. };
  118616. }
  118617. declare module BABYLON {
  118618. /** @hidden */
  118619. export var geometryPixelShader: {
  118620. name: string;
  118621. shader: string;
  118622. };
  118623. }
  118624. declare module BABYLON {
  118625. /** @hidden */
  118626. export var geometryVertexShader: {
  118627. name: string;
  118628. shader: string;
  118629. };
  118630. }
  118631. declare module BABYLON {
  118632. /** @hidden */
  118633. interface ISavedTransformationMatrix {
  118634. world: Matrix;
  118635. viewProjection: Matrix;
  118636. }
  118637. /**
  118638. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118639. */
  118640. export class GeometryBufferRenderer {
  118641. /**
  118642. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118643. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118644. */
  118645. static readonly POSITION_TEXTURE_TYPE: number;
  118646. /**
  118647. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118648. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118649. */
  118650. static readonly VELOCITY_TEXTURE_TYPE: number;
  118651. /**
  118652. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118653. * in order to compute objects velocities when enableVelocity is set to "true"
  118654. * @hidden
  118655. */
  118656. _previousTransformationMatrices: {
  118657. [index: number]: ISavedTransformationMatrix;
  118658. };
  118659. /**
  118660. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118661. * in order to compute objects velocities when enableVelocity is set to "true"
  118662. * @hidden
  118663. */
  118664. _previousBonesTransformationMatrices: {
  118665. [index: number]: Float32Array;
  118666. };
  118667. /**
  118668. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118669. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118670. */
  118671. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118672. private _scene;
  118673. private _multiRenderTarget;
  118674. private _ratio;
  118675. private _enablePosition;
  118676. private _enableVelocity;
  118677. private _positionIndex;
  118678. private _velocityIndex;
  118679. protected _effect: Effect;
  118680. protected _cachedDefines: string;
  118681. /**
  118682. * Set the render list (meshes to be rendered) used in the G buffer.
  118683. */
  118684. renderList: Mesh[];
  118685. /**
  118686. * Gets wether or not G buffer are supported by the running hardware.
  118687. * This requires draw buffer supports
  118688. */
  118689. readonly isSupported: boolean;
  118690. /**
  118691. * Returns the index of the given texture type in the G-Buffer textures array
  118692. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118693. * @returns the index of the given texture type in the G-Buffer textures array
  118694. */
  118695. getTextureIndex(textureType: number): number;
  118696. /**
  118697. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118698. */
  118699. /**
  118700. * Sets whether or not objects positions are enabled for the G buffer.
  118701. */
  118702. enablePosition: boolean;
  118703. /**
  118704. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118705. */
  118706. /**
  118707. * Sets wether or not objects velocities are enabled for the G buffer.
  118708. */
  118709. enableVelocity: boolean;
  118710. /**
  118711. * Gets the scene associated with the buffer.
  118712. */
  118713. readonly scene: Scene;
  118714. /**
  118715. * Gets the ratio used by the buffer during its creation.
  118716. * How big is the buffer related to the main canvas.
  118717. */
  118718. readonly ratio: number;
  118719. /** @hidden */
  118720. static _SceneComponentInitialization: (scene: Scene) => void;
  118721. /**
  118722. * Creates a new G Buffer for the scene
  118723. * @param scene The scene the buffer belongs to
  118724. * @param ratio How big is the buffer related to the main canvas.
  118725. */
  118726. constructor(scene: Scene, ratio?: number);
  118727. /**
  118728. * Checks wether everything is ready to render a submesh to the G buffer.
  118729. * @param subMesh the submesh to check readiness for
  118730. * @param useInstances is the mesh drawn using instance or not
  118731. * @returns true if ready otherwise false
  118732. */
  118733. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118734. /**
  118735. * Gets the current underlying G Buffer.
  118736. * @returns the buffer
  118737. */
  118738. getGBuffer(): MultiRenderTarget;
  118739. /**
  118740. * Gets the number of samples used to render the buffer (anti aliasing).
  118741. */
  118742. /**
  118743. * Sets the number of samples used to render the buffer (anti aliasing).
  118744. */
  118745. samples: number;
  118746. /**
  118747. * Disposes the renderer and frees up associated resources.
  118748. */
  118749. dispose(): void;
  118750. protected _createRenderTargets(): void;
  118751. private _copyBonesTransformationMatrices;
  118752. }
  118753. }
  118754. declare module BABYLON {
  118755. interface Scene {
  118756. /** @hidden (Backing field) */
  118757. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118758. /**
  118759. * Gets or Sets the current geometry buffer associated to the scene.
  118760. */
  118761. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118762. /**
  118763. * Enables a GeometryBufferRender and associates it with the scene
  118764. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118765. * @returns the GeometryBufferRenderer
  118766. */
  118767. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118768. /**
  118769. * Disables the GeometryBufferRender associated with the scene
  118770. */
  118771. disableGeometryBufferRenderer(): void;
  118772. }
  118773. /**
  118774. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118775. * in several rendering techniques.
  118776. */
  118777. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118778. /**
  118779. * The component name helpful to identify the component in the list of scene components.
  118780. */
  118781. readonly name: string;
  118782. /**
  118783. * The scene the component belongs to.
  118784. */
  118785. scene: Scene;
  118786. /**
  118787. * Creates a new instance of the component for the given scene
  118788. * @param scene Defines the scene to register the component in
  118789. */
  118790. constructor(scene: Scene);
  118791. /**
  118792. * Registers the component in a given scene
  118793. */
  118794. register(): void;
  118795. /**
  118796. * Rebuilds the elements related to this component in case of
  118797. * context lost for instance.
  118798. */
  118799. rebuild(): void;
  118800. /**
  118801. * Disposes the component and the associated ressources
  118802. */
  118803. dispose(): void;
  118804. private _gatherRenderTargets;
  118805. }
  118806. }
  118807. declare module BABYLON {
  118808. /** @hidden */
  118809. export var motionBlurPixelShader: {
  118810. name: string;
  118811. shader: string;
  118812. };
  118813. }
  118814. declare module BABYLON {
  118815. /**
  118816. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118817. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118818. * As an example, all you have to do is to create the post-process:
  118819. * var mb = new BABYLON.MotionBlurPostProcess(
  118820. * 'mb', // The name of the effect.
  118821. * scene, // The scene containing the objects to blur according to their velocity.
  118822. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118823. * camera // The camera to apply the render pass to.
  118824. * );
  118825. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118826. */
  118827. export class MotionBlurPostProcess extends PostProcess {
  118828. /**
  118829. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118830. */
  118831. motionStrength: number;
  118832. /**
  118833. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118834. */
  118835. /**
  118836. * Sets the number of iterations to be used for motion blur quality
  118837. */
  118838. motionBlurSamples: number;
  118839. private _motionBlurSamples;
  118840. private _geometryBufferRenderer;
  118841. /**
  118842. * Creates a new instance MotionBlurPostProcess
  118843. * @param name The name of the effect.
  118844. * @param scene The scene containing the objects to blur according to their velocity.
  118845. * @param options The required width/height ratio to downsize to before computing the render pass.
  118846. * @param camera The camera to apply the render pass to.
  118847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118848. * @param engine The engine which the post process will be applied. (default: current engine)
  118849. * @param reusable If the post process can be reused on the same frame. (default: false)
  118850. * @param textureType Type of textures used when performing the post process. (default: 0)
  118851. * @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)
  118852. */
  118853. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118854. /**
  118855. * Excludes the given skinned mesh from computing bones velocities.
  118856. * 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.
  118857. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118858. */
  118859. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118860. /**
  118861. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118862. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118863. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118864. */
  118865. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118866. /**
  118867. * Disposes the post process.
  118868. * @param camera The camera to dispose the post process on.
  118869. */
  118870. dispose(camera?: Camera): void;
  118871. }
  118872. }
  118873. declare module BABYLON {
  118874. /** @hidden */
  118875. export var refractionPixelShader: {
  118876. name: string;
  118877. shader: string;
  118878. };
  118879. }
  118880. declare module BABYLON {
  118881. /**
  118882. * Post process which applies a refractin texture
  118883. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118884. */
  118885. export class RefractionPostProcess extends PostProcess {
  118886. /** the base color of the refraction (used to taint the rendering) */
  118887. color: Color3;
  118888. /** simulated refraction depth */
  118889. depth: number;
  118890. /** the coefficient of the base color (0 to remove base color tainting) */
  118891. colorLevel: number;
  118892. private _refTexture;
  118893. private _ownRefractionTexture;
  118894. /**
  118895. * Gets or sets the refraction texture
  118896. * Please note that you are responsible for disposing the texture if you set it manually
  118897. */
  118898. refractionTexture: Texture;
  118899. /**
  118900. * Initializes the RefractionPostProcess
  118901. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118902. * @param name The name of the effect.
  118903. * @param refractionTextureUrl Url of the refraction texture to use
  118904. * @param color the base color of the refraction (used to taint the rendering)
  118905. * @param depth simulated refraction depth
  118906. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118907. * @param camera The camera to apply the render pass to.
  118908. * @param options The required width/height ratio to downsize to before computing the render pass.
  118909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118910. * @param engine The engine which the post process will be applied. (default: current engine)
  118911. * @param reusable If the post process can be reused on the same frame. (default: false)
  118912. */
  118913. constructor(name: string, refractionTextureUrl: string,
  118914. /** the base color of the refraction (used to taint the rendering) */
  118915. color: Color3,
  118916. /** simulated refraction depth */
  118917. depth: number,
  118918. /** the coefficient of the base color (0 to remove base color tainting) */
  118919. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118920. /**
  118921. * Disposes of the post process
  118922. * @param camera Camera to dispose post process on
  118923. */
  118924. dispose(camera: Camera): void;
  118925. }
  118926. }
  118927. declare module BABYLON {
  118928. /** @hidden */
  118929. export var sharpenPixelShader: {
  118930. name: string;
  118931. shader: string;
  118932. };
  118933. }
  118934. declare module BABYLON {
  118935. /**
  118936. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118937. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118938. */
  118939. export class SharpenPostProcess extends PostProcess {
  118940. /**
  118941. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118942. */
  118943. colorAmount: number;
  118944. /**
  118945. * How much sharpness should be applied (default: 0.3)
  118946. */
  118947. edgeAmount: number;
  118948. /**
  118949. * Creates a new instance ConvolutionPostProcess
  118950. * @param name The name of the effect.
  118951. * @param options The required width/height ratio to downsize to before computing the render pass.
  118952. * @param camera The camera to apply the render pass to.
  118953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118954. * @param engine The engine which the post process will be applied. (default: current engine)
  118955. * @param reusable If the post process can be reused on the same frame. (default: false)
  118956. * @param textureType Type of textures used when performing the post process. (default: 0)
  118957. * @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)
  118958. */
  118959. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118960. }
  118961. }
  118962. declare module BABYLON {
  118963. /**
  118964. * PostProcessRenderPipeline
  118965. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118966. */
  118967. export class PostProcessRenderPipeline {
  118968. private engine;
  118969. private _renderEffects;
  118970. private _renderEffectsForIsolatedPass;
  118971. /**
  118972. * List of inspectable custom properties (used by the Inspector)
  118973. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118974. */
  118975. inspectableCustomProperties: IInspectable[];
  118976. /**
  118977. * @hidden
  118978. */
  118979. protected _cameras: Camera[];
  118980. /** @hidden */
  118981. _name: string;
  118982. /**
  118983. * Gets pipeline name
  118984. */
  118985. readonly name: string;
  118986. /**
  118987. * Initializes a PostProcessRenderPipeline
  118988. * @param engine engine to add the pipeline to
  118989. * @param name name of the pipeline
  118990. */
  118991. constructor(engine: Engine, name: string);
  118992. /**
  118993. * Gets the class name
  118994. * @returns "PostProcessRenderPipeline"
  118995. */
  118996. getClassName(): string;
  118997. /**
  118998. * If all the render effects in the pipeline are supported
  118999. */
  119000. readonly isSupported: boolean;
  119001. /**
  119002. * Adds an effect to the pipeline
  119003. * @param renderEffect the effect to add
  119004. */
  119005. addEffect(renderEffect: PostProcessRenderEffect): void;
  119006. /** @hidden */
  119007. _rebuild(): void;
  119008. /** @hidden */
  119009. _enableEffect(renderEffectName: string, cameras: Camera): void;
  119010. /** @hidden */
  119011. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  119012. /** @hidden */
  119013. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119014. /** @hidden */
  119015. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119016. /** @hidden */
  119017. _attachCameras(cameras: Camera, unique: boolean): void;
  119018. /** @hidden */
  119019. _attachCameras(cameras: Camera[], unique: boolean): void;
  119020. /** @hidden */
  119021. _detachCameras(cameras: Camera): void;
  119022. /** @hidden */
  119023. _detachCameras(cameras: Nullable<Camera[]>): void;
  119024. /** @hidden */
  119025. _update(): void;
  119026. /** @hidden */
  119027. _reset(): void;
  119028. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  119029. /**
  119030. * Disposes of the pipeline
  119031. */
  119032. dispose(): void;
  119033. }
  119034. }
  119035. declare module BABYLON {
  119036. /**
  119037. * PostProcessRenderPipelineManager class
  119038. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119039. */
  119040. export class PostProcessRenderPipelineManager {
  119041. private _renderPipelines;
  119042. /**
  119043. * Initializes a PostProcessRenderPipelineManager
  119044. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119045. */
  119046. constructor();
  119047. /**
  119048. * Gets the list of supported render pipelines
  119049. */
  119050. readonly supportedPipelines: PostProcessRenderPipeline[];
  119051. /**
  119052. * Adds a pipeline to the manager
  119053. * @param renderPipeline The pipeline to add
  119054. */
  119055. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  119056. /**
  119057. * Attaches a camera to the pipeline
  119058. * @param renderPipelineName The name of the pipeline to attach to
  119059. * @param cameras the camera to attach
  119060. * @param unique if the camera can be attached multiple times to the pipeline
  119061. */
  119062. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  119063. /**
  119064. * Detaches a camera from the pipeline
  119065. * @param renderPipelineName The name of the pipeline to detach from
  119066. * @param cameras the camera to detach
  119067. */
  119068. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  119069. /**
  119070. * Enables an effect by name on a pipeline
  119071. * @param renderPipelineName the name of the pipeline to enable the effect in
  119072. * @param renderEffectName the name of the effect to enable
  119073. * @param cameras the cameras that the effect should be enabled on
  119074. */
  119075. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119076. /**
  119077. * Disables an effect by name on a pipeline
  119078. * @param renderPipelineName the name of the pipeline to disable the effect in
  119079. * @param renderEffectName the name of the effect to disable
  119080. * @param cameras the cameras that the effect should be disabled on
  119081. */
  119082. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119083. /**
  119084. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  119085. */
  119086. update(): void;
  119087. /** @hidden */
  119088. _rebuild(): void;
  119089. /**
  119090. * Disposes of the manager and pipelines
  119091. */
  119092. dispose(): void;
  119093. }
  119094. }
  119095. declare module BABYLON {
  119096. interface Scene {
  119097. /** @hidden (Backing field) */
  119098. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119099. /**
  119100. * Gets the postprocess render pipeline manager
  119101. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119102. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119103. */
  119104. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119105. }
  119106. /**
  119107. * Defines the Render Pipeline scene component responsible to rendering pipelines
  119108. */
  119109. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  119110. /**
  119111. * The component name helpfull to identify the component in the list of scene components.
  119112. */
  119113. readonly name: string;
  119114. /**
  119115. * The scene the component belongs to.
  119116. */
  119117. scene: Scene;
  119118. /**
  119119. * Creates a new instance of the component for the given scene
  119120. * @param scene Defines the scene to register the component in
  119121. */
  119122. constructor(scene: Scene);
  119123. /**
  119124. * Registers the component in a given scene
  119125. */
  119126. register(): void;
  119127. /**
  119128. * Rebuilds the elements related to this component in case of
  119129. * context lost for instance.
  119130. */
  119131. rebuild(): void;
  119132. /**
  119133. * Disposes the component and the associated ressources
  119134. */
  119135. dispose(): void;
  119136. private _gatherRenderTargets;
  119137. }
  119138. }
  119139. declare module BABYLON {
  119140. /**
  119141. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  119142. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119143. */
  119144. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119145. private _scene;
  119146. private _camerasToBeAttached;
  119147. /**
  119148. * ID of the sharpen post process,
  119149. */
  119150. private readonly SharpenPostProcessId;
  119151. /**
  119152. * @ignore
  119153. * ID of the image processing post process;
  119154. */
  119155. readonly ImageProcessingPostProcessId: string;
  119156. /**
  119157. * @ignore
  119158. * ID of the Fast Approximate Anti-Aliasing post process;
  119159. */
  119160. readonly FxaaPostProcessId: string;
  119161. /**
  119162. * ID of the chromatic aberration post process,
  119163. */
  119164. private readonly ChromaticAberrationPostProcessId;
  119165. /**
  119166. * ID of the grain post process
  119167. */
  119168. private readonly GrainPostProcessId;
  119169. /**
  119170. * Sharpen post process which will apply a sharpen convolution to enhance edges
  119171. */
  119172. sharpen: SharpenPostProcess;
  119173. private _sharpenEffect;
  119174. private bloom;
  119175. /**
  119176. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  119177. */
  119178. depthOfField: DepthOfFieldEffect;
  119179. /**
  119180. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119181. */
  119182. fxaa: FxaaPostProcess;
  119183. /**
  119184. * Image post processing pass used to perform operations such as tone mapping or color grading.
  119185. */
  119186. imageProcessing: ImageProcessingPostProcess;
  119187. /**
  119188. * Chromatic aberration post process which will shift rgb colors in the image
  119189. */
  119190. chromaticAberration: ChromaticAberrationPostProcess;
  119191. private _chromaticAberrationEffect;
  119192. /**
  119193. * Grain post process which add noise to the image
  119194. */
  119195. grain: GrainPostProcess;
  119196. private _grainEffect;
  119197. /**
  119198. * Glow post process which adds a glow to emissive areas of the image
  119199. */
  119200. private _glowLayer;
  119201. /**
  119202. * Animations which can be used to tweak settings over a period of time
  119203. */
  119204. animations: Animation[];
  119205. private _imageProcessingConfigurationObserver;
  119206. private _sharpenEnabled;
  119207. private _bloomEnabled;
  119208. private _depthOfFieldEnabled;
  119209. private _depthOfFieldBlurLevel;
  119210. private _fxaaEnabled;
  119211. private _imageProcessingEnabled;
  119212. private _defaultPipelineTextureType;
  119213. private _bloomScale;
  119214. private _chromaticAberrationEnabled;
  119215. private _grainEnabled;
  119216. private _buildAllowed;
  119217. /**
  119218. * Gets active scene
  119219. */
  119220. readonly scene: Scene;
  119221. /**
  119222. * Enable or disable the sharpen process from the pipeline
  119223. */
  119224. sharpenEnabled: boolean;
  119225. private _resizeObserver;
  119226. private _hardwareScaleLevel;
  119227. private _bloomKernel;
  119228. /**
  119229. * Specifies the size of the bloom blur kernel, relative to the final output size
  119230. */
  119231. bloomKernel: number;
  119232. /**
  119233. * Specifies the weight of the bloom in the final rendering
  119234. */
  119235. private _bloomWeight;
  119236. /**
  119237. * Specifies the luma threshold for the area that will be blurred by the bloom
  119238. */
  119239. private _bloomThreshold;
  119240. private _hdr;
  119241. /**
  119242. * The strength of the bloom.
  119243. */
  119244. bloomWeight: number;
  119245. /**
  119246. * The strength of the bloom.
  119247. */
  119248. bloomThreshold: number;
  119249. /**
  119250. * The scale of the bloom, lower value will provide better performance.
  119251. */
  119252. bloomScale: number;
  119253. /**
  119254. * Enable or disable the bloom from the pipeline
  119255. */
  119256. bloomEnabled: boolean;
  119257. private _rebuildBloom;
  119258. /**
  119259. * If the depth of field is enabled.
  119260. */
  119261. depthOfFieldEnabled: boolean;
  119262. /**
  119263. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119264. */
  119265. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  119266. /**
  119267. * If the anti aliasing is enabled.
  119268. */
  119269. fxaaEnabled: boolean;
  119270. private _samples;
  119271. /**
  119272. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119273. */
  119274. samples: number;
  119275. /**
  119276. * If image processing is enabled.
  119277. */
  119278. imageProcessingEnabled: boolean;
  119279. /**
  119280. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119281. */
  119282. glowLayerEnabled: boolean;
  119283. /**
  119284. * Gets the glow layer (or null if not defined)
  119285. */
  119286. readonly glowLayer: Nullable<GlowLayer>;
  119287. /**
  119288. * Enable or disable the chromaticAberration process from the pipeline
  119289. */
  119290. chromaticAberrationEnabled: boolean;
  119291. /**
  119292. * Enable or disable the grain process from the pipeline
  119293. */
  119294. grainEnabled: boolean;
  119295. /**
  119296. * @constructor
  119297. * @param name - The rendering pipeline name (default: "")
  119298. * @param hdr - If high dynamic range textures should be used (default: true)
  119299. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119300. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119301. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119302. */
  119303. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119304. /**
  119305. * Get the class name
  119306. * @returns "DefaultRenderingPipeline"
  119307. */
  119308. getClassName(): string;
  119309. /**
  119310. * Force the compilation of the entire pipeline.
  119311. */
  119312. prepare(): void;
  119313. private _hasCleared;
  119314. private _prevPostProcess;
  119315. private _prevPrevPostProcess;
  119316. private _setAutoClearAndTextureSharing;
  119317. private _depthOfFieldSceneObserver;
  119318. private _buildPipeline;
  119319. private _disposePostProcesses;
  119320. /**
  119321. * Adds a camera to the pipeline
  119322. * @param camera the camera to be added
  119323. */
  119324. addCamera(camera: Camera): void;
  119325. /**
  119326. * Removes a camera from the pipeline
  119327. * @param camera the camera to remove
  119328. */
  119329. removeCamera(camera: Camera): void;
  119330. /**
  119331. * Dispose of the pipeline and stop all post processes
  119332. */
  119333. dispose(): void;
  119334. /**
  119335. * Serialize the rendering pipeline (Used when exporting)
  119336. * @returns the serialized object
  119337. */
  119338. serialize(): any;
  119339. /**
  119340. * Parse the serialized pipeline
  119341. * @param source Source pipeline.
  119342. * @param scene The scene to load the pipeline to.
  119343. * @param rootUrl The URL of the serialized pipeline.
  119344. * @returns An instantiated pipeline from the serialized object.
  119345. */
  119346. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119347. }
  119348. }
  119349. declare module BABYLON {
  119350. /** @hidden */
  119351. export var lensHighlightsPixelShader: {
  119352. name: string;
  119353. shader: string;
  119354. };
  119355. }
  119356. declare module BABYLON {
  119357. /** @hidden */
  119358. export var depthOfFieldPixelShader: {
  119359. name: string;
  119360. shader: string;
  119361. };
  119362. }
  119363. declare module BABYLON {
  119364. /**
  119365. * BABYLON.JS Chromatic Aberration GLSL Shader
  119366. * Author: Olivier Guyot
  119367. * Separates very slightly R, G and B colors on the edges of the screen
  119368. * Inspired by Francois Tarlier & Martins Upitis
  119369. */
  119370. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119371. /**
  119372. * @ignore
  119373. * The chromatic aberration PostProcess id in the pipeline
  119374. */
  119375. LensChromaticAberrationEffect: string;
  119376. /**
  119377. * @ignore
  119378. * The highlights enhancing PostProcess id in the pipeline
  119379. */
  119380. HighlightsEnhancingEffect: string;
  119381. /**
  119382. * @ignore
  119383. * The depth-of-field PostProcess id in the pipeline
  119384. */
  119385. LensDepthOfFieldEffect: string;
  119386. private _scene;
  119387. private _depthTexture;
  119388. private _grainTexture;
  119389. private _chromaticAberrationPostProcess;
  119390. private _highlightsPostProcess;
  119391. private _depthOfFieldPostProcess;
  119392. private _edgeBlur;
  119393. private _grainAmount;
  119394. private _chromaticAberration;
  119395. private _distortion;
  119396. private _highlightsGain;
  119397. private _highlightsThreshold;
  119398. private _dofDistance;
  119399. private _dofAperture;
  119400. private _dofDarken;
  119401. private _dofPentagon;
  119402. private _blurNoise;
  119403. /**
  119404. * @constructor
  119405. *
  119406. * Effect parameters are as follow:
  119407. * {
  119408. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119409. * edge_blur: number; // from 0 to x (1 for realism)
  119410. * distortion: number; // from 0 to x (1 for realism)
  119411. * grain_amount: number; // from 0 to 1
  119412. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119413. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119414. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119415. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119416. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119417. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119418. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119419. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119420. * }
  119421. * Note: if an effect parameter is unset, effect is disabled
  119422. *
  119423. * @param name The rendering pipeline name
  119424. * @param parameters - An object containing all parameters (see above)
  119425. * @param scene The scene linked to this pipeline
  119426. * @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)
  119427. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119428. */
  119429. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119430. /**
  119431. * Get the class name
  119432. * @returns "LensRenderingPipeline"
  119433. */
  119434. getClassName(): string;
  119435. /**
  119436. * Gets associated scene
  119437. */
  119438. readonly scene: Scene;
  119439. /**
  119440. * Gets or sets the edge blur
  119441. */
  119442. edgeBlur: number;
  119443. /**
  119444. * Gets or sets the grain amount
  119445. */
  119446. grainAmount: number;
  119447. /**
  119448. * Gets or sets the chromatic aberration amount
  119449. */
  119450. chromaticAberration: number;
  119451. /**
  119452. * Gets or sets the depth of field aperture
  119453. */
  119454. dofAperture: number;
  119455. /**
  119456. * Gets or sets the edge distortion
  119457. */
  119458. edgeDistortion: number;
  119459. /**
  119460. * Gets or sets the depth of field distortion
  119461. */
  119462. dofDistortion: number;
  119463. /**
  119464. * Gets or sets the darken out of focus amount
  119465. */
  119466. darkenOutOfFocus: number;
  119467. /**
  119468. * Gets or sets a boolean indicating if blur noise is enabled
  119469. */
  119470. blurNoise: boolean;
  119471. /**
  119472. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119473. */
  119474. pentagonBokeh: boolean;
  119475. /**
  119476. * Gets or sets the highlight grain amount
  119477. */
  119478. highlightsGain: number;
  119479. /**
  119480. * Gets or sets the highlight threshold
  119481. */
  119482. highlightsThreshold: number;
  119483. /**
  119484. * Sets the amount of blur at the edges
  119485. * @param amount blur amount
  119486. */
  119487. setEdgeBlur(amount: number): void;
  119488. /**
  119489. * Sets edge blur to 0
  119490. */
  119491. disableEdgeBlur(): void;
  119492. /**
  119493. * Sets the amout of grain
  119494. * @param amount Amount of grain
  119495. */
  119496. setGrainAmount(amount: number): void;
  119497. /**
  119498. * Set grain amount to 0
  119499. */
  119500. disableGrain(): void;
  119501. /**
  119502. * Sets the chromatic aberration amount
  119503. * @param amount amount of chromatic aberration
  119504. */
  119505. setChromaticAberration(amount: number): void;
  119506. /**
  119507. * Sets chromatic aberration amount to 0
  119508. */
  119509. disableChromaticAberration(): void;
  119510. /**
  119511. * Sets the EdgeDistortion amount
  119512. * @param amount amount of EdgeDistortion
  119513. */
  119514. setEdgeDistortion(amount: number): void;
  119515. /**
  119516. * Sets edge distortion to 0
  119517. */
  119518. disableEdgeDistortion(): void;
  119519. /**
  119520. * Sets the FocusDistance amount
  119521. * @param amount amount of FocusDistance
  119522. */
  119523. setFocusDistance(amount: number): void;
  119524. /**
  119525. * Disables depth of field
  119526. */
  119527. disableDepthOfField(): void;
  119528. /**
  119529. * Sets the Aperture amount
  119530. * @param amount amount of Aperture
  119531. */
  119532. setAperture(amount: number): void;
  119533. /**
  119534. * Sets the DarkenOutOfFocus amount
  119535. * @param amount amount of DarkenOutOfFocus
  119536. */
  119537. setDarkenOutOfFocus(amount: number): void;
  119538. private _pentagonBokehIsEnabled;
  119539. /**
  119540. * Creates a pentagon bokeh effect
  119541. */
  119542. enablePentagonBokeh(): void;
  119543. /**
  119544. * Disables the pentagon bokeh effect
  119545. */
  119546. disablePentagonBokeh(): void;
  119547. /**
  119548. * Enables noise blur
  119549. */
  119550. enableNoiseBlur(): void;
  119551. /**
  119552. * Disables noise blur
  119553. */
  119554. disableNoiseBlur(): void;
  119555. /**
  119556. * Sets the HighlightsGain amount
  119557. * @param amount amount of HighlightsGain
  119558. */
  119559. setHighlightsGain(amount: number): void;
  119560. /**
  119561. * Sets the HighlightsThreshold amount
  119562. * @param amount amount of HighlightsThreshold
  119563. */
  119564. setHighlightsThreshold(amount: number): void;
  119565. /**
  119566. * Disables highlights
  119567. */
  119568. disableHighlights(): void;
  119569. /**
  119570. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119571. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119572. */
  119573. dispose(disableDepthRender?: boolean): void;
  119574. private _createChromaticAberrationPostProcess;
  119575. private _createHighlightsPostProcess;
  119576. private _createDepthOfFieldPostProcess;
  119577. private _createGrainTexture;
  119578. }
  119579. }
  119580. declare module BABYLON {
  119581. /** @hidden */
  119582. export var ssao2PixelShader: {
  119583. name: string;
  119584. shader: string;
  119585. };
  119586. }
  119587. declare module BABYLON {
  119588. /** @hidden */
  119589. export var ssaoCombinePixelShader: {
  119590. name: string;
  119591. shader: string;
  119592. };
  119593. }
  119594. declare module BABYLON {
  119595. /**
  119596. * Render pipeline to produce ssao effect
  119597. */
  119598. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119599. /**
  119600. * @ignore
  119601. * The PassPostProcess id in the pipeline that contains the original scene color
  119602. */
  119603. SSAOOriginalSceneColorEffect: string;
  119604. /**
  119605. * @ignore
  119606. * The SSAO PostProcess id in the pipeline
  119607. */
  119608. SSAORenderEffect: string;
  119609. /**
  119610. * @ignore
  119611. * The horizontal blur PostProcess id in the pipeline
  119612. */
  119613. SSAOBlurHRenderEffect: string;
  119614. /**
  119615. * @ignore
  119616. * The vertical blur PostProcess id in the pipeline
  119617. */
  119618. SSAOBlurVRenderEffect: string;
  119619. /**
  119620. * @ignore
  119621. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119622. */
  119623. SSAOCombineRenderEffect: string;
  119624. /**
  119625. * The output strength of the SSAO post-process. Default value is 1.0.
  119626. */
  119627. totalStrength: number;
  119628. /**
  119629. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119630. */
  119631. maxZ: number;
  119632. /**
  119633. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119634. */
  119635. minZAspect: number;
  119636. private _samples;
  119637. /**
  119638. * Number of samples used for the SSAO calculations. Default value is 8
  119639. */
  119640. samples: number;
  119641. private _textureSamples;
  119642. /**
  119643. * Number of samples to use for antialiasing
  119644. */
  119645. textureSamples: number;
  119646. /**
  119647. * Ratio object used for SSAO ratio and blur ratio
  119648. */
  119649. private _ratio;
  119650. /**
  119651. * Dynamically generated sphere sampler.
  119652. */
  119653. private _sampleSphere;
  119654. /**
  119655. * Blur filter offsets
  119656. */
  119657. private _samplerOffsets;
  119658. private _expensiveBlur;
  119659. /**
  119660. * If bilateral blur should be used
  119661. */
  119662. expensiveBlur: boolean;
  119663. /**
  119664. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119665. */
  119666. radius: number;
  119667. /**
  119668. * The base color of the SSAO post-process
  119669. * The final result is "base + ssao" between [0, 1]
  119670. */
  119671. base: number;
  119672. /**
  119673. * Support test.
  119674. */
  119675. static readonly IsSupported: boolean;
  119676. private _scene;
  119677. private _depthTexture;
  119678. private _normalTexture;
  119679. private _randomTexture;
  119680. private _originalColorPostProcess;
  119681. private _ssaoPostProcess;
  119682. private _blurHPostProcess;
  119683. private _blurVPostProcess;
  119684. private _ssaoCombinePostProcess;
  119685. private _firstUpdate;
  119686. /**
  119687. * Gets active scene
  119688. */
  119689. readonly scene: Scene;
  119690. /**
  119691. * @constructor
  119692. * @param name The rendering pipeline name
  119693. * @param scene The scene linked to this pipeline
  119694. * @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 }
  119695. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119696. */
  119697. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119698. /**
  119699. * Get the class name
  119700. * @returns "SSAO2RenderingPipeline"
  119701. */
  119702. getClassName(): string;
  119703. /**
  119704. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119705. */
  119706. dispose(disableGeometryBufferRenderer?: boolean): void;
  119707. private _createBlurPostProcess;
  119708. /** @hidden */
  119709. _rebuild(): void;
  119710. private _bits;
  119711. private _radicalInverse_VdC;
  119712. private _hammersley;
  119713. private _hemisphereSample_uniform;
  119714. private _generateHemisphere;
  119715. private _createSSAOPostProcess;
  119716. private _createSSAOCombinePostProcess;
  119717. private _createRandomTexture;
  119718. /**
  119719. * Serialize the rendering pipeline (Used when exporting)
  119720. * @returns the serialized object
  119721. */
  119722. serialize(): any;
  119723. /**
  119724. * Parse the serialized pipeline
  119725. * @param source Source pipeline.
  119726. * @param scene The scene to load the pipeline to.
  119727. * @param rootUrl The URL of the serialized pipeline.
  119728. * @returns An instantiated pipeline from the serialized object.
  119729. */
  119730. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119731. }
  119732. }
  119733. declare module BABYLON {
  119734. /** @hidden */
  119735. export var ssaoPixelShader: {
  119736. name: string;
  119737. shader: string;
  119738. };
  119739. }
  119740. declare module BABYLON {
  119741. /**
  119742. * Render pipeline to produce ssao effect
  119743. */
  119744. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119745. /**
  119746. * @ignore
  119747. * The PassPostProcess id in the pipeline that contains the original scene color
  119748. */
  119749. SSAOOriginalSceneColorEffect: string;
  119750. /**
  119751. * @ignore
  119752. * The SSAO PostProcess id in the pipeline
  119753. */
  119754. SSAORenderEffect: string;
  119755. /**
  119756. * @ignore
  119757. * The horizontal blur PostProcess id in the pipeline
  119758. */
  119759. SSAOBlurHRenderEffect: string;
  119760. /**
  119761. * @ignore
  119762. * The vertical blur PostProcess id in the pipeline
  119763. */
  119764. SSAOBlurVRenderEffect: string;
  119765. /**
  119766. * @ignore
  119767. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119768. */
  119769. SSAOCombineRenderEffect: string;
  119770. /**
  119771. * The output strength of the SSAO post-process. Default value is 1.0.
  119772. */
  119773. totalStrength: number;
  119774. /**
  119775. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119776. */
  119777. radius: number;
  119778. /**
  119779. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119780. * Must not be equal to fallOff and superior to fallOff.
  119781. * Default value is 0.0075
  119782. */
  119783. area: number;
  119784. /**
  119785. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119786. * Must not be equal to area and inferior to area.
  119787. * Default value is 0.000001
  119788. */
  119789. fallOff: number;
  119790. /**
  119791. * The base color of the SSAO post-process
  119792. * The final result is "base + ssao" between [0, 1]
  119793. */
  119794. base: number;
  119795. private _scene;
  119796. private _depthTexture;
  119797. private _randomTexture;
  119798. private _originalColorPostProcess;
  119799. private _ssaoPostProcess;
  119800. private _blurHPostProcess;
  119801. private _blurVPostProcess;
  119802. private _ssaoCombinePostProcess;
  119803. private _firstUpdate;
  119804. /**
  119805. * Gets active scene
  119806. */
  119807. readonly scene: Scene;
  119808. /**
  119809. * @constructor
  119810. * @param name - The rendering pipeline name
  119811. * @param scene - The scene linked to this pipeline
  119812. * @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 }
  119813. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119814. */
  119815. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119816. /**
  119817. * Get the class name
  119818. * @returns "SSAORenderingPipeline"
  119819. */
  119820. getClassName(): string;
  119821. /**
  119822. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119823. */
  119824. dispose(disableDepthRender?: boolean): void;
  119825. private _createBlurPostProcess;
  119826. /** @hidden */
  119827. _rebuild(): void;
  119828. private _createSSAOPostProcess;
  119829. private _createSSAOCombinePostProcess;
  119830. private _createRandomTexture;
  119831. }
  119832. }
  119833. declare module BABYLON {
  119834. /** @hidden */
  119835. export var standardPixelShader: {
  119836. name: string;
  119837. shader: string;
  119838. };
  119839. }
  119840. declare module BABYLON {
  119841. /**
  119842. * Standard rendering pipeline
  119843. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119844. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119845. */
  119846. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119847. /**
  119848. * Public members
  119849. */
  119850. /**
  119851. * Post-process which contains the original scene color before the pipeline applies all the effects
  119852. */
  119853. originalPostProcess: Nullable<PostProcess>;
  119854. /**
  119855. * Post-process used to down scale an image x4
  119856. */
  119857. downSampleX4PostProcess: Nullable<PostProcess>;
  119858. /**
  119859. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119860. */
  119861. brightPassPostProcess: Nullable<PostProcess>;
  119862. /**
  119863. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119864. */
  119865. blurHPostProcesses: PostProcess[];
  119866. /**
  119867. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119868. */
  119869. blurVPostProcesses: PostProcess[];
  119870. /**
  119871. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119872. */
  119873. textureAdderPostProcess: Nullable<PostProcess>;
  119874. /**
  119875. * Post-process used to create volumetric lighting effect
  119876. */
  119877. volumetricLightPostProcess: Nullable<PostProcess>;
  119878. /**
  119879. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119880. */
  119881. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119882. /**
  119883. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119884. */
  119885. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119886. /**
  119887. * Post-process used to merge the volumetric light effect and the real scene color
  119888. */
  119889. volumetricLightMergePostProces: Nullable<PostProcess>;
  119890. /**
  119891. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119892. */
  119893. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119894. /**
  119895. * Base post-process used to calculate the average luminance of the final image for HDR
  119896. */
  119897. luminancePostProcess: Nullable<PostProcess>;
  119898. /**
  119899. * Post-processes used to create down sample post-processes in order to get
  119900. * the average luminance of the final image for HDR
  119901. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119902. */
  119903. luminanceDownSamplePostProcesses: PostProcess[];
  119904. /**
  119905. * Post-process used to create a HDR effect (light adaptation)
  119906. */
  119907. hdrPostProcess: Nullable<PostProcess>;
  119908. /**
  119909. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119910. */
  119911. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119912. /**
  119913. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119914. */
  119915. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119916. /**
  119917. * Post-process used to merge the final HDR post-process and the real scene color
  119918. */
  119919. hdrFinalPostProcess: Nullable<PostProcess>;
  119920. /**
  119921. * Post-process used to create a lens flare effect
  119922. */
  119923. lensFlarePostProcess: Nullable<PostProcess>;
  119924. /**
  119925. * Post-process that merges the result of the lens flare post-process and the real scene color
  119926. */
  119927. lensFlareComposePostProcess: Nullable<PostProcess>;
  119928. /**
  119929. * Post-process used to create a motion blur effect
  119930. */
  119931. motionBlurPostProcess: Nullable<PostProcess>;
  119932. /**
  119933. * Post-process used to create a depth of field effect
  119934. */
  119935. depthOfFieldPostProcess: Nullable<PostProcess>;
  119936. /**
  119937. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119938. */
  119939. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119940. /**
  119941. * Represents the brightness threshold in order to configure the illuminated surfaces
  119942. */
  119943. brightThreshold: number;
  119944. /**
  119945. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119946. */
  119947. blurWidth: number;
  119948. /**
  119949. * Sets if the blur for highlighted surfaces must be only horizontal
  119950. */
  119951. horizontalBlur: boolean;
  119952. /**
  119953. * Gets the overall exposure used by the pipeline
  119954. */
  119955. /**
  119956. * Sets the overall exposure used by the pipeline
  119957. */
  119958. exposure: number;
  119959. /**
  119960. * Texture used typically to simulate "dirty" on camera lens
  119961. */
  119962. lensTexture: Nullable<Texture>;
  119963. /**
  119964. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119965. */
  119966. volumetricLightCoefficient: number;
  119967. /**
  119968. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119969. */
  119970. volumetricLightPower: number;
  119971. /**
  119972. * Used the set the blur intensity to smooth the volumetric lights
  119973. */
  119974. volumetricLightBlurScale: number;
  119975. /**
  119976. * Light (spot or directional) used to generate the volumetric lights rays
  119977. * The source light must have a shadow generate so the pipeline can get its
  119978. * depth map
  119979. */
  119980. sourceLight: Nullable<SpotLight | DirectionalLight>;
  119981. /**
  119982. * For eye adaptation, represents the minimum luminance the eye can see
  119983. */
  119984. hdrMinimumLuminance: number;
  119985. /**
  119986. * For eye adaptation, represents the decrease luminance speed
  119987. */
  119988. hdrDecreaseRate: number;
  119989. /**
  119990. * For eye adaptation, represents the increase luminance speed
  119991. */
  119992. hdrIncreaseRate: number;
  119993. /**
  119994. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119995. */
  119996. /**
  119997. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119998. */
  119999. hdrAutoExposure: boolean;
  120000. /**
  120001. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120002. */
  120003. lensColorTexture: Nullable<Texture>;
  120004. /**
  120005. * The overall strengh for the lens flare effect
  120006. */
  120007. lensFlareStrength: number;
  120008. /**
  120009. * Dispersion coefficient for lens flare ghosts
  120010. */
  120011. lensFlareGhostDispersal: number;
  120012. /**
  120013. * Main lens flare halo width
  120014. */
  120015. lensFlareHaloWidth: number;
  120016. /**
  120017. * Based on the lens distortion effect, defines how much the lens flare result
  120018. * is distorted
  120019. */
  120020. lensFlareDistortionStrength: number;
  120021. /**
  120022. * Lens star texture must be used to simulate rays on the flares and is available
  120023. * in the documentation
  120024. */
  120025. lensStarTexture: Nullable<Texture>;
  120026. /**
  120027. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120028. * flare effect by taking account of the dirt texture
  120029. */
  120030. lensFlareDirtTexture: Nullable<Texture>;
  120031. /**
  120032. * Represents the focal length for the depth of field effect
  120033. */
  120034. depthOfFieldDistance: number;
  120035. /**
  120036. * Represents the blur intensity for the blurred part of the depth of field effect
  120037. */
  120038. depthOfFieldBlurWidth: number;
  120039. /**
  120040. * Gets how much the image is blurred by the movement while using the motion blur post-process
  120041. */
  120042. /**
  120043. * Sets how much the image is blurred by the movement while using the motion blur post-process
  120044. */
  120045. motionStrength: number;
  120046. /**
  120047. * Gets wether or not the motion blur post-process is object based or screen based.
  120048. */
  120049. /**
  120050. * Sets wether or not the motion blur post-process should be object based or screen based
  120051. */
  120052. objectBasedMotionBlur: boolean;
  120053. /**
  120054. * List of animations for the pipeline (IAnimatable implementation)
  120055. */
  120056. animations: Animation[];
  120057. /**
  120058. * Private members
  120059. */
  120060. private _scene;
  120061. private _currentDepthOfFieldSource;
  120062. private _basePostProcess;
  120063. private _fixedExposure;
  120064. private _currentExposure;
  120065. private _hdrAutoExposure;
  120066. private _hdrCurrentLuminance;
  120067. private _motionStrength;
  120068. private _isObjectBasedMotionBlur;
  120069. private _floatTextureType;
  120070. private _ratio;
  120071. private _bloomEnabled;
  120072. private _depthOfFieldEnabled;
  120073. private _vlsEnabled;
  120074. private _lensFlareEnabled;
  120075. private _hdrEnabled;
  120076. private _motionBlurEnabled;
  120077. private _fxaaEnabled;
  120078. private _motionBlurSamples;
  120079. private _volumetricLightStepsCount;
  120080. private _samples;
  120081. /**
  120082. * @ignore
  120083. * Specifies if the bloom pipeline is enabled
  120084. */
  120085. BloomEnabled: boolean;
  120086. /**
  120087. * @ignore
  120088. * Specifies if the depth of field pipeline is enabed
  120089. */
  120090. DepthOfFieldEnabled: boolean;
  120091. /**
  120092. * @ignore
  120093. * Specifies if the lens flare pipeline is enabed
  120094. */
  120095. LensFlareEnabled: boolean;
  120096. /**
  120097. * @ignore
  120098. * Specifies if the HDR pipeline is enabled
  120099. */
  120100. HDREnabled: boolean;
  120101. /**
  120102. * @ignore
  120103. * Specifies if the volumetric lights scattering effect is enabled
  120104. */
  120105. VLSEnabled: boolean;
  120106. /**
  120107. * @ignore
  120108. * Specifies if the motion blur effect is enabled
  120109. */
  120110. MotionBlurEnabled: boolean;
  120111. /**
  120112. * Specifies if anti-aliasing is enabled
  120113. */
  120114. fxaaEnabled: boolean;
  120115. /**
  120116. * Specifies the number of steps used to calculate the volumetric lights
  120117. * Typically in interval [50, 200]
  120118. */
  120119. volumetricLightStepsCount: number;
  120120. /**
  120121. * Specifies the number of samples used for the motion blur effect
  120122. * Typically in interval [16, 64]
  120123. */
  120124. motionBlurSamples: number;
  120125. /**
  120126. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120127. */
  120128. samples: number;
  120129. /**
  120130. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120131. * @constructor
  120132. * @param name The rendering pipeline name
  120133. * @param scene The scene linked to this pipeline
  120134. * @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)
  120135. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120136. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120137. */
  120138. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  120139. private _buildPipeline;
  120140. private _createDownSampleX4PostProcess;
  120141. private _createBrightPassPostProcess;
  120142. private _createBlurPostProcesses;
  120143. private _createTextureAdderPostProcess;
  120144. private _createVolumetricLightPostProcess;
  120145. private _createLuminancePostProcesses;
  120146. private _createHdrPostProcess;
  120147. private _createLensFlarePostProcess;
  120148. private _createDepthOfFieldPostProcess;
  120149. private _createMotionBlurPostProcess;
  120150. private _getDepthTexture;
  120151. private _disposePostProcesses;
  120152. /**
  120153. * Dispose of the pipeline and stop all post processes
  120154. */
  120155. dispose(): void;
  120156. /**
  120157. * Serialize the rendering pipeline (Used when exporting)
  120158. * @returns the serialized object
  120159. */
  120160. serialize(): any;
  120161. /**
  120162. * Parse the serialized pipeline
  120163. * @param source Source pipeline.
  120164. * @param scene The scene to load the pipeline to.
  120165. * @param rootUrl The URL of the serialized pipeline.
  120166. * @returns An instantiated pipeline from the serialized object.
  120167. */
  120168. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  120169. /**
  120170. * Luminance steps
  120171. */
  120172. static LuminanceSteps: number;
  120173. }
  120174. }
  120175. declare module BABYLON {
  120176. /** @hidden */
  120177. export var tonemapPixelShader: {
  120178. name: string;
  120179. shader: string;
  120180. };
  120181. }
  120182. declare module BABYLON {
  120183. /** Defines operator used for tonemapping */
  120184. export enum TonemappingOperator {
  120185. /** Hable */
  120186. Hable = 0,
  120187. /** Reinhard */
  120188. Reinhard = 1,
  120189. /** HejiDawson */
  120190. HejiDawson = 2,
  120191. /** Photographic */
  120192. Photographic = 3
  120193. }
  120194. /**
  120195. * Defines a post process to apply tone mapping
  120196. */
  120197. export class TonemapPostProcess extends PostProcess {
  120198. private _operator;
  120199. /** Defines the required exposure adjustement */
  120200. exposureAdjustment: number;
  120201. /**
  120202. * Creates a new TonemapPostProcess
  120203. * @param name defines the name of the postprocess
  120204. * @param _operator defines the operator to use
  120205. * @param exposureAdjustment defines the required exposure adjustement
  120206. * @param camera defines the camera to use (can be null)
  120207. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120208. * @param engine defines the hosting engine (can be ignore if camera is set)
  120209. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120210. */
  120211. constructor(name: string, _operator: TonemappingOperator,
  120212. /** Defines the required exposure adjustement */
  120213. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  120214. }
  120215. }
  120216. declare module BABYLON {
  120217. /** @hidden */
  120218. export var depthVertexShader: {
  120219. name: string;
  120220. shader: string;
  120221. };
  120222. }
  120223. declare module BABYLON {
  120224. /** @hidden */
  120225. export var volumetricLightScatteringPixelShader: {
  120226. name: string;
  120227. shader: string;
  120228. };
  120229. }
  120230. declare module BABYLON {
  120231. /** @hidden */
  120232. export var volumetricLightScatteringPassPixelShader: {
  120233. name: string;
  120234. shader: string;
  120235. };
  120236. }
  120237. declare module BABYLON {
  120238. /**
  120239. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120240. */
  120241. export class VolumetricLightScatteringPostProcess extends PostProcess {
  120242. private _volumetricLightScatteringPass;
  120243. private _volumetricLightScatteringRTT;
  120244. private _viewPort;
  120245. private _screenCoordinates;
  120246. private _cachedDefines;
  120247. /**
  120248. * If not undefined, the mesh position is computed from the attached node position
  120249. */
  120250. attachedNode: {
  120251. position: Vector3;
  120252. };
  120253. /**
  120254. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120255. */
  120256. customMeshPosition: Vector3;
  120257. /**
  120258. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120259. */
  120260. useCustomMeshPosition: boolean;
  120261. /**
  120262. * If the post-process should inverse the light scattering direction
  120263. */
  120264. invert: boolean;
  120265. /**
  120266. * The internal mesh used by the post-process
  120267. */
  120268. mesh: Mesh;
  120269. /**
  120270. * @hidden
  120271. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120272. */
  120273. useDiffuseColor: boolean;
  120274. /**
  120275. * Array containing the excluded meshes not rendered in the internal pass
  120276. */
  120277. excludedMeshes: AbstractMesh[];
  120278. /**
  120279. * Controls the overall intensity of the post-process
  120280. */
  120281. exposure: number;
  120282. /**
  120283. * Dissipates each sample's contribution in range [0, 1]
  120284. */
  120285. decay: number;
  120286. /**
  120287. * Controls the overall intensity of each sample
  120288. */
  120289. weight: number;
  120290. /**
  120291. * Controls the density of each sample
  120292. */
  120293. density: number;
  120294. /**
  120295. * @constructor
  120296. * @param name The post-process name
  120297. * @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)
  120298. * @param camera The camera that the post-process will be attached to
  120299. * @param mesh The mesh used to create the light scattering
  120300. * @param samples The post-process quality, default 100
  120301. * @param samplingModeThe post-process filtering mode
  120302. * @param engine The babylon engine
  120303. * @param reusable If the post-process is reusable
  120304. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120305. */
  120306. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120307. /**
  120308. * Returns the string "VolumetricLightScatteringPostProcess"
  120309. * @returns "VolumetricLightScatteringPostProcess"
  120310. */
  120311. getClassName(): string;
  120312. private _isReady;
  120313. /**
  120314. * Sets the new light position for light scattering effect
  120315. * @param position The new custom light position
  120316. */
  120317. setCustomMeshPosition(position: Vector3): void;
  120318. /**
  120319. * Returns the light position for light scattering effect
  120320. * @return Vector3 The custom light position
  120321. */
  120322. getCustomMeshPosition(): Vector3;
  120323. /**
  120324. * Disposes the internal assets and detaches the post-process from the camera
  120325. */
  120326. dispose(camera: Camera): void;
  120327. /**
  120328. * Returns the render target texture used by the post-process
  120329. * @return the render target texture used by the post-process
  120330. */
  120331. getPass(): RenderTargetTexture;
  120332. private _meshExcluded;
  120333. private _createPass;
  120334. private _updateMeshScreenCoordinates;
  120335. /**
  120336. * Creates a default mesh for the Volumeric Light Scattering post-process
  120337. * @param name The mesh name
  120338. * @param scene The scene where to create the mesh
  120339. * @return the default mesh
  120340. */
  120341. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120342. }
  120343. }
  120344. declare module BABYLON {
  120345. interface Scene {
  120346. /** @hidden (Backing field) */
  120347. _boundingBoxRenderer: BoundingBoxRenderer;
  120348. /** @hidden (Backing field) */
  120349. _forceShowBoundingBoxes: boolean;
  120350. /**
  120351. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120352. */
  120353. forceShowBoundingBoxes: boolean;
  120354. /**
  120355. * Gets the bounding box renderer associated with the scene
  120356. * @returns a BoundingBoxRenderer
  120357. */
  120358. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120359. }
  120360. interface AbstractMesh {
  120361. /** @hidden (Backing field) */
  120362. _showBoundingBox: boolean;
  120363. /**
  120364. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120365. */
  120366. showBoundingBox: boolean;
  120367. }
  120368. /**
  120369. * Component responsible of rendering the bounding box of the meshes in a scene.
  120370. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120371. */
  120372. export class BoundingBoxRenderer implements ISceneComponent {
  120373. /**
  120374. * The component name helpfull to identify the component in the list of scene components.
  120375. */
  120376. readonly name: string;
  120377. /**
  120378. * The scene the component belongs to.
  120379. */
  120380. scene: Scene;
  120381. /**
  120382. * Color of the bounding box lines placed in front of an object
  120383. */
  120384. frontColor: Color3;
  120385. /**
  120386. * Color of the bounding box lines placed behind an object
  120387. */
  120388. backColor: Color3;
  120389. /**
  120390. * Defines if the renderer should show the back lines or not
  120391. */
  120392. showBackLines: boolean;
  120393. /**
  120394. * @hidden
  120395. */
  120396. renderList: SmartArray<BoundingBox>;
  120397. private _colorShader;
  120398. private _vertexBuffers;
  120399. private _indexBuffer;
  120400. private _fillIndexBuffer;
  120401. private _fillIndexData;
  120402. /**
  120403. * Instantiates a new bounding box renderer in a scene.
  120404. * @param scene the scene the renderer renders in
  120405. */
  120406. constructor(scene: Scene);
  120407. /**
  120408. * Registers the component in a given scene
  120409. */
  120410. register(): void;
  120411. private _evaluateSubMesh;
  120412. private _activeMesh;
  120413. private _prepareRessources;
  120414. private _createIndexBuffer;
  120415. /**
  120416. * Rebuilds the elements related to this component in case of
  120417. * context lost for instance.
  120418. */
  120419. rebuild(): void;
  120420. /**
  120421. * @hidden
  120422. */
  120423. reset(): void;
  120424. /**
  120425. * Render the bounding boxes of a specific rendering group
  120426. * @param renderingGroupId defines the rendering group to render
  120427. */
  120428. render(renderingGroupId: number): void;
  120429. /**
  120430. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120431. * @param mesh Define the mesh to render the occlusion bounding box for
  120432. */
  120433. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120434. /**
  120435. * Dispose and release the resources attached to this renderer.
  120436. */
  120437. dispose(): void;
  120438. }
  120439. }
  120440. declare module BABYLON {
  120441. /** @hidden */
  120442. export var depthPixelShader: {
  120443. name: string;
  120444. shader: string;
  120445. };
  120446. }
  120447. declare module BABYLON {
  120448. /**
  120449. * This represents a depth renderer in Babylon.
  120450. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120451. */
  120452. export class DepthRenderer {
  120453. private _scene;
  120454. private _depthMap;
  120455. private _effect;
  120456. private _cachedDefines;
  120457. private _camera;
  120458. /**
  120459. * Specifiess that the depth renderer will only be used within
  120460. * the camera it is created for.
  120461. * This can help forcing its rendering during the camera processing.
  120462. */
  120463. useOnlyInActiveCamera: boolean;
  120464. /** @hidden */
  120465. static _SceneComponentInitialization: (scene: Scene) => void;
  120466. /**
  120467. * Instantiates a depth renderer
  120468. * @param scene The scene the renderer belongs to
  120469. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120470. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120471. */
  120472. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  120473. /**
  120474. * Creates the depth rendering effect and checks if the effect is ready.
  120475. * @param subMesh The submesh to be used to render the depth map of
  120476. * @param useInstances If multiple world instances should be used
  120477. * @returns if the depth renderer is ready to render the depth map
  120478. */
  120479. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120480. /**
  120481. * Gets the texture which the depth map will be written to.
  120482. * @returns The depth map texture
  120483. */
  120484. getDepthMap(): RenderTargetTexture;
  120485. /**
  120486. * Disposes of the depth renderer.
  120487. */
  120488. dispose(): void;
  120489. }
  120490. }
  120491. declare module BABYLON {
  120492. interface Scene {
  120493. /** @hidden (Backing field) */
  120494. _depthRenderer: {
  120495. [id: string]: DepthRenderer;
  120496. };
  120497. /**
  120498. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120499. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120500. * @returns the created depth renderer
  120501. */
  120502. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  120503. /**
  120504. * Disables a depth renderer for a given camera
  120505. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120506. */
  120507. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120508. }
  120509. /**
  120510. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120511. * in several rendering techniques.
  120512. */
  120513. export class DepthRendererSceneComponent implements ISceneComponent {
  120514. /**
  120515. * The component name helpfull to identify the component in the list of scene components.
  120516. */
  120517. readonly name: string;
  120518. /**
  120519. * The scene the component belongs to.
  120520. */
  120521. scene: Scene;
  120522. /**
  120523. * Creates a new instance of the component for the given scene
  120524. * @param scene Defines the scene to register the component in
  120525. */
  120526. constructor(scene: Scene);
  120527. /**
  120528. * Registers the component in a given scene
  120529. */
  120530. register(): void;
  120531. /**
  120532. * Rebuilds the elements related to this component in case of
  120533. * context lost for instance.
  120534. */
  120535. rebuild(): void;
  120536. /**
  120537. * Disposes the component and the associated ressources
  120538. */
  120539. dispose(): void;
  120540. private _gatherRenderTargets;
  120541. private _gatherActiveCameraRenderTargets;
  120542. }
  120543. }
  120544. declare module BABYLON {
  120545. /** @hidden */
  120546. export var outlinePixelShader: {
  120547. name: string;
  120548. shader: string;
  120549. };
  120550. }
  120551. declare module BABYLON {
  120552. /** @hidden */
  120553. export var outlineVertexShader: {
  120554. name: string;
  120555. shader: string;
  120556. };
  120557. }
  120558. declare module BABYLON {
  120559. interface Scene {
  120560. /** @hidden */
  120561. _outlineRenderer: OutlineRenderer;
  120562. /**
  120563. * Gets the outline renderer associated with the scene
  120564. * @returns a OutlineRenderer
  120565. */
  120566. getOutlineRenderer(): OutlineRenderer;
  120567. }
  120568. interface AbstractMesh {
  120569. /** @hidden (Backing field) */
  120570. _renderOutline: boolean;
  120571. /**
  120572. * Gets or sets a boolean indicating if the outline must be rendered as well
  120573. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120574. */
  120575. renderOutline: boolean;
  120576. /** @hidden (Backing field) */
  120577. _renderOverlay: boolean;
  120578. /**
  120579. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120580. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120581. */
  120582. renderOverlay: boolean;
  120583. }
  120584. /**
  120585. * This class is responsible to draw bothe outline/overlay of meshes.
  120586. * It should not be used directly but through the available method on mesh.
  120587. */
  120588. export class OutlineRenderer implements ISceneComponent {
  120589. /**
  120590. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120591. */
  120592. private static _StencilReference;
  120593. /**
  120594. * The name of the component. Each component must have a unique name.
  120595. */
  120596. name: string;
  120597. /**
  120598. * The scene the component belongs to.
  120599. */
  120600. scene: Scene;
  120601. /**
  120602. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120603. */
  120604. zOffset: number;
  120605. private _engine;
  120606. private _effect;
  120607. private _cachedDefines;
  120608. private _savedDepthWrite;
  120609. /**
  120610. * Instantiates a new outline renderer. (There could be only one per scene).
  120611. * @param scene Defines the scene it belongs to
  120612. */
  120613. constructor(scene: Scene);
  120614. /**
  120615. * Register the component to one instance of a scene.
  120616. */
  120617. register(): void;
  120618. /**
  120619. * Rebuilds the elements related to this component in case of
  120620. * context lost for instance.
  120621. */
  120622. rebuild(): void;
  120623. /**
  120624. * Disposes the component and the associated ressources.
  120625. */
  120626. dispose(): void;
  120627. /**
  120628. * Renders the outline in the canvas.
  120629. * @param subMesh Defines the sumesh to render
  120630. * @param batch Defines the batch of meshes in case of instances
  120631. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120632. */
  120633. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120634. /**
  120635. * Returns whether or not the outline renderer is ready for a given submesh.
  120636. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120637. * @param subMesh Defines the submesh to check readyness for
  120638. * @param useInstances Defines wheter wee are trying to render instances or not
  120639. * @returns true if ready otherwise false
  120640. */
  120641. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120642. private _beforeRenderingMesh;
  120643. private _afterRenderingMesh;
  120644. }
  120645. }
  120646. declare module BABYLON {
  120647. /**
  120648. * Defines the list of states available for a task inside a AssetsManager
  120649. */
  120650. export enum AssetTaskState {
  120651. /**
  120652. * Initialization
  120653. */
  120654. INIT = 0,
  120655. /**
  120656. * Running
  120657. */
  120658. RUNNING = 1,
  120659. /**
  120660. * Done
  120661. */
  120662. DONE = 2,
  120663. /**
  120664. * Error
  120665. */
  120666. ERROR = 3
  120667. }
  120668. /**
  120669. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120670. */
  120671. export abstract class AbstractAssetTask {
  120672. /**
  120673. * Task name
  120674. */ name: string;
  120675. /**
  120676. * Callback called when the task is successful
  120677. */
  120678. onSuccess: (task: any) => void;
  120679. /**
  120680. * Callback called when the task is not successful
  120681. */
  120682. onError: (task: any, message?: string, exception?: any) => void;
  120683. /**
  120684. * Creates a new AssetsManager
  120685. * @param name defines the name of the task
  120686. */
  120687. constructor(
  120688. /**
  120689. * Task name
  120690. */ name: string);
  120691. private _isCompleted;
  120692. private _taskState;
  120693. private _errorObject;
  120694. /**
  120695. * Get if the task is completed
  120696. */
  120697. readonly isCompleted: boolean;
  120698. /**
  120699. * Gets the current state of the task
  120700. */
  120701. readonly taskState: AssetTaskState;
  120702. /**
  120703. * Gets the current error object (if task is in error)
  120704. */
  120705. readonly errorObject: {
  120706. message?: string;
  120707. exception?: any;
  120708. };
  120709. /**
  120710. * Internal only
  120711. * @hidden
  120712. */
  120713. _setErrorObject(message?: string, exception?: any): void;
  120714. /**
  120715. * Execute the current task
  120716. * @param scene defines the scene where you want your assets to be loaded
  120717. * @param onSuccess is a callback called when the task is successfully executed
  120718. * @param onError is a callback called if an error occurs
  120719. */
  120720. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120721. /**
  120722. * Execute the current task
  120723. * @param scene defines the scene where you want your assets to be loaded
  120724. * @param onSuccess is a callback called when the task is successfully executed
  120725. * @param onError is a callback called if an error occurs
  120726. */
  120727. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120728. /**
  120729. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120730. * This can be used with failed tasks that have the reason for failure fixed.
  120731. */
  120732. reset(): void;
  120733. private onErrorCallback;
  120734. private onDoneCallback;
  120735. }
  120736. /**
  120737. * Define the interface used by progress events raised during assets loading
  120738. */
  120739. export interface IAssetsProgressEvent {
  120740. /**
  120741. * Defines the number of remaining tasks to process
  120742. */
  120743. remainingCount: number;
  120744. /**
  120745. * Defines the total number of tasks
  120746. */
  120747. totalCount: number;
  120748. /**
  120749. * Defines the task that was just processed
  120750. */
  120751. task: AbstractAssetTask;
  120752. }
  120753. /**
  120754. * Class used to share progress information about assets loading
  120755. */
  120756. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120757. /**
  120758. * Defines the number of remaining tasks to process
  120759. */
  120760. remainingCount: number;
  120761. /**
  120762. * Defines the total number of tasks
  120763. */
  120764. totalCount: number;
  120765. /**
  120766. * Defines the task that was just processed
  120767. */
  120768. task: AbstractAssetTask;
  120769. /**
  120770. * Creates a AssetsProgressEvent
  120771. * @param remainingCount defines the number of remaining tasks to process
  120772. * @param totalCount defines the total number of tasks
  120773. * @param task defines the task that was just processed
  120774. */
  120775. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120776. }
  120777. /**
  120778. * Define a task used by AssetsManager to load meshes
  120779. */
  120780. export class MeshAssetTask extends AbstractAssetTask {
  120781. /**
  120782. * Defines the name of the task
  120783. */
  120784. name: string;
  120785. /**
  120786. * Defines the list of mesh's names you want to load
  120787. */
  120788. meshesNames: any;
  120789. /**
  120790. * Defines the root url to use as a base to load your meshes and associated resources
  120791. */
  120792. rootUrl: string;
  120793. /**
  120794. * Defines the filename of the scene to load from
  120795. */
  120796. sceneFilename: string;
  120797. /**
  120798. * Gets the list of loaded meshes
  120799. */
  120800. loadedMeshes: Array<AbstractMesh>;
  120801. /**
  120802. * Gets the list of loaded particle systems
  120803. */
  120804. loadedParticleSystems: Array<IParticleSystem>;
  120805. /**
  120806. * Gets the list of loaded skeletons
  120807. */
  120808. loadedSkeletons: Array<Skeleton>;
  120809. /**
  120810. * Gets the list of loaded animation groups
  120811. */
  120812. loadedAnimationGroups: Array<AnimationGroup>;
  120813. /**
  120814. * Callback called when the task is successful
  120815. */
  120816. onSuccess: (task: MeshAssetTask) => void;
  120817. /**
  120818. * Callback called when the task is successful
  120819. */
  120820. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120821. /**
  120822. * Creates a new MeshAssetTask
  120823. * @param name defines the name of the task
  120824. * @param meshesNames defines the list of mesh's names you want to load
  120825. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120826. * @param sceneFilename defines the filename of the scene to load from
  120827. */
  120828. constructor(
  120829. /**
  120830. * Defines the name of the task
  120831. */
  120832. name: string,
  120833. /**
  120834. * Defines the list of mesh's names you want to load
  120835. */
  120836. meshesNames: any,
  120837. /**
  120838. * Defines the root url to use as a base to load your meshes and associated resources
  120839. */
  120840. rootUrl: string,
  120841. /**
  120842. * Defines the filename of the scene to load from
  120843. */
  120844. sceneFilename: string);
  120845. /**
  120846. * Execute the current task
  120847. * @param scene defines the scene where you want your assets to be loaded
  120848. * @param onSuccess is a callback called when the task is successfully executed
  120849. * @param onError is a callback called if an error occurs
  120850. */
  120851. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120852. }
  120853. /**
  120854. * Define a task used by AssetsManager to load text content
  120855. */
  120856. export class TextFileAssetTask extends AbstractAssetTask {
  120857. /**
  120858. * Defines the name of the task
  120859. */
  120860. name: string;
  120861. /**
  120862. * Defines the location of the file to load
  120863. */
  120864. url: string;
  120865. /**
  120866. * Gets the loaded text string
  120867. */
  120868. text: string;
  120869. /**
  120870. * Callback called when the task is successful
  120871. */
  120872. onSuccess: (task: TextFileAssetTask) => void;
  120873. /**
  120874. * Callback called when the task is successful
  120875. */
  120876. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120877. /**
  120878. * Creates a new TextFileAssetTask object
  120879. * @param name defines the name of the task
  120880. * @param url defines the location of the file to load
  120881. */
  120882. constructor(
  120883. /**
  120884. * Defines the name of the task
  120885. */
  120886. name: string,
  120887. /**
  120888. * Defines the location of the file to load
  120889. */
  120890. url: string);
  120891. /**
  120892. * Execute the current task
  120893. * @param scene defines the scene where you want your assets to be loaded
  120894. * @param onSuccess is a callback called when the task is successfully executed
  120895. * @param onError is a callback called if an error occurs
  120896. */
  120897. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120898. }
  120899. /**
  120900. * Define a task used by AssetsManager to load binary data
  120901. */
  120902. export class BinaryFileAssetTask extends AbstractAssetTask {
  120903. /**
  120904. * Defines the name of the task
  120905. */
  120906. name: string;
  120907. /**
  120908. * Defines the location of the file to load
  120909. */
  120910. url: string;
  120911. /**
  120912. * Gets the lodaded data (as an array buffer)
  120913. */
  120914. data: ArrayBuffer;
  120915. /**
  120916. * Callback called when the task is successful
  120917. */
  120918. onSuccess: (task: BinaryFileAssetTask) => void;
  120919. /**
  120920. * Callback called when the task is successful
  120921. */
  120922. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120923. /**
  120924. * Creates a new BinaryFileAssetTask object
  120925. * @param name defines the name of the new task
  120926. * @param url defines the location of the file to load
  120927. */
  120928. constructor(
  120929. /**
  120930. * Defines the name of the task
  120931. */
  120932. name: string,
  120933. /**
  120934. * Defines the location of the file to load
  120935. */
  120936. url: string);
  120937. /**
  120938. * Execute the current task
  120939. * @param scene defines the scene where you want your assets to be loaded
  120940. * @param onSuccess is a callback called when the task is successfully executed
  120941. * @param onError is a callback called if an error occurs
  120942. */
  120943. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120944. }
  120945. /**
  120946. * Define a task used by AssetsManager to load images
  120947. */
  120948. export class ImageAssetTask extends AbstractAssetTask {
  120949. /**
  120950. * Defines the name of the task
  120951. */
  120952. name: string;
  120953. /**
  120954. * Defines the location of the image to load
  120955. */
  120956. url: string;
  120957. /**
  120958. * Gets the loaded images
  120959. */
  120960. image: HTMLImageElement;
  120961. /**
  120962. * Callback called when the task is successful
  120963. */
  120964. onSuccess: (task: ImageAssetTask) => void;
  120965. /**
  120966. * Callback called when the task is successful
  120967. */
  120968. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120969. /**
  120970. * Creates a new ImageAssetTask
  120971. * @param name defines the name of the task
  120972. * @param url defines the location of the image to load
  120973. */
  120974. constructor(
  120975. /**
  120976. * Defines the name of the task
  120977. */
  120978. name: string,
  120979. /**
  120980. * Defines the location of the image to load
  120981. */
  120982. url: string);
  120983. /**
  120984. * Execute the current task
  120985. * @param scene defines the scene where you want your assets to be loaded
  120986. * @param onSuccess is a callback called when the task is successfully executed
  120987. * @param onError is a callback called if an error occurs
  120988. */
  120989. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120990. }
  120991. /**
  120992. * Defines the interface used by texture loading tasks
  120993. */
  120994. export interface ITextureAssetTask<TEX extends BaseTexture> {
  120995. /**
  120996. * Gets the loaded texture
  120997. */
  120998. texture: TEX;
  120999. }
  121000. /**
  121001. * Define a task used by AssetsManager to load 2D textures
  121002. */
  121003. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  121004. /**
  121005. * Defines the name of the task
  121006. */
  121007. name: string;
  121008. /**
  121009. * Defines the location of the file to load
  121010. */
  121011. url: string;
  121012. /**
  121013. * Defines if mipmap should not be generated (default is false)
  121014. */
  121015. noMipmap?: boolean | undefined;
  121016. /**
  121017. * Defines if texture must be inverted on Y axis (default is false)
  121018. */
  121019. invertY?: boolean | undefined;
  121020. /**
  121021. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121022. */
  121023. samplingMode: number;
  121024. /**
  121025. * Gets the loaded texture
  121026. */
  121027. texture: Texture;
  121028. /**
  121029. * Callback called when the task is successful
  121030. */
  121031. onSuccess: (task: TextureAssetTask) => void;
  121032. /**
  121033. * Callback called when the task is successful
  121034. */
  121035. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  121036. /**
  121037. * Creates a new TextureAssetTask object
  121038. * @param name defines the name of the task
  121039. * @param url defines the location of the file to load
  121040. * @param noMipmap defines if mipmap should not be generated (default is false)
  121041. * @param invertY defines if texture must be inverted on Y axis (default is false)
  121042. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121043. */
  121044. constructor(
  121045. /**
  121046. * Defines the name of the task
  121047. */
  121048. name: string,
  121049. /**
  121050. * Defines the location of the file to load
  121051. */
  121052. url: string,
  121053. /**
  121054. * Defines if mipmap should not be generated (default is false)
  121055. */
  121056. noMipmap?: boolean | undefined,
  121057. /**
  121058. * Defines if texture must be inverted on Y axis (default is false)
  121059. */
  121060. invertY?: boolean | undefined,
  121061. /**
  121062. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121063. */
  121064. samplingMode?: number);
  121065. /**
  121066. * Execute the current task
  121067. * @param scene defines the scene where you want your assets to be loaded
  121068. * @param onSuccess is a callback called when the task is successfully executed
  121069. * @param onError is a callback called if an error occurs
  121070. */
  121071. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121072. }
  121073. /**
  121074. * Define a task used by AssetsManager to load cube textures
  121075. */
  121076. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  121077. /**
  121078. * Defines the name of the task
  121079. */
  121080. name: string;
  121081. /**
  121082. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121083. */
  121084. url: string;
  121085. /**
  121086. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121087. */
  121088. extensions?: string[] | undefined;
  121089. /**
  121090. * Defines if mipmaps should not be generated (default is false)
  121091. */
  121092. noMipmap?: boolean | undefined;
  121093. /**
  121094. * Defines the explicit list of files (undefined by default)
  121095. */
  121096. files?: string[] | undefined;
  121097. /**
  121098. * Gets the loaded texture
  121099. */
  121100. texture: CubeTexture;
  121101. /**
  121102. * Callback called when the task is successful
  121103. */
  121104. onSuccess: (task: CubeTextureAssetTask) => void;
  121105. /**
  121106. * Callback called when the task is successful
  121107. */
  121108. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  121109. /**
  121110. * Creates a new CubeTextureAssetTask
  121111. * @param name defines the name of the task
  121112. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121113. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121114. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121115. * @param files defines the explicit list of files (undefined by default)
  121116. */
  121117. constructor(
  121118. /**
  121119. * Defines the name of the task
  121120. */
  121121. name: string,
  121122. /**
  121123. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121124. */
  121125. url: string,
  121126. /**
  121127. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121128. */
  121129. extensions?: string[] | undefined,
  121130. /**
  121131. * Defines if mipmaps should not be generated (default is false)
  121132. */
  121133. noMipmap?: boolean | undefined,
  121134. /**
  121135. * Defines the explicit list of files (undefined by default)
  121136. */
  121137. files?: string[] | undefined);
  121138. /**
  121139. * Execute the current task
  121140. * @param scene defines the scene where you want your assets to be loaded
  121141. * @param onSuccess is a callback called when the task is successfully executed
  121142. * @param onError is a callback called if an error occurs
  121143. */
  121144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121145. }
  121146. /**
  121147. * Define a task used by AssetsManager to load HDR cube textures
  121148. */
  121149. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  121150. /**
  121151. * Defines the name of the task
  121152. */
  121153. name: string;
  121154. /**
  121155. * Defines the location of the file to load
  121156. */
  121157. url: string;
  121158. /**
  121159. * Defines the desired size (the more it increases the longer the generation will be)
  121160. */
  121161. size: number;
  121162. /**
  121163. * Defines if mipmaps should not be generated (default is false)
  121164. */
  121165. noMipmap: boolean;
  121166. /**
  121167. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121168. */
  121169. generateHarmonics: boolean;
  121170. /**
  121171. * 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)
  121172. */
  121173. gammaSpace: boolean;
  121174. /**
  121175. * Internal Use Only
  121176. */
  121177. reserved: boolean;
  121178. /**
  121179. * Gets the loaded texture
  121180. */
  121181. texture: HDRCubeTexture;
  121182. /**
  121183. * Callback called when the task is successful
  121184. */
  121185. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  121186. /**
  121187. * Callback called when the task is successful
  121188. */
  121189. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  121190. /**
  121191. * Creates a new HDRCubeTextureAssetTask object
  121192. * @param name defines the name of the task
  121193. * @param url defines the location of the file to load
  121194. * @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.
  121195. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121196. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121197. * @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)
  121198. * @param reserved Internal use only
  121199. */
  121200. constructor(
  121201. /**
  121202. * Defines the name of the task
  121203. */
  121204. name: string,
  121205. /**
  121206. * Defines the location of the file to load
  121207. */
  121208. url: string,
  121209. /**
  121210. * Defines the desired size (the more it increases the longer the generation will be)
  121211. */
  121212. size: number,
  121213. /**
  121214. * Defines if mipmaps should not be generated (default is false)
  121215. */
  121216. noMipmap?: boolean,
  121217. /**
  121218. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121219. */
  121220. generateHarmonics?: boolean,
  121221. /**
  121222. * 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)
  121223. */
  121224. gammaSpace?: boolean,
  121225. /**
  121226. * Internal Use Only
  121227. */
  121228. reserved?: boolean);
  121229. /**
  121230. * Execute the current task
  121231. * @param scene defines the scene where you want your assets to be loaded
  121232. * @param onSuccess is a callback called when the task is successfully executed
  121233. * @param onError is a callback called if an error occurs
  121234. */
  121235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121236. }
  121237. /**
  121238. * Define a task used by AssetsManager to load Equirectangular cube textures
  121239. */
  121240. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  121241. /**
  121242. * Defines the name of the task
  121243. */
  121244. name: string;
  121245. /**
  121246. * Defines the location of the file to load
  121247. */
  121248. url: string;
  121249. /**
  121250. * Defines the desired size (the more it increases the longer the generation will be)
  121251. */
  121252. size: number;
  121253. /**
  121254. * Defines if mipmaps should not be generated (default is false)
  121255. */
  121256. noMipmap: boolean;
  121257. /**
  121258. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121259. * but the standard material would require them in Gamma space) (default is true)
  121260. */
  121261. gammaSpace: boolean;
  121262. /**
  121263. * Gets the loaded texture
  121264. */
  121265. texture: EquiRectangularCubeTexture;
  121266. /**
  121267. * Callback called when the task is successful
  121268. */
  121269. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  121270. /**
  121271. * Callback called when the task is successful
  121272. */
  121273. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  121274. /**
  121275. * Creates a new EquiRectangularCubeTextureAssetTask object
  121276. * @param name defines the name of the task
  121277. * @param url defines the location of the file to load
  121278. * @param size defines the desired size (the more it increases the longer the generation will be)
  121279. * If the size is omitted this implies you are using a preprocessed cubemap.
  121280. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121281. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  121282. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  121283. * (default is true)
  121284. */
  121285. constructor(
  121286. /**
  121287. * Defines the name of the task
  121288. */
  121289. name: string,
  121290. /**
  121291. * Defines the location of the file to load
  121292. */
  121293. url: string,
  121294. /**
  121295. * Defines the desired size (the more it increases the longer the generation will be)
  121296. */
  121297. size: number,
  121298. /**
  121299. * Defines if mipmaps should not be generated (default is false)
  121300. */
  121301. noMipmap?: boolean,
  121302. /**
  121303. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121304. * but the standard material would require them in Gamma space) (default is true)
  121305. */
  121306. gammaSpace?: boolean);
  121307. /**
  121308. * Execute the current task
  121309. * @param scene defines the scene where you want your assets to be loaded
  121310. * @param onSuccess is a callback called when the task is successfully executed
  121311. * @param onError is a callback called if an error occurs
  121312. */
  121313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121314. }
  121315. /**
  121316. * This class can be used to easily import assets into a scene
  121317. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121318. */
  121319. export class AssetsManager {
  121320. private _scene;
  121321. private _isLoading;
  121322. protected _tasks: AbstractAssetTask[];
  121323. protected _waitingTasksCount: number;
  121324. protected _totalTasksCount: number;
  121325. /**
  121326. * Callback called when all tasks are processed
  121327. */
  121328. onFinish: (tasks: AbstractAssetTask[]) => void;
  121329. /**
  121330. * Callback called when a task is successful
  121331. */
  121332. onTaskSuccess: (task: AbstractAssetTask) => void;
  121333. /**
  121334. * Callback called when a task had an error
  121335. */
  121336. onTaskError: (task: AbstractAssetTask) => void;
  121337. /**
  121338. * Callback called when a task is done (whatever the result is)
  121339. */
  121340. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121341. /**
  121342. * Observable called when all tasks are processed
  121343. */
  121344. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121345. /**
  121346. * Observable called when a task had an error
  121347. */
  121348. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121349. /**
  121350. * Observable called when all tasks were executed
  121351. */
  121352. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121353. /**
  121354. * Observable called when a task is done (whatever the result is)
  121355. */
  121356. onProgressObservable: Observable<IAssetsProgressEvent>;
  121357. /**
  121358. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121359. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121360. */
  121361. useDefaultLoadingScreen: boolean;
  121362. /**
  121363. * Creates a new AssetsManager
  121364. * @param scene defines the scene to work on
  121365. */
  121366. constructor(scene: Scene);
  121367. /**
  121368. * Add a MeshAssetTask to the list of active tasks
  121369. * @param taskName defines the name of the new task
  121370. * @param meshesNames defines the name of meshes to load
  121371. * @param rootUrl defines the root url to use to locate files
  121372. * @param sceneFilename defines the filename of the scene file
  121373. * @returns a new MeshAssetTask object
  121374. */
  121375. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121376. /**
  121377. * Add a TextFileAssetTask to the list of active tasks
  121378. * @param taskName defines the name of the new task
  121379. * @param url defines the url of the file to load
  121380. * @returns a new TextFileAssetTask object
  121381. */
  121382. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121383. /**
  121384. * Add a BinaryFileAssetTask to the list of active tasks
  121385. * @param taskName defines the name of the new task
  121386. * @param url defines the url of the file to load
  121387. * @returns a new BinaryFileAssetTask object
  121388. */
  121389. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121390. /**
  121391. * Add a ImageAssetTask to the list of active tasks
  121392. * @param taskName defines the name of the new task
  121393. * @param url defines the url of the file to load
  121394. * @returns a new ImageAssetTask object
  121395. */
  121396. addImageTask(taskName: string, url: string): ImageAssetTask;
  121397. /**
  121398. * Add a TextureAssetTask to the list of active tasks
  121399. * @param taskName defines the name of the new task
  121400. * @param url defines the url of the file to load
  121401. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121402. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121403. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121404. * @returns a new TextureAssetTask object
  121405. */
  121406. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121407. /**
  121408. * Add a CubeTextureAssetTask to the list of active tasks
  121409. * @param taskName defines the name of the new task
  121410. * @param url defines the url of the file to load
  121411. * @param extensions defines the extension to use to load the cube map (can be null)
  121412. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121413. * @param files defines the list of files to load (can be null)
  121414. * @returns a new CubeTextureAssetTask object
  121415. */
  121416. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121417. /**
  121418. *
  121419. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121420. * @param taskName defines the name of the new task
  121421. * @param url defines the url of the file to load
  121422. * @param size defines the size you want for the cubemap (can be null)
  121423. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121424. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121425. * @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)
  121426. * @param reserved Internal use only
  121427. * @returns a new HDRCubeTextureAssetTask object
  121428. */
  121429. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121430. /**
  121431. *
  121432. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121433. * @param taskName defines the name of the new task
  121434. * @param url defines the url of the file to load
  121435. * @param size defines the size you want for the cubemap (can be null)
  121436. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121437. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121438. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121439. * @returns a new EquiRectangularCubeTextureAssetTask object
  121440. */
  121441. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121442. /**
  121443. * Remove a task from the assets manager.
  121444. * @param task the task to remove
  121445. */
  121446. removeTask(task: AbstractAssetTask): void;
  121447. private _decreaseWaitingTasksCount;
  121448. private _runTask;
  121449. /**
  121450. * Reset the AssetsManager and remove all tasks
  121451. * @return the current instance of the AssetsManager
  121452. */
  121453. reset(): AssetsManager;
  121454. /**
  121455. * Start the loading process
  121456. * @return the current instance of the AssetsManager
  121457. */
  121458. load(): AssetsManager;
  121459. /**
  121460. * Start the loading process as an async operation
  121461. * @return a promise returning the list of failed tasks
  121462. */
  121463. loadAsync(): Promise<void>;
  121464. }
  121465. }
  121466. declare module BABYLON {
  121467. /**
  121468. * Wrapper class for promise with external resolve and reject.
  121469. */
  121470. export class Deferred<T> {
  121471. /**
  121472. * The promise associated with this deferred object.
  121473. */
  121474. readonly promise: Promise<T>;
  121475. private _resolve;
  121476. private _reject;
  121477. /**
  121478. * The resolve method of the promise associated with this deferred object.
  121479. */
  121480. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121481. /**
  121482. * The reject method of the promise associated with this deferred object.
  121483. */
  121484. readonly reject: (reason?: any) => void;
  121485. /**
  121486. * Constructor for this deferred object.
  121487. */
  121488. constructor();
  121489. }
  121490. }
  121491. declare module BABYLON {
  121492. /**
  121493. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121494. */
  121495. export class MeshExploder {
  121496. private _centerMesh;
  121497. private _meshes;
  121498. private _meshesOrigins;
  121499. private _toCenterVectors;
  121500. private _scaledDirection;
  121501. private _newPosition;
  121502. private _centerPosition;
  121503. /**
  121504. * Explodes meshes from a center mesh.
  121505. * @param meshes The meshes to explode.
  121506. * @param centerMesh The mesh to be center of explosion.
  121507. */
  121508. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121509. private _setCenterMesh;
  121510. /**
  121511. * Get class name
  121512. * @returns "MeshExploder"
  121513. */
  121514. getClassName(): string;
  121515. /**
  121516. * "Exploded meshes"
  121517. * @returns Array of meshes with the centerMesh at index 0.
  121518. */
  121519. getMeshes(): Array<Mesh>;
  121520. /**
  121521. * Explodes meshes giving a specific direction
  121522. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121523. */
  121524. explode(direction?: number): void;
  121525. }
  121526. }
  121527. declare module BABYLON {
  121528. /**
  121529. * Class used to help managing file picking and drag'n'drop
  121530. */
  121531. export class FilesInput {
  121532. /**
  121533. * List of files ready to be loaded
  121534. */
  121535. static readonly FilesToLoad: {
  121536. [key: string]: File;
  121537. };
  121538. /**
  121539. * Callback called when a file is processed
  121540. */
  121541. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121542. private _engine;
  121543. private _currentScene;
  121544. private _sceneLoadedCallback;
  121545. private _progressCallback;
  121546. private _additionalRenderLoopLogicCallback;
  121547. private _textureLoadingCallback;
  121548. private _startingProcessingFilesCallback;
  121549. private _onReloadCallback;
  121550. private _errorCallback;
  121551. private _elementToMonitor;
  121552. private _sceneFileToLoad;
  121553. private _filesToLoad;
  121554. /**
  121555. * Creates a new FilesInput
  121556. * @param engine defines the rendering engine
  121557. * @param scene defines the hosting scene
  121558. * @param sceneLoadedCallback callback called when scene is loaded
  121559. * @param progressCallback callback called to track progress
  121560. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121561. * @param textureLoadingCallback callback called when a texture is loading
  121562. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121563. * @param onReloadCallback callback called when a reload is requested
  121564. * @param errorCallback callback call if an error occurs
  121565. */
  121566. 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);
  121567. private _dragEnterHandler;
  121568. private _dragOverHandler;
  121569. private _dropHandler;
  121570. /**
  121571. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121572. * @param elementToMonitor defines the DOM element to track
  121573. */
  121574. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121575. /**
  121576. * Release all associated resources
  121577. */
  121578. dispose(): void;
  121579. private renderFunction;
  121580. private drag;
  121581. private drop;
  121582. private _traverseFolder;
  121583. private _processFiles;
  121584. /**
  121585. * Load files from a drop event
  121586. * @param event defines the drop event to use as source
  121587. */
  121588. loadFiles(event: any): void;
  121589. private _processReload;
  121590. /**
  121591. * Reload the current scene from the loaded files
  121592. */
  121593. reload(): void;
  121594. }
  121595. }
  121596. declare module BABYLON {
  121597. /**
  121598. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121600. */
  121601. export class SceneOptimization {
  121602. /**
  121603. * Defines the priority of this optimization (0 by default which means first in the list)
  121604. */
  121605. priority: number;
  121606. /**
  121607. * Gets a string describing the action executed by the current optimization
  121608. * @returns description string
  121609. */
  121610. getDescription(): string;
  121611. /**
  121612. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121613. * @param scene defines the current scene where to apply this optimization
  121614. * @param optimizer defines the current optimizer
  121615. * @returns true if everything that can be done was applied
  121616. */
  121617. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121618. /**
  121619. * Creates the SceneOptimization object
  121620. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121621. * @param desc defines the description associated with the optimization
  121622. */
  121623. constructor(
  121624. /**
  121625. * Defines the priority of this optimization (0 by default which means first in the list)
  121626. */
  121627. priority?: number);
  121628. }
  121629. /**
  121630. * Defines an optimization used to reduce the size of render target textures
  121631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121632. */
  121633. export class TextureOptimization extends SceneOptimization {
  121634. /**
  121635. * Defines the priority of this optimization (0 by default which means first in the list)
  121636. */
  121637. priority: number;
  121638. /**
  121639. * 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
  121640. */
  121641. maximumSize: number;
  121642. /**
  121643. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121644. */
  121645. step: number;
  121646. /**
  121647. * Gets a string describing the action executed by the current optimization
  121648. * @returns description string
  121649. */
  121650. getDescription(): string;
  121651. /**
  121652. * Creates the TextureOptimization object
  121653. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121654. * @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
  121655. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121656. */
  121657. constructor(
  121658. /**
  121659. * Defines the priority of this optimization (0 by default which means first in the list)
  121660. */
  121661. priority?: number,
  121662. /**
  121663. * 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
  121664. */
  121665. maximumSize?: number,
  121666. /**
  121667. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121668. */
  121669. step?: number);
  121670. /**
  121671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121672. * @param scene defines the current scene where to apply this optimization
  121673. * @param optimizer defines the current optimizer
  121674. * @returns true if everything that can be done was applied
  121675. */
  121676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121677. }
  121678. /**
  121679. * Defines an optimization used to increase or decrease the rendering resolution
  121680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121681. */
  121682. export class HardwareScalingOptimization extends SceneOptimization {
  121683. /**
  121684. * Defines the priority of this optimization (0 by default which means first in the list)
  121685. */
  121686. priority: number;
  121687. /**
  121688. * Defines the maximum scale to use (2 by default)
  121689. */
  121690. maximumScale: number;
  121691. /**
  121692. * Defines the step to use between two passes (0.5 by default)
  121693. */
  121694. step: number;
  121695. private _currentScale;
  121696. private _directionOffset;
  121697. /**
  121698. * Gets a string describing the action executed by the current optimization
  121699. * @return description string
  121700. */
  121701. getDescription(): string;
  121702. /**
  121703. * Creates the HardwareScalingOptimization object
  121704. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121705. * @param maximumScale defines the maximum scale to use (2 by default)
  121706. * @param step defines the step to use between two passes (0.5 by default)
  121707. */
  121708. constructor(
  121709. /**
  121710. * Defines the priority of this optimization (0 by default which means first in the list)
  121711. */
  121712. priority?: number,
  121713. /**
  121714. * Defines the maximum scale to use (2 by default)
  121715. */
  121716. maximumScale?: number,
  121717. /**
  121718. * Defines the step to use between two passes (0.5 by default)
  121719. */
  121720. step?: number);
  121721. /**
  121722. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121723. * @param scene defines the current scene where to apply this optimization
  121724. * @param optimizer defines the current optimizer
  121725. * @returns true if everything that can be done was applied
  121726. */
  121727. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121728. }
  121729. /**
  121730. * Defines an optimization used to remove shadows
  121731. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121732. */
  121733. export class ShadowsOptimization extends SceneOptimization {
  121734. /**
  121735. * Gets a string describing the action executed by the current optimization
  121736. * @return description string
  121737. */
  121738. getDescription(): string;
  121739. /**
  121740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121741. * @param scene defines the current scene where to apply this optimization
  121742. * @param optimizer defines the current optimizer
  121743. * @returns true if everything that can be done was applied
  121744. */
  121745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121746. }
  121747. /**
  121748. * Defines an optimization used to turn post-processes off
  121749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121750. */
  121751. export class PostProcessesOptimization extends SceneOptimization {
  121752. /**
  121753. * Gets a string describing the action executed by the current optimization
  121754. * @return description string
  121755. */
  121756. getDescription(): string;
  121757. /**
  121758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121759. * @param scene defines the current scene where to apply this optimization
  121760. * @param optimizer defines the current optimizer
  121761. * @returns true if everything that can be done was applied
  121762. */
  121763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121764. }
  121765. /**
  121766. * Defines an optimization used to turn lens flares off
  121767. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121768. */
  121769. export class LensFlaresOptimization extends SceneOptimization {
  121770. /**
  121771. * Gets a string describing the action executed by the current optimization
  121772. * @return description string
  121773. */
  121774. getDescription(): string;
  121775. /**
  121776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121777. * @param scene defines the current scene where to apply this optimization
  121778. * @param optimizer defines the current optimizer
  121779. * @returns true if everything that can be done was applied
  121780. */
  121781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121782. }
  121783. /**
  121784. * Defines an optimization based on user defined callback.
  121785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121786. */
  121787. export class CustomOptimization extends SceneOptimization {
  121788. /**
  121789. * Callback called to apply the custom optimization.
  121790. */
  121791. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121792. /**
  121793. * Callback called to get custom description
  121794. */
  121795. onGetDescription: () => string;
  121796. /**
  121797. * Gets a string describing the action executed by the current optimization
  121798. * @returns description string
  121799. */
  121800. getDescription(): string;
  121801. /**
  121802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121803. * @param scene defines the current scene where to apply this optimization
  121804. * @param optimizer defines the current optimizer
  121805. * @returns true if everything that can be done was applied
  121806. */
  121807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121808. }
  121809. /**
  121810. * Defines an optimization used to turn particles off
  121811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121812. */
  121813. export class ParticlesOptimization extends SceneOptimization {
  121814. /**
  121815. * Gets a string describing the action executed by the current optimization
  121816. * @return description string
  121817. */
  121818. getDescription(): string;
  121819. /**
  121820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121821. * @param scene defines the current scene where to apply this optimization
  121822. * @param optimizer defines the current optimizer
  121823. * @returns true if everything that can be done was applied
  121824. */
  121825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121826. }
  121827. /**
  121828. * Defines an optimization used to turn render targets off
  121829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121830. */
  121831. export class RenderTargetsOptimization extends SceneOptimization {
  121832. /**
  121833. * Gets a string describing the action executed by the current optimization
  121834. * @return description string
  121835. */
  121836. getDescription(): string;
  121837. /**
  121838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121839. * @param scene defines the current scene where to apply this optimization
  121840. * @param optimizer defines the current optimizer
  121841. * @returns true if everything that can be done was applied
  121842. */
  121843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121844. }
  121845. /**
  121846. * Defines an optimization used to merge meshes with compatible materials
  121847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121848. */
  121849. export class MergeMeshesOptimization extends SceneOptimization {
  121850. private static _UpdateSelectionTree;
  121851. /**
  121852. * Gets or sets a boolean which defines if optimization octree has to be updated
  121853. */
  121854. /**
  121855. * Gets or sets a boolean which defines if optimization octree has to be updated
  121856. */
  121857. static UpdateSelectionTree: boolean;
  121858. /**
  121859. * Gets a string describing the action executed by the current optimization
  121860. * @return description string
  121861. */
  121862. getDescription(): string;
  121863. private _canBeMerged;
  121864. /**
  121865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121866. * @param scene defines the current scene where to apply this optimization
  121867. * @param optimizer defines the current optimizer
  121868. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121869. * @returns true if everything that can be done was applied
  121870. */
  121871. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121872. }
  121873. /**
  121874. * Defines a list of options used by SceneOptimizer
  121875. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121876. */
  121877. export class SceneOptimizerOptions {
  121878. /**
  121879. * Defines the target frame rate to reach (60 by default)
  121880. */
  121881. targetFrameRate: number;
  121882. /**
  121883. * Defines the interval between two checkes (2000ms by default)
  121884. */
  121885. trackerDuration: number;
  121886. /**
  121887. * Gets the list of optimizations to apply
  121888. */
  121889. optimizations: SceneOptimization[];
  121890. /**
  121891. * Creates a new list of options used by SceneOptimizer
  121892. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121893. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121894. */
  121895. constructor(
  121896. /**
  121897. * Defines the target frame rate to reach (60 by default)
  121898. */
  121899. targetFrameRate?: number,
  121900. /**
  121901. * Defines the interval between two checkes (2000ms by default)
  121902. */
  121903. trackerDuration?: number);
  121904. /**
  121905. * Add a new optimization
  121906. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121907. * @returns the current SceneOptimizerOptions
  121908. */
  121909. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121910. /**
  121911. * Add a new custom optimization
  121912. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121913. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121914. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121915. * @returns the current SceneOptimizerOptions
  121916. */
  121917. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121918. /**
  121919. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121920. * @param targetFrameRate defines the target frame rate (60 by default)
  121921. * @returns a SceneOptimizerOptions object
  121922. */
  121923. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121924. /**
  121925. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121926. * @param targetFrameRate defines the target frame rate (60 by default)
  121927. * @returns a SceneOptimizerOptions object
  121928. */
  121929. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121930. /**
  121931. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121932. * @param targetFrameRate defines the target frame rate (60 by default)
  121933. * @returns a SceneOptimizerOptions object
  121934. */
  121935. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121936. }
  121937. /**
  121938. * Class used to run optimizations in order to reach a target frame rate
  121939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121940. */
  121941. export class SceneOptimizer implements IDisposable {
  121942. private _isRunning;
  121943. private _options;
  121944. private _scene;
  121945. private _currentPriorityLevel;
  121946. private _targetFrameRate;
  121947. private _trackerDuration;
  121948. private _currentFrameRate;
  121949. private _sceneDisposeObserver;
  121950. private _improvementMode;
  121951. /**
  121952. * Defines an observable called when the optimizer reaches the target frame rate
  121953. */
  121954. onSuccessObservable: Observable<SceneOptimizer>;
  121955. /**
  121956. * Defines an observable called when the optimizer enables an optimization
  121957. */
  121958. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121959. /**
  121960. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121961. */
  121962. onFailureObservable: Observable<SceneOptimizer>;
  121963. /**
  121964. * Gets a boolean indicating if the optimizer is in improvement mode
  121965. */
  121966. readonly isInImprovementMode: boolean;
  121967. /**
  121968. * Gets the current priority level (0 at start)
  121969. */
  121970. readonly currentPriorityLevel: number;
  121971. /**
  121972. * Gets the current frame rate checked by the SceneOptimizer
  121973. */
  121974. readonly currentFrameRate: number;
  121975. /**
  121976. * Gets or sets the current target frame rate (60 by default)
  121977. */
  121978. /**
  121979. * Gets or sets the current target frame rate (60 by default)
  121980. */
  121981. targetFrameRate: number;
  121982. /**
  121983. * Gets or sets the current interval between two checks (every 2000ms by default)
  121984. */
  121985. /**
  121986. * Gets or sets the current interval between two checks (every 2000ms by default)
  121987. */
  121988. trackerDuration: number;
  121989. /**
  121990. * Gets the list of active optimizations
  121991. */
  121992. readonly optimizations: SceneOptimization[];
  121993. /**
  121994. * Creates a new SceneOptimizer
  121995. * @param scene defines the scene to work on
  121996. * @param options defines the options to use with the SceneOptimizer
  121997. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  121998. * @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)
  121999. */
  122000. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  122001. /**
  122002. * Stops the current optimizer
  122003. */
  122004. stop(): void;
  122005. /**
  122006. * Reset the optimizer to initial step (current priority level = 0)
  122007. */
  122008. reset(): void;
  122009. /**
  122010. * Start the optimizer. By default it will try to reach a specific framerate
  122011. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  122012. */
  122013. start(): void;
  122014. private _checkCurrentState;
  122015. /**
  122016. * Release all resources
  122017. */
  122018. dispose(): void;
  122019. /**
  122020. * Helper function to create a SceneOptimizer with one single line of code
  122021. * @param scene defines the scene to work on
  122022. * @param options defines the options to use with the SceneOptimizer
  122023. * @param onSuccess defines a callback to call on success
  122024. * @param onFailure defines a callback to call on failure
  122025. * @returns the new SceneOptimizer object
  122026. */
  122027. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  122028. }
  122029. }
  122030. declare module BABYLON {
  122031. /**
  122032. * Class used to serialize a scene into a string
  122033. */
  122034. export class SceneSerializer {
  122035. /**
  122036. * Clear cache used by a previous serialization
  122037. */
  122038. static ClearCache(): void;
  122039. /**
  122040. * Serialize a scene into a JSON compatible object
  122041. * @param scene defines the scene to serialize
  122042. * @returns a JSON compatible object
  122043. */
  122044. static Serialize(scene: Scene): any;
  122045. /**
  122046. * Serialize a mesh into a JSON compatible object
  122047. * @param toSerialize defines the mesh to serialize
  122048. * @param withParents defines if parents must be serialized as well
  122049. * @param withChildren defines if children must be serialized as well
  122050. * @returns a JSON compatible object
  122051. */
  122052. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  122053. }
  122054. }
  122055. declare module BABYLON {
  122056. /**
  122057. * Class used to host texture specific utilities
  122058. */
  122059. export class TextureTools {
  122060. /**
  122061. * Uses the GPU to create a copy texture rescaled at a given size
  122062. * @param texture Texture to copy from
  122063. * @param width defines the desired width
  122064. * @param height defines the desired height
  122065. * @param useBilinearMode defines if bilinear mode has to be used
  122066. * @return the generated texture
  122067. */
  122068. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  122069. }
  122070. }
  122071. declare module BABYLON {
  122072. /**
  122073. * This represents the different options available for the video capture.
  122074. */
  122075. export interface VideoRecorderOptions {
  122076. /** Defines the mime type of the video. */
  122077. mimeType: string;
  122078. /** Defines the FPS the video should be recorded at. */
  122079. fps: number;
  122080. /** Defines the chunk size for the recording data. */
  122081. recordChunckSize: number;
  122082. /** The audio tracks to attach to the recording. */
  122083. audioTracks?: MediaStreamTrack[];
  122084. }
  122085. /**
  122086. * This can help with recording videos from BabylonJS.
  122087. * This is based on the available WebRTC functionalities of the browser.
  122088. *
  122089. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  122090. */
  122091. export class VideoRecorder {
  122092. private static readonly _defaultOptions;
  122093. /**
  122094. * Returns whether or not the VideoRecorder is available in your browser.
  122095. * @param engine Defines the Babylon Engine.
  122096. * @returns true if supported otherwise false.
  122097. */
  122098. static IsSupported(engine: Engine): boolean;
  122099. private readonly _options;
  122100. private _canvas;
  122101. private _mediaRecorder;
  122102. private _recordedChunks;
  122103. private _fileName;
  122104. private _resolve;
  122105. private _reject;
  122106. /**
  122107. * True when a recording is already in progress.
  122108. */
  122109. readonly isRecording: boolean;
  122110. /**
  122111. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  122112. * @param engine Defines the BabylonJS Engine you wish to record.
  122113. * @param options Defines options that can be used to customize the capture.
  122114. */
  122115. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  122116. /**
  122117. * Stops the current recording before the default capture timeout passed in the startRecording function.
  122118. */
  122119. stopRecording(): void;
  122120. /**
  122121. * Starts recording the canvas for a max duration specified in parameters.
  122122. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  122123. * If null no automatic download will start and you can rely on the promise to get the data back.
  122124. * @param maxDuration Defines the maximum recording time in seconds.
  122125. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  122126. * @return A promise callback at the end of the recording with the video data in Blob.
  122127. */
  122128. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  122129. /**
  122130. * Releases internal resources used during the recording.
  122131. */
  122132. dispose(): void;
  122133. private _handleDataAvailable;
  122134. private _handleError;
  122135. private _handleStop;
  122136. }
  122137. }
  122138. declare module BABYLON {
  122139. /**
  122140. * Class containing a set of static utilities functions for screenshots
  122141. */
  122142. export class ScreenshotTools {
  122143. /**
  122144. * Captures a screenshot of the current rendering
  122145. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122146. * @param engine defines the rendering engine
  122147. * @param camera defines the source camera
  122148. * @param size This parameter can be set to a single number or to an object with the
  122149. * following (optional) properties: precision, width, height. If a single number is passed,
  122150. * it will be used for both width and height. If an object is passed, the screenshot size
  122151. * will be derived from the parameters. The precision property is a multiplier allowing
  122152. * rendering at a higher or lower resolution
  122153. * @param successCallback defines the callback receives a single parameter which contains the
  122154. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122155. * src parameter of an <img> to display it
  122156. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122157. * Check your browser for supported MIME types
  122158. */
  122159. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  122160. /**
  122161. * Generates an image screenshot from the specified camera.
  122162. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122163. * @param engine The engine to use for rendering
  122164. * @param camera The camera to use for rendering
  122165. * @param size This parameter can be set to a single number or to an object with the
  122166. * following (optional) properties: precision, width, height. If a single number is passed,
  122167. * it will be used for both width and height. If an object is passed, the screenshot size
  122168. * will be derived from the parameters. The precision property is a multiplier allowing
  122169. * rendering at a higher or lower resolution
  122170. * @param successCallback The callback receives a single parameter which contains the
  122171. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122172. * src parameter of an <img> to display it
  122173. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122174. * Check your browser for supported MIME types
  122175. * @param samples Texture samples (default: 1)
  122176. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122177. * @param fileName A name for for the downloaded file.
  122178. */
  122179. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122180. }
  122181. }
  122182. declare module BABYLON {
  122183. /**
  122184. * A cursor which tracks a point on a path
  122185. */
  122186. export class PathCursor {
  122187. private path;
  122188. /**
  122189. * Stores path cursor callbacks for when an onchange event is triggered
  122190. */
  122191. private _onchange;
  122192. /**
  122193. * The value of the path cursor
  122194. */
  122195. value: number;
  122196. /**
  122197. * The animation array of the path cursor
  122198. */
  122199. animations: Animation[];
  122200. /**
  122201. * Initializes the path cursor
  122202. * @param path The path to track
  122203. */
  122204. constructor(path: Path2);
  122205. /**
  122206. * Gets the cursor point on the path
  122207. * @returns A point on the path cursor at the cursor location
  122208. */
  122209. getPoint(): Vector3;
  122210. /**
  122211. * Moves the cursor ahead by the step amount
  122212. * @param step The amount to move the cursor forward
  122213. * @returns This path cursor
  122214. */
  122215. moveAhead(step?: number): PathCursor;
  122216. /**
  122217. * Moves the cursor behind by the step amount
  122218. * @param step The amount to move the cursor back
  122219. * @returns This path cursor
  122220. */
  122221. moveBack(step?: number): PathCursor;
  122222. /**
  122223. * Moves the cursor by the step amount
  122224. * If the step amount is greater than one, an exception is thrown
  122225. * @param step The amount to move the cursor
  122226. * @returns This path cursor
  122227. */
  122228. move(step: number): PathCursor;
  122229. /**
  122230. * Ensures that the value is limited between zero and one
  122231. * @returns This path cursor
  122232. */
  122233. private ensureLimits;
  122234. /**
  122235. * Runs onchange callbacks on change (used by the animation engine)
  122236. * @returns This path cursor
  122237. */
  122238. private raiseOnChange;
  122239. /**
  122240. * Executes a function on change
  122241. * @param f A path cursor onchange callback
  122242. * @returns This path cursor
  122243. */
  122244. onchange(f: (cursor: PathCursor) => void): PathCursor;
  122245. }
  122246. }
  122247. declare module BABYLON {
  122248. /** @hidden */
  122249. export var blurPixelShader: {
  122250. name: string;
  122251. shader: string;
  122252. };
  122253. }
  122254. declare module BABYLON {
  122255. /** @hidden */
  122256. export var pointCloudVertexDeclaration: {
  122257. name: string;
  122258. shader: string;
  122259. };
  122260. }
  122261. // Mixins
  122262. interface Window {
  122263. mozIndexedDB: IDBFactory;
  122264. webkitIndexedDB: IDBFactory;
  122265. msIndexedDB: IDBFactory;
  122266. webkitURL: typeof URL;
  122267. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  122268. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  122269. WebGLRenderingContext: WebGLRenderingContext;
  122270. MSGesture: MSGesture;
  122271. CANNON: any;
  122272. AudioContext: AudioContext;
  122273. webkitAudioContext: AudioContext;
  122274. PointerEvent: any;
  122275. Math: Math;
  122276. Uint8Array: Uint8ArrayConstructor;
  122277. Float32Array: Float32ArrayConstructor;
  122278. mozURL: typeof URL;
  122279. msURL: typeof URL;
  122280. VRFrameData: any; // WebVR, from specs 1.1
  122281. DracoDecoderModule: any;
  122282. setImmediate(handler: (...args: any[]) => void): number;
  122283. }
  122284. interface HTMLCanvasElement {
  122285. requestPointerLock(): void;
  122286. msRequestPointerLock?(): void;
  122287. mozRequestPointerLock?(): void;
  122288. webkitRequestPointerLock?(): void;
  122289. /** Track wether a record is in progress */
  122290. isRecording: boolean;
  122291. /** Capture Stream method defined by some browsers */
  122292. captureStream(fps?: number): MediaStream;
  122293. }
  122294. interface CanvasRenderingContext2D {
  122295. msImageSmoothingEnabled: boolean;
  122296. }
  122297. interface MouseEvent {
  122298. mozMovementX: number;
  122299. mozMovementY: number;
  122300. webkitMovementX: number;
  122301. webkitMovementY: number;
  122302. msMovementX: number;
  122303. msMovementY: number;
  122304. }
  122305. interface Navigator {
  122306. mozGetVRDevices: (any: any) => any;
  122307. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122308. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122309. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122310. webkitGetGamepads(): Gamepad[];
  122311. msGetGamepads(): Gamepad[];
  122312. webkitGamepads(): Gamepad[];
  122313. }
  122314. interface HTMLVideoElement {
  122315. mozSrcObject: any;
  122316. }
  122317. interface Math {
  122318. fround(x: number): number;
  122319. imul(a: number, b: number): number;
  122320. }
  122321. interface WebGLRenderingContext {
  122322. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122323. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122324. vertexAttribDivisor(index: number, divisor: number): void;
  122325. createVertexArray(): any;
  122326. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122327. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122328. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122329. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122330. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122331. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122332. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122333. // Queries
  122334. createQuery(): WebGLQuery;
  122335. deleteQuery(query: WebGLQuery): void;
  122336. beginQuery(target: number, query: WebGLQuery): void;
  122337. endQuery(target: number): void;
  122338. getQueryParameter(query: WebGLQuery, pname: number): any;
  122339. getQuery(target: number, pname: number): any;
  122340. MAX_SAMPLES: number;
  122341. RGBA8: number;
  122342. READ_FRAMEBUFFER: number;
  122343. DRAW_FRAMEBUFFER: number;
  122344. UNIFORM_BUFFER: number;
  122345. HALF_FLOAT_OES: number;
  122346. RGBA16F: number;
  122347. RGBA32F: number;
  122348. R32F: number;
  122349. RG32F: number;
  122350. RGB32F: number;
  122351. R16F: number;
  122352. RG16F: number;
  122353. RGB16F: number;
  122354. RED: number;
  122355. RG: number;
  122356. R8: number;
  122357. RG8: number;
  122358. UNSIGNED_INT_24_8: number;
  122359. DEPTH24_STENCIL8: number;
  122360. /* Multiple Render Targets */
  122361. drawBuffers(buffers: number[]): void;
  122362. readBuffer(src: number): void;
  122363. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122364. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122365. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122366. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122367. // Occlusion Query
  122368. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122369. ANY_SAMPLES_PASSED: number;
  122370. QUERY_RESULT_AVAILABLE: number;
  122371. QUERY_RESULT: number;
  122372. }
  122373. interface WebGLProgram {
  122374. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122375. }
  122376. interface EXT_disjoint_timer_query {
  122377. QUERY_COUNTER_BITS_EXT: number;
  122378. TIME_ELAPSED_EXT: number;
  122379. TIMESTAMP_EXT: number;
  122380. GPU_DISJOINT_EXT: number;
  122381. QUERY_RESULT_EXT: number;
  122382. QUERY_RESULT_AVAILABLE_EXT: number;
  122383. queryCounterEXT(query: WebGLQuery, target: number): void;
  122384. createQueryEXT(): WebGLQuery;
  122385. beginQueryEXT(target: number, query: WebGLQuery): void;
  122386. endQueryEXT(target: number): void;
  122387. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122388. deleteQueryEXT(query: WebGLQuery): void;
  122389. }
  122390. interface WebGLUniformLocation {
  122391. _currentState: any;
  122392. }
  122393. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122394. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122395. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122396. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122397. interface WebGLRenderingContext {
  122398. readonly RASTERIZER_DISCARD: number;
  122399. readonly DEPTH_COMPONENT24: number;
  122400. readonly TEXTURE_3D: number;
  122401. readonly TEXTURE_2D_ARRAY: number;
  122402. readonly TEXTURE_COMPARE_FUNC: number;
  122403. readonly TEXTURE_COMPARE_MODE: number;
  122404. readonly COMPARE_REF_TO_TEXTURE: number;
  122405. readonly TEXTURE_WRAP_R: number;
  122406. readonly HALF_FLOAT: number;
  122407. readonly RGB8: number;
  122408. readonly RED_INTEGER: number;
  122409. readonly RG_INTEGER: number;
  122410. readonly RGB_INTEGER: number;
  122411. readonly RGBA_INTEGER: number;
  122412. readonly R8_SNORM: number;
  122413. readonly RG8_SNORM: number;
  122414. readonly RGB8_SNORM: number;
  122415. readonly RGBA8_SNORM: number;
  122416. readonly R8I: number;
  122417. readonly RG8I: number;
  122418. readonly RGB8I: number;
  122419. readonly RGBA8I: number;
  122420. readonly R8UI: number;
  122421. readonly RG8UI: number;
  122422. readonly RGB8UI: number;
  122423. readonly RGBA8UI: number;
  122424. readonly R16I: number;
  122425. readonly RG16I: number;
  122426. readonly RGB16I: number;
  122427. readonly RGBA16I: number;
  122428. readonly R16UI: number;
  122429. readonly RG16UI: number;
  122430. readonly RGB16UI: number;
  122431. readonly RGBA16UI: number;
  122432. readonly R32I: number;
  122433. readonly RG32I: number;
  122434. readonly RGB32I: number;
  122435. readonly RGBA32I: number;
  122436. readonly R32UI: number;
  122437. readonly RG32UI: number;
  122438. readonly RGB32UI: number;
  122439. readonly RGBA32UI: number;
  122440. readonly RGB10_A2UI: number;
  122441. readonly R11F_G11F_B10F: number;
  122442. readonly RGB9_E5: number;
  122443. readonly RGB10_A2: number;
  122444. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122445. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122446. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122447. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122448. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122449. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122450. 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;
  122451. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122452. readonly TRANSFORM_FEEDBACK: number;
  122453. readonly INTERLEAVED_ATTRIBS: number;
  122454. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122455. createTransformFeedback(): WebGLTransformFeedback;
  122456. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122457. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122458. beginTransformFeedback(primitiveMode: number): void;
  122459. endTransformFeedback(): void;
  122460. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122461. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122462. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122463. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122464. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122465. }
  122466. interface ImageBitmap {
  122467. readonly width: number;
  122468. readonly height: number;
  122469. close(): void;
  122470. }
  122471. interface WebGLQuery extends WebGLObject {
  122472. }
  122473. declare var WebGLQuery: {
  122474. prototype: WebGLQuery;
  122475. new(): WebGLQuery;
  122476. };
  122477. interface WebGLSampler extends WebGLObject {
  122478. }
  122479. declare var WebGLSampler: {
  122480. prototype: WebGLSampler;
  122481. new(): WebGLSampler;
  122482. };
  122483. interface WebGLSync extends WebGLObject {
  122484. }
  122485. declare var WebGLSync: {
  122486. prototype: WebGLSync;
  122487. new(): WebGLSync;
  122488. };
  122489. interface WebGLTransformFeedback extends WebGLObject {
  122490. }
  122491. declare var WebGLTransformFeedback: {
  122492. prototype: WebGLTransformFeedback;
  122493. new(): WebGLTransformFeedback;
  122494. };
  122495. interface WebGLVertexArrayObject extends WebGLObject {
  122496. }
  122497. declare var WebGLVertexArrayObject: {
  122498. prototype: WebGLVertexArrayObject;
  122499. new(): WebGLVertexArrayObject;
  122500. };
  122501. // Type definitions for WebVR API
  122502. // Project: https://w3c.github.io/webvr/
  122503. // Definitions by: six a <https://github.com/lostfictions>
  122504. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122505. interface VRDisplay extends EventTarget {
  122506. /**
  122507. * Dictionary of capabilities describing the VRDisplay.
  122508. */
  122509. readonly capabilities: VRDisplayCapabilities;
  122510. /**
  122511. * z-depth defining the far plane of the eye view frustum
  122512. * enables mapping of values in the render target depth
  122513. * attachment to scene coordinates. Initially set to 10000.0.
  122514. */
  122515. depthFar: number;
  122516. /**
  122517. * z-depth defining the near plane of the eye view frustum
  122518. * enables mapping of values in the render target depth
  122519. * attachment to scene coordinates. Initially set to 0.01.
  122520. */
  122521. depthNear: number;
  122522. /**
  122523. * An identifier for this distinct VRDisplay. Used as an
  122524. * association point in the Gamepad API.
  122525. */
  122526. readonly displayId: number;
  122527. /**
  122528. * A display name, a user-readable name identifying it.
  122529. */
  122530. readonly displayName: string;
  122531. readonly isConnected: boolean;
  122532. readonly isPresenting: boolean;
  122533. /**
  122534. * If this VRDisplay supports room-scale experiences, the optional
  122535. * stage attribute contains details on the room-scale parameters.
  122536. */
  122537. readonly stageParameters: VRStageParameters | null;
  122538. /**
  122539. * Passing the value returned by `requestAnimationFrame` to
  122540. * `cancelAnimationFrame` will unregister the callback.
  122541. * @param handle Define the hanle of the request to cancel
  122542. */
  122543. cancelAnimationFrame(handle: number): void;
  122544. /**
  122545. * Stops presenting to the VRDisplay.
  122546. * @returns a promise to know when it stopped
  122547. */
  122548. exitPresent(): Promise<void>;
  122549. /**
  122550. * Return the current VREyeParameters for the given eye.
  122551. * @param whichEye Define the eye we want the parameter for
  122552. * @returns the eye parameters
  122553. */
  122554. getEyeParameters(whichEye: string): VREyeParameters;
  122555. /**
  122556. * Populates the passed VRFrameData with the information required to render
  122557. * the current frame.
  122558. * @param frameData Define the data structure to populate
  122559. * @returns true if ok otherwise false
  122560. */
  122561. getFrameData(frameData: VRFrameData): boolean;
  122562. /**
  122563. * Get the layers currently being presented.
  122564. * @returns the list of VR layers
  122565. */
  122566. getLayers(): VRLayer[];
  122567. /**
  122568. * Return a VRPose containing the future predicted pose of the VRDisplay
  122569. * when the current frame will be presented. The value returned will not
  122570. * change until JavaScript has returned control to the browser.
  122571. *
  122572. * The VRPose will contain the position, orientation, velocity,
  122573. * and acceleration of each of these properties.
  122574. * @returns the pose object
  122575. */
  122576. getPose(): VRPose;
  122577. /**
  122578. * Return the current instantaneous pose of the VRDisplay, with no
  122579. * prediction applied.
  122580. * @returns the current instantaneous pose
  122581. */
  122582. getImmediatePose(): VRPose;
  122583. /**
  122584. * The callback passed to `requestAnimationFrame` will be called
  122585. * any time a new frame should be rendered. When the VRDisplay is
  122586. * presenting the callback will be called at the native refresh
  122587. * rate of the HMD. When not presenting this function acts
  122588. * identically to how window.requestAnimationFrame acts. Content should
  122589. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122590. * asynchronously from other displays and at differing refresh rates.
  122591. * @param callback Define the eaction to run next frame
  122592. * @returns the request handle it
  122593. */
  122594. requestAnimationFrame(callback: FrameRequestCallback): number;
  122595. /**
  122596. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122597. * Repeat calls while already presenting will update the VRLayers being displayed.
  122598. * @param layers Define the list of layer to present
  122599. * @returns a promise to know when the request has been fulfilled
  122600. */
  122601. requestPresent(layers: VRLayer[]): Promise<void>;
  122602. /**
  122603. * Reset the pose for this display, treating its current position and
  122604. * orientation as the "origin/zero" values. VRPose.position,
  122605. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122606. * updated when calling resetPose(). This should be called in only
  122607. * sitting-space experiences.
  122608. */
  122609. resetPose(): void;
  122610. /**
  122611. * The VRLayer provided to the VRDisplay will be captured and presented
  122612. * in the HMD. Calling this function has the same effect on the source
  122613. * canvas as any other operation that uses its source image, and canvases
  122614. * created without preserveDrawingBuffer set to true will be cleared.
  122615. * @param pose Define the pose to submit
  122616. */
  122617. submitFrame(pose?: VRPose): void;
  122618. }
  122619. declare var VRDisplay: {
  122620. prototype: VRDisplay;
  122621. new(): VRDisplay;
  122622. };
  122623. interface VRLayer {
  122624. leftBounds?: number[] | Float32Array | null;
  122625. rightBounds?: number[] | Float32Array | null;
  122626. source?: HTMLCanvasElement | null;
  122627. }
  122628. interface VRDisplayCapabilities {
  122629. readonly canPresent: boolean;
  122630. readonly hasExternalDisplay: boolean;
  122631. readonly hasOrientation: boolean;
  122632. readonly hasPosition: boolean;
  122633. readonly maxLayers: number;
  122634. }
  122635. interface VREyeParameters {
  122636. /** @deprecated */
  122637. readonly fieldOfView: VRFieldOfView;
  122638. readonly offset: Float32Array;
  122639. readonly renderHeight: number;
  122640. readonly renderWidth: number;
  122641. }
  122642. interface VRFieldOfView {
  122643. readonly downDegrees: number;
  122644. readonly leftDegrees: number;
  122645. readonly rightDegrees: number;
  122646. readonly upDegrees: number;
  122647. }
  122648. interface VRFrameData {
  122649. readonly leftProjectionMatrix: Float32Array;
  122650. readonly leftViewMatrix: Float32Array;
  122651. readonly pose: VRPose;
  122652. readonly rightProjectionMatrix: Float32Array;
  122653. readonly rightViewMatrix: Float32Array;
  122654. readonly timestamp: number;
  122655. }
  122656. interface VRPose {
  122657. readonly angularAcceleration: Float32Array | null;
  122658. readonly angularVelocity: Float32Array | null;
  122659. readonly linearAcceleration: Float32Array | null;
  122660. readonly linearVelocity: Float32Array | null;
  122661. readonly orientation: Float32Array | null;
  122662. readonly position: Float32Array | null;
  122663. readonly timestamp: number;
  122664. }
  122665. interface VRStageParameters {
  122666. sittingToStandingTransform?: Float32Array;
  122667. sizeX?: number;
  122668. sizeY?: number;
  122669. }
  122670. interface Navigator {
  122671. getVRDisplays(): Promise<VRDisplay[]>;
  122672. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122673. }
  122674. interface Window {
  122675. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122676. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122677. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122678. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122679. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122680. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122681. }
  122682. interface Gamepad {
  122683. readonly displayId: number;
  122684. }
  122685. interface XRDevice {
  122686. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  122687. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  122688. }
  122689. interface XRSession {
  122690. getInputSources(): Array<any>;
  122691. baseLayer: XRWebGLLayer;
  122692. requestFrameOfReference(type: string): Promise<void>;
  122693. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  122694. end(): Promise<void>;
  122695. requestAnimationFrame: Function;
  122696. addEventListener: Function;
  122697. }
  122698. interface XRSessionCreationOptions {
  122699. outputContext?: WebGLRenderingContext | null;
  122700. immersive?: boolean;
  122701. environmentIntegration?: boolean;
  122702. }
  122703. interface XRLayer {
  122704. getViewport: Function;
  122705. framebufferWidth: number;
  122706. framebufferHeight: number;
  122707. }
  122708. interface XRView {
  122709. projectionMatrix: Float32Array;
  122710. }
  122711. interface XRFrame {
  122712. getDevicePose: Function;
  122713. getInputPose: Function;
  122714. views: Array<XRView>;
  122715. baseLayer: XRLayer;
  122716. }
  122717. interface XRFrameOfReference {
  122718. }
  122719. interface XRWebGLLayer extends XRLayer {
  122720. framebuffer: WebGLFramebuffer;
  122721. }
  122722. declare var XRWebGLLayer: {
  122723. prototype: XRWebGLLayer;
  122724. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122725. };